Weapon System/ derma/ Databasing Help please!!

Hay guys im trying to get this code to work but its giving me some problems heres the code hope can help thanks. ;D

Error:

init.lua



function GM:PlayerSpawn( ply )

if ply:GetNWString("primary") == "" or ply:GetNWString("secondary") == "" then
		ply:Give("fas2_m4a1")
		ply:Give("fas2_p226")
		ply:SetNWString("primary", "fas2_m4a1")
		ply:SetNWString("secondary", "fas2_p226")
		else
		ply:Give( ply:GetNWString("primary") )
		ply:Give( ply:GetNWString("secondary") )
	end
end


cl_init.lua



util.AddNetworkString( "Add_AK47" );
util.AddNetworkString( "Add_P226" );
util.AddNetworkString( "Add_M4A1" );

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, 70 )
DermaButton:SetSize( 150, 20 )
DermaButton.DoClick = function ()
Msg("You will get your M4A1 when you respawn")
net.Start( "Add_M4A1" )
net.SendToServer()
end

local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "AK47" )
DermaButton:SetPos( 50, 90 )
DermaButton:SetSize( 150, 20 )
DermaButton.DoClick = function ()
Msg("You will get your ak47 when you respawn")
net.Start( "Add_AK47" )
net.SendToServer()
end
end
concommand.Add("cl_loadout_primary", loadout)

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 )


In your other thread I mentioned that they need to be in a SERVER-side file.

init.lua

So i put it all in the init file? or do you want me to put in the derma to the cl_init.lua then the rest to init.lua ??

[editline]8th March 2014[/editline]

i figured out it was pl i was putting ply…
sorry for the big trouble human error…