From 1a9b325174c43677d8b4df2c5773dfbcebf8798e Mon Sep 17 00:00:00 2001 From: AlmTech Date: Wed, 30 Oct 2019 21:37:53 +0100 Subject: [PATCH] Added character limit --- gamemode/engine/derma/menus/menu_character.lua | 5 +++-- gamemode/engine/lib/server/sv_networking.lua | 8 ++++++++ gamemode/settings/sv_settings.lua | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index 8a7c1f5..6fa89a1 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -424,7 +424,7 @@ function menu.open( dt ) end local txt = vgui.Create( "DLabel", cpanels[count] ) - txt:SetText( v.name || "NAME" ) + txt:SetText( v.name || "[ERROR] NAME=nil" ) txt:SetFont( "q_charNameText" ) txt:SetTextColor( Color( 200, 200, 200, 220 ) ) txt:SizeToContents() @@ -516,7 +516,8 @@ function menu.open( dt ) p.enter.DoClick = function() surface.PlaySound( "UI/buttonclick.wav" ) -- enter world -- - snm.RunNetworkedFunc( "enterWorldChar", {index = selectedChar.index} ) -- FIX CRASH ISSUE ( 0xC00000FD ) + local dt = { index = selectedChar.index } + snm.RunNetworkedFunc( "enterWorldChar", dt ) -- FIX CRASH ISSUE ( 0xC00000FD ) end p.enter.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end end diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index 56e4a0b..c9c3923 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -61,6 +61,14 @@ local funcs = { local netfuncs = { createChar = function( pl, args ) pl.charcount = Quantum.Server.Char.GetCharCount( pl ) + if( #args.name > 16 ) then + Quantum.Debug( "Player " .. tostring( pl ) .. " character name too long. Unable to create." ) + return + elseif( pl.charcount + 1 > Quantum.Server.Settings.CharacterLimit ) then -- character limit + Quantum.Debug( "Player " .. tostring( pl ) .. " tried to exceed their character limit." ) + return + end + print(pl.charcount + 1) Quantum.Server.Char.Load( pl, pl.charcount + 1, args ) end, enterWorldChar = function( pl, args ) diff --git a/gamemode/settings/sv_settings.lua b/gamemode/settings/sv_settings.lua index 30bd68f..3cf3442 100644 --- a/gamemode/settings/sv_settings.lua +++ b/gamemode/settings/sv_settings.lua @@ -7,6 +7,8 @@ Quantum.Server.Settings = {} +Quantum.Server.Settings.CharacterLimit = 5 + Quantum.Server.Settings.VoiceChatRange = 400 Quantum.Server.Settings.MaxHealth = 100