Hay guys im trying to get my gamemode to interact with the database i setup in the gamemode/server
but im using net stuff but i don't understand how its not working
[code]
function loadout()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Testing Derma Stuff" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "Primary" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 20 )
DermaButton.DoClick = function ()
RunConsoleCommand("cl_loadout_primary")
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "M4A1" )
DermaButton:SetPos( 50, 50 )
DermaButton:SetSize( 150, 20 )
DermaButton.DoClick = function ()
net.Start( "Add_M4A1" )
net.WriteString( "Next time you will spawn with a M4A1" )
net.SendToServer()
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "AK47" )
DermaButton:SetPos( 75, 50 )
DermaButton:SetSize( 150, 20 )
DermaButton.DoClick = function ()
net.Start( "Add_AK47" )
net.WriteString( "Next time you will spawn with a AK47" )
net.SendToServer()
end
net.Receive( "Add_M4A1", function( len, ply )
if ( IsValid( ply ) and ply:IsPlayer() ) then
ply:Give("fas2_m4a1")
ply:SetNWString("primary", "fas2_m4a1")
else
return false
end
end )
net.Receive( "Add_AK47", function( len, pl )
if ( IsValid( ply ) and ply:IsPlayer() ) then
ply:Give("fas2_ak47")
ply:SetNWString("primary", "fas2_ak47")
else
return false
end
end )
net.Receive( "Add_P226", function( len, pl )
if ( IsValid( ply ) and ply:IsPlayer() ) then
ply:Give("fas2_p226")
ply:SetNWString("primary", "fas2_p226")
else
return false
end
end )
end
concommand.Add("cl_loadout_primary", loadout)
[/code]
Client and server at the same time
[QUOTE]
[ERROR] gamemodes/soldierwars/gamemode/cl_init.lua:61: Calling net.Start with unpooled message name [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. DoClick - gamemodes/soldierwars/gamemode/cl_init.lua:61
3. unknown - lua/vgui/dlabel.lua:206
[/QUOTE]
You forgot to call:
[lua]util.AddNetworkString( "Add_AK47" );
util.AddNetworkString( "Add_P226" );
util.AddNetworkString( "Add_M4A1" );
[/lua]
Server-side. You should think about making a generic one, like add_weapon or something which does the same thing but takes an input string. Also, never trust client-input; make sure they're allowed to spawn the weapon they send in.
You forgot to do util.AddNetworkString( string str ) serverside.
[url]http://wiki.garrysmod.com/page/util/AddNetworkString[/url]
Darn it, Ace ninja'd me
Thanks you. you made feel like an idiot but i understand the error Thanks!
Sorry, you need to Log In to post a reply to this thread.