How do you give a weapon through derma for fretta

Pretty simple, i need to know how to make a derma frame with a button that takes away 10 from a networked int and gives them a weapon like a shotgun.

-snip-
(apparantly people can be dicks if they want)

Chad, if you don’t know half of what you’re talking about then quit posting.

As for your question, the most efficient way for the client to communicate with the server is through concommands. For example,

[lua]-- ON THE SERVER
function GivePistol( pl )
pl:Give( “weapon_pistol” )
end
concommand.Add( “give_pistol”, GivePistol )

– ON THE CLIENT, A BUTTON IN A MENU
button.DoClick = function()
RunConsoleCommand( “give_pistol” )
end[/lua]

alright trying it now
EDIT:: ok im getting this error



M.A.N/gamemode/cl_init.lua:34: attempt to index global 'button' (a nil value)


this is init.lua


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( "shared.lua" )

function GM:OnNPCKilled( Npc, pl )  
   if( pl:IsPlayer() ) then  //Checks to see if they are actually a player.
      pl:SetNetworkedInt( "Stats", pl:GetNetworkedInt( "Stats" ) + 1 )
	pl:SetFrags( pl:Frags() + 1 )   
   end  
end

function SchoolShow( ply )
	ply:ConCommand( "f4" )
end
hook.Add("ShowSpare2", "School", SchoolShow)

function GivePistol( pl )  
    pl:Give( "weapon_pistol" )  
end  
concommand.Add( "give_pistol", GivePistol ) 


and this is cl_init



include( 'shared.lua' )


function GM:PositionScoreboard( ScoreBoard )

	ScoreBoard:SetSize( 700, ScrH() - 100 )
	ScoreBoard:SetPos( (ScrW() - ScoreBoard:GetWide()) / 2, 50 )

end


function GM:HUDPaint()  
    draw.SimpleText("Stats: " .. tostring(LocalPlayer():GetNetworkedInt("Stats")), "ScoreboardText", ScrW() / 2 - 70, ScrH() - 63, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)  
end  

function f4()
	local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
	DermaPanel:SetPos( 50,50 ) -- Position on the players screen
	DermaPanel:SetSize( 400, 300 ) -- Size of the frame
	DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
	DermaPanel:SetVisible( true )
	DermaPanel:SetDraggable( true ) -- Draggable by mouse?
	DermaPanel:ShowCloseButton( true ) -- Show the close button?
	DermaPanel:MakePopup() -- Show the frame
	//*************************************
	//Buttons
	local DermaButton = vgui.Create( "DButton" )
	DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
		DermaButton:SetText( "Kill yourself" )
			DermaButton:SetPos( 25, 50 )
			DermaButton:SetSize( 150, 50 )
				button.DoClick = function()  
					RunConsoleCommand( "give_pistol" )  
				end  
end
concommand.Add( "f4", f4 )



button.DoClick is supposed to be DermaButton.DoClick

awesome it works =) thanks for all your help! my gamemodes gonna be epic.

[lua]function GivePistol( pl )
pl:Give( “weapon_pistol” )
end
concommand.Add( “give_pistol”, GivePistol )[/lua]

He has a function called give_pistol.

Well i think its best to keep things simple, good luck

im using that give_pistol as a stand in for an upgrade function. i have a question how would i check to see if a networked int is greater then 0?

>.>

if networkedint > 0 then


if player:GetNetworkedInt( "Pistol" ) > 0 then
             -- Stuff
end

ya i just realized that that was a stupid question I asked, figured it out earlier in my computer science class today.