Give command doesn't work (A nil Value)

I try to make a console command to give or giveammo with slider and ComboBox it doesn’t work.
Thanks in advance.



autorun\client	est.lua:122: attempt to call method 'give' (a nil value)


[lua]HealthX = player.GetByID( 1 ):Health()
SetHealthX = player.GetByID( 1 ):SetHealth()
PGetID1 = LocalPlayer()
x1 = 560
y1 = 20
gun1 = weapon_ar2

function myhud()

for k,v in pairs (LocalPlayer():GetWeapons()) do
if v:GetClass() == gun1 then
draw.SimpleText("Clip: " … v:Clip1(), “ScoreboardText”, 15, 50, Color(242, 204, 51, 225), 0, 0)
– draw.SimpleText("Clip Extra: " … client:GetAmmoCount(v:GetActiveWeapon():GetPrimaryAmmoType()), “ScoreboardText”, 15, 60, Color(242, 204, 51, 225), 0, 0)
draw.SimpleText("Clip Secondary: " … LocalPlayer():GetAmmoCount(v:GetSecondaryAmmoType( )), “ScoreboardText”, 15, 70, Color(242, 204, 51, 225), 0, 0)

end

end
end

hook.Add(“HUDPaint”, “myhud”, myhud)

function DrawPlayerHealth()
if (LocalPlayer():Health() > 0) then
draw.RoundedBox( 6, 5 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 6 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 10 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Health() / 1000), 4, Color(255, 0, 0, 255));
draw.SimpleText("HP: " … LocalPlayer():Health() … “%”, “ScoreboardText”, 16 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerhealth”,DrawPlayerHealth);

function DrawPlayerArmor()
if (LocalPlayer():Armor() > 0) then
draw.RoundedBox(6, 125 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 126 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 130 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Armor() / 1000), 4, Color(0, 51, 255, 255));
draw.SimpleText("AP: " … LocalPlayer():Armor() … “%”, “ScoreboardText”, 132 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerarmor”,DrawPlayerArmor);

function hidehud(name)
for k, v in pairs({“CHudHealth”, “CHudBattery”} ) do
if name == v then return false end
end
end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

DermaPanel = vgui.Create(“DFrame”)
DermaPanel:SetTitle( "Lotus006 Ammo HUD: ")
DermaPanel:SetPos( 25,20 )
DermaPanel:SetTall(425)
DermaPanel:SetWide(360)
DermaPanel:Center()
DermaPanel:MakePopup()

NumSlider = vgui.Create( “DNumSlider”, DermaPanel )
NumSlider:SetPos( 25,50 )
NumSlider:SetWide( 100 )
NumSlider:GetValue( SetHealthX )
NumSlider:SetText( " Set Health: ")
NumSlider:SetMin( 1 ) – Minimum number of the slider
NumSlider:SetValue( HealthX )
NumSlider:SetMax( 300 ) – Maximum number of the slider
NumSlider:SetDecimals( 0 ) – Sets a decimal. Zero means it’s a whole number
NumSlider.Slider:SetSlideX( HealthX ) – This value is between 0 and 1. Since Health is 50 and the max slider is 100 it will be halfway.

SomeCollapsibleCategory = vgui.Create(“DCollapsibleCategory”, DermaPanel)
SomeCollapsibleCategory:SetPos( 25, 100 )
SomeCollapsibleCategory:SetSize( 200, 50 ) – Keep the second number at 50
SomeCollapsibleCategory:SetExpanded( 1 ) – Expanded when popped up
SomeCollapsibleCategory:SetLabel( "Weapon AR2 : On Screen " )

CategoryList = vgui.Create( “DPanelList” )
CategoryList:SetAutoSize( false )
CategoryList:SetSize( 100, 160 )
CategoryList:SetSpacing( 5 )
CategoryList:EnableHorizontal( false )
CategoryList:EnableVerticalScrollbar( true )

SomeCollapsibleCategory:SetContents( CategoryList ) – Add our list above us as the contents of the collapsible category

SetAmmoAR2 = vgui.Create( “DNumSlider” )
SetAmmoAR2:SetSize( 120, 50 ) – Keep the second number at 50
SetAmmoAR2:SetPos( 5, 5 )
SetAmmoAR2:SetText( “Primary Ammo” )
SetAmmoAR2:SetMin( 0 )
SetAmmoAR2:SetMax( 2000 )
SetAmmoAR2:SetValue( )
SetAmmoAR2:SetDecimals( 0 )
SetAmmoAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAR2 )

SetAmmoAltAR2 = vgui.Create( “DNumSlider” )
SetAmmoAltAR2:SetSize( 150, 50 ) – Keep the second number at 50
SetAmmoAltAR2:SetText( “Alt Ammo” )
SetAmmoAltAR2:SetPos( 5, 5 )
SetAmmoAltAR2:SetMin( 0 )
SetAmmoAltAR2:SetMax( 2000 )
SetAmmoAltAR2:SetDecimals( 0 )
SetAmmoAltAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAltAR2 )

ButtonGAR2 = vgui.Create( “DButton”, DermaPanel );
ButtonGAR2:SetSize( 100, 30 );
ButtonGAR2:SetPos( 50, 30 );
ButtonGAR2:SetText( “Give AR2” );
ButtonGAR2.DoClick = function()
RunConsoleCommand( “StripAndGive” )
end

CategoryList:AddItem( ButtonGAR2 )

function StripAndGive(ply)
ply:StripWeapons()
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_gravgun”)
ply:Give(“gmod_toolgun”)
return true
end
hook.Add(“PlayerLoadout”, “StripAndGive”, StripAndGive)[/lua]

Give isn’t clientside, as shown on the bottom of your code.

thanks but how I can make serverside ?

You would have to put it in autorun/test.lua, in your server files.

[lua]if SERVER then
function StripAndGive(ply)
ply:StripWeapons()
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_gravgun”)
ply:Give(“gmod_toolgun”)
return true
end
concommand.Add(“StripAndGive”, StripAndGive)
end
[/lua]

Along with your code you have, I edited so it will work now for your RunConsoleCommand.

the console say :
And my file is in autorun/test.lua



Unknown command: StripAndGive


Show the new code.

the code is in the firt post here.

I gave you the new code for it damn why don’t you listen.

[lua]
HealthX = player.GetByID( 1 ):Health()
SetHealthX = player.GetByID( 1 ):SetHealth()
PGetID1 = LocalPlayer()
x1 = 560
y1 = 20
gun1 = weapon_ar2

function myhud()

for k,v in pairs (LocalPlayer():GetWeapons()) do
if v:GetClass() == gun1 then
draw.SimpleText("Clip: " … v:Clip1(), “ScoreboardText”, 15, 50, Color(242, 204, 51, 225), 0, 0)
– draw.SimpleText("Clip Extra: " … client:GetAmmoCount(v:GetActiveWeapon():GetPrimaryAmmoType()), “ScoreboardText”, 15, 60, Color(242, 204, 51, 225), 0, 0)
draw.SimpleText("Clip Secondary: " … LocalPlayer():GetAmmoCount(v:GetSecondaryAmmoType( )), “ScoreboardText”, 15, 70, Color(242, 204, 51, 225), 0, 0)

end

end
end

hook.Add(“HUDPaint”, “myhud”, myhud)

function DrawPlayerHealth()
if (LocalPlayer():Health() > 0) then
draw.RoundedBox( 6, 5 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 6 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 10 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Health() / 1000), 4, Color(255, 0, 0, 255));
draw.SimpleText("HP: " … LocalPlayer():Health() … “%”, “ScoreboardText”, 16 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerhealth”,DrawPlayerHealth);

function DrawPlayerArmor()
if (LocalPlayer():Armor() > 0) then
draw.RoundedBox(6, 125 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 126 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 130 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Armor() / 1000), 4, Color(0, 51, 255, 255));
draw.SimpleText("AP: " … LocalPlayer():Armor() … “%”, “ScoreboardText”, 132 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerarmor”,DrawPlayerArmor);

function hidehud(name)
for k, v in pairs({“CHudHealth”, “CHudBattery”} ) do
if name == v then return false end
end
end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

DermaPanel = vgui.Create(“DFrame”)
DermaPanel:SetTitle( "Lotus006 Ammo HUD: ")
DermaPanel:SetPos( 25,20 )
DermaPanel:SetTall(425)
DermaPanel:SetWide(360)
DermaPanel:Center()
DermaPanel:MakePopup()

NumSlider = vgui.Create( “DNumSlider”, DermaPanel )
NumSlider:SetPos( 25,50 )
NumSlider:SetWide( 100 )
NumSlider:GetValue( SetHealthX )
NumSlider:SetText( " Set Health: ")
NumSlider:SetMin( 1 ) – Minimum number of the slider
NumSlider:SetValue( HealthX )
NumSlider:SetMax( 300 ) – Maximum number of the slider
NumSlider:SetDecimals( 0 ) – Sets a decimal. Zero means it’s a whole number
NumSlider.Slider:SetSlideX( HealthX ) – This value is between 0 and 1. Since Health is 50 and the max slider is 100 it will be halfway.

SomeCollapsibleCategory = vgui.Create(“DCollapsibleCategory”, DermaPanel)
SomeCollapsibleCategory:SetPos( 25, 100 )
SomeCollapsibleCategory:SetSize( 200, 50 ) – Keep the second number at 50
SomeCollapsibleCategory:SetExpanded( 1 ) – Expanded when popped up
SomeCollapsibleCategory:SetLabel( "Weapon AR2 : On Screen " )

CategoryList = vgui.Create( “DPanelList” )
CategoryList:SetAutoSize( false )
CategoryList:SetSize( 100, 160 )
CategoryList:SetSpacing( 5 )
CategoryList:EnableHorizontal( false )
CategoryList:EnableVerticalScrollbar( true )

SomeCollapsibleCategory:SetContents( CategoryList ) – Add our list above us as the contents of the collapsible category

SetAmmoAR2 = vgui.Create( “DNumSlider” )
SetAmmoAR2:SetSize( 120, 50 ) – Keep the second number at 50
SetAmmoAR2:SetPos( 5, 5 )
SetAmmoAR2:SetText( “Primary Ammo” )
SetAmmoAR2:SetMin( 0 )
SetAmmoAR2:SetMax( 2000 )
SetAmmoAR2:SetValue( )
SetAmmoAR2:SetDecimals( 0 )
SetAmmoAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAR2 )

SetAmmoAltAR2 = vgui.Create( “DNumSlider” )
SetAmmoAltAR2:SetSize( 150, 50 ) – Keep the second number at 50
SetAmmoAltAR2:SetText( “Alt Ammo” )
SetAmmoAltAR2:SetPos( 5, 5 )
SetAmmoAltAR2:SetMin( 0 )
SetAmmoAltAR2:SetMax( 2000 )
SetAmmoAltAR2:SetDecimals( 0 )
SetAmmoAltAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAltAR2 )

ButtonGAR2 = vgui.Create( “DButton”, DermaPanel );
ButtonGAR2:SetSize( 100, 30 );
ButtonGAR2:SetPos( 50, 30 );
ButtonGAR2:SetText( “Give AR2” );
ButtonGAR2.DoClick = function()
RunConsoleCommand( “StripAndGive” )
end

CategoryList:AddItem( ButtonGAR2 )

– Fixed
if SERVER then
function StripAndGive(ply)
ply:StripWeapons()
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_gravgun”)
ply:Give(“gmod_toolgun”)
return true
end
concommand.Add(“StripAndGive”, StripAndGive)
end
[/lua]

oops sorry I was thinking I have put your one but I made a mistake.

Edit: Same error

[lua]HealthX = player.GetByID( 1 ):Health()
SetHealthX = player.GetByID( 1 ):SetHealth()
PGetID1 = LocalPlayer()
x1 = 560
y1 = 20
gun1 = weapon_ar2

function myhud()

for k,v in pairs (LocalPlayer():GetWeapons()) do
if v:GetClass() == gun1 then
draw.SimpleText("Clip: " … v:Clip1(), “ScoreboardText”, 15, 50, Color(242, 204, 51, 225), 0, 0)
– draw.SimpleText("Clip Extra: " … client:GetAmmoCount(v:GetActiveWeapon():GetPrimaryAmmoType()), “ScoreboardText”, 15, 60, Color(242, 204, 51, 225), 0, 0)
draw.SimpleText("Clip Secondary: " … LocalPlayer():GetAmmoCount(v:GetSecondaryAmmoType( )), “ScoreboardText”, 15, 70, Color(242, 204, 51, 225), 0, 0)

end

end
end

hook.Add(“HUDPaint”, “myhud”, myhud)

function DrawPlayerHealth()
if (LocalPlayer():Health() > 0) then
draw.RoundedBox( 6, 5 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 6 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 10 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Health() / 1000), 4, Color(255, 0, 0, 255));
draw.SimpleText("HP: " … LocalPlayer():Health() … “%”, “ScoreboardText”, 16 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerhealth”,DrawPlayerHealth);

function DrawPlayerArmor()
if (LocalPlayer():Armor() > 0) then
draw.RoundedBox(6, 125 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 126 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 130 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Armor() / 1000), 4, Color(0, 51, 255, 255));
draw.SimpleText("AP: " … LocalPlayer():Armor() … “%”, “ScoreboardText”, 132 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerarmor”,DrawPlayerArmor);

function hidehud(name)
for k, v in pairs({“CHudHealth”, “CHudBattery”} ) do
if name == v then return false end
end
end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

DermaPanel = vgui.Create(“DFrame”)
DermaPanel:SetTitle( "Lotus006 Ammo HUD: ")
DermaPanel:SetPos( 25,20 )
DermaPanel:SetTall(425)
DermaPanel:SetWide(360)
DermaPanel:Center()
DermaPanel:MakePopup()

NumSlider = vgui.Create( “DNumSlider”, DermaPanel )
NumSlider:SetPos( 25,50 )
NumSlider:SetWide( 100 )
NumSlider:GetValue( SetHealthX )
NumSlider:SetText( " Set Health: ")
NumSlider:SetMin( 1 ) – Minimum number of the slider
NumSlider:SetValue( HealthX )
NumSlider:SetMax( 300 ) – Maximum number of the slider
NumSlider:SetDecimals( 0 ) – Sets a decimal. Zero means it’s a whole number
NumSlider.Slider:SetSlideX( HealthX ) – This value is between 0 and 1. Since Health is 50 and the max slider is 100 it will be halfway.

SomeCollapsibleCategory = vgui.Create(“DCollapsibleCategory”, DermaPanel)
SomeCollapsibleCategory:SetPos( 25, 100 )
SomeCollapsibleCategory:SetSize( 200, 50 ) – Keep the second number at 50
SomeCollapsibleCategory:SetExpanded( 1 ) – Expanded when popped up
SomeCollapsibleCategory:SetLabel( "Weapon AR2 : On Screen " )

CategoryList = vgui.Create( “DPanelList” )
CategoryList:SetAutoSize( false )
CategoryList:SetSize( 100, 160 )
CategoryList:SetSpacing( 5 )
CategoryList:EnableHorizontal( false )
CategoryList:EnableVerticalScrollbar( true )

SomeCollapsibleCategory:SetContents( CategoryList ) – Add our list above us as the contents of the collapsible category

SetAmmoAR2 = vgui.Create( “DNumSlider” )
SetAmmoAR2:SetSize( 120, 50 ) – Keep the second number at 50
SetAmmoAR2:SetPos( 5, 5 )
SetAmmoAR2:SetText( “Primary Ammo” )
SetAmmoAR2:SetMin( 0 )
SetAmmoAR2:SetMax( 2000 )
SetAmmoAR2:SetValue( )
SetAmmoAR2:SetDecimals( 0 )
SetAmmoAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAR2 )

SetAmmoAltAR2 = vgui.Create( “DNumSlider” )
SetAmmoAltAR2:SetSize( 150, 50 ) – Keep the second number at 50
SetAmmoAltAR2:SetText( “Alt Ammo” )
SetAmmoAltAR2:SetPos( 5, 5 )
SetAmmoAltAR2:SetMin( 0 )
SetAmmoAltAR2:SetMax( 2000 )
SetAmmoAltAR2:SetDecimals( 0 )
SetAmmoAltAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAltAR2 )

ButtonGAR2 = vgui.Create( “DButton”, DermaPanel );
ButtonGAR2:SetSize( 100, 30 );
ButtonGAR2:SetPos( 50, 30 );
ButtonGAR2:SetText( “Give AR2” );
ButtonGAR2.DoClick = function()
RunConsoleCommand( “StripAndGive” )
end

CategoryList:AddItem( ButtonGAR2 )

– Fixed
if SERVER then
function StripAndGive(ply)
ply:StripWeapons()
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_gravgun”)
ply:Give(“gmod_toolgun”)
return true
end
concommand.Add(“StripAndGive”, StripAndGive)
end
[/lua]

where are you saving it and how are you running this?

in the autorun/test.lua and lua_openscript_cl autorun est.lua for refresh.

If your opening it on client how do you expect this to work?

run the function on line 122 on server then other code on client

like this ? but it give no error

[lua]HealthX = player.GetByID( 1 ):Health()
SetHealthX = player.GetByID( 1 ):SetHealth()
PGetID1 = LocalPlayer()
x1 = 560
y1 = 20
gun1 = weapon_ar2

function myhud()

for k,v in pairs (LocalPlayer():GetWeapons()) do
if v:GetClass() == gun1 then
draw.SimpleText("Clip: " … v:Clip1(), “ScoreboardText”, 15, 50, Color(242, 204, 51, 225), 0, 0)
– draw.SimpleText("Clip Extra: " … client:GetAmmoCount(v:GetActiveWeapon():GetPrimaryAmmoType()), “ScoreboardText”, 15, 60, Color(242, 204, 51, 225), 0, 0)
draw.SimpleText("Clip Secondary: " … LocalPlayer():GetAmmoCount(v:GetSecondaryAmmoType( )), “ScoreboardText”, 15, 70, Color(242, 204, 51, 225), 0, 0)

end

end
end

hook.Add(“HUDPaint”, “myhud”, myhud)

function DrawPlayerHealth()
if (LocalPlayer():Health() > 0) then
draw.RoundedBox( 6, 5 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 6 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 10 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Health() / 1000), 4, Color(255, 0, 0, 255));
draw.SimpleText("HP: " … LocalPlayer():Health() … “%”, “ScoreboardText”, 16 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerhealth”,DrawPlayerHealth);

function DrawPlayerArmor()
if (LocalPlayer():Armor() > 0) then
draw.RoundedBox(6, 125 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 126 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 130 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Armor() / 1000), 4, Color(0, 51, 255, 255));
draw.SimpleText("AP: " … LocalPlayer():Armor() … “%”, “ScoreboardText”, 132 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerarmor”,DrawPlayerArmor);

function hidehud(name)
for k, v in pairs({“CHudHealth”, “CHudBattery”} ) do
if name == v then return false end
end
end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

if SERVER then
DermaPanel = vgui.Create(“DFrame”)
DermaPanel:SetTitle( "Lotus006 Ammo HUD: ")
DermaPanel:SetPos( 25,20 )
DermaPanel:SetTall(425)
DermaPanel:SetWide(360)
DermaPanel:Center()
DermaPanel:MakePopup()

NumSlider = vgui.Create( “DNumSlider”, DermaPanel )
NumSlider:SetPos( 25,50 )
NumSlider:SetWide( 100 )
NumSlider:GetValue( SetHealthX )
NumSlider:SetText( " Set Health: ")
NumSlider:SetMin( 1 ) – Minimum number of the slider
NumSlider:SetValue( HealthX )
NumSlider:SetMax( 300 ) – Maximum number of the slider
NumSlider:SetDecimals( 0 ) – Sets a decimal. Zero means it’s a whole number
NumSlider.Slider:SetSlideX( HealthX ) – This value is between 0 and 1. Since Health is 50 and the max slider is 100 it will be halfway.

SomeCollapsibleCategory = vgui.Create(“DCollapsibleCategory”, DermaPanel)
SomeCollapsibleCategory:SetPos( 25, 100 )
SomeCollapsibleCategory:SetSize( 200, 50 ) – Keep the second number at 50
SomeCollapsibleCategory:SetExpanded( 1 ) – Expanded when popped up
SomeCollapsibleCategory:SetLabel( "Weapon AR2 : On Screen " )

CategoryList = vgui.Create( “DPanelList” )
CategoryList:SetAutoSize( false )
CategoryList:SetSize( 100, 160 )
CategoryList:SetSpacing( 5 )
CategoryList:EnableHorizontal( false )
CategoryList:EnableVerticalScrollbar( true )

SomeCollapsibleCategory:SetContents( CategoryList ) – Add our list above us as the contents of the collapsible category

SetAmmoAR2 = vgui.Create( “DNumSlider” )
SetAmmoAR2:SetSize( 120, 50 ) – Keep the second number at 50
SetAmmoAR2:SetPos( 5, 5 )
SetAmmoAR2:SetText( “Primary Ammo” )
SetAmmoAR2:SetMin( 0 )
SetAmmoAR2:SetMax( 2000 )
SetAmmoAR2:SetValue( )
SetAmmoAR2:SetDecimals( 0 )
SetAmmoAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAR2 )

SetAmmoAltAR2 = vgui.Create( “DNumSlider” )
SetAmmoAltAR2:SetSize( 150, 50 ) – Keep the second number at 50
SetAmmoAltAR2:SetText( “Alt Ammo” )
SetAmmoAltAR2:SetPos( 5, 5 )
SetAmmoAltAR2:SetMin( 0 )
SetAmmoAltAR2:SetMax( 2000 )
SetAmmoAltAR2:SetDecimals( 0 )
SetAmmoAltAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAltAR2 )

ButtonGAR2 = vgui.Create( “DButton”, DermaPanel );
ButtonGAR2:SetSize( 100, 30 );
ButtonGAR2:SetPos( 50, 30 );
ButtonGAR2:SetText( “Give AR2” );

CategoryList:AddItem( ButtonGAR2 )

– Fixed 2nd time

function StripAndGive(ply)

ButtonGAR2.DoClick = function()
	RunConsoleCommand( "StripAndGive" )

end
ply:StripWeapons()
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_gravgun”)
ply:Give(“gmod_toolgun”)
return true
end
concommand.Add(“StripAndGive”, StripAndGive)
end
[/lua]

No this needs too go on server not client
[lua]
function StripAndGive(ply)
ply:StripWeapons()
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_gravgun”)
ply:Give(“gmod_toolgun”)
return true
end
concommand.Add(“StripAndGive”, StripAndGive)
end
[/lua]

what do you mean ? I did this before too,

and with this too

[lua]

HealthX = player.GetByID( 1 ):Health()
SetHealthX = player.GetByID( 1 ):SetHealth()
PGetID1 = LocalPlayer()
x1 = 560
y1 = 20
gun1 = weapon_ar2

function myhud()

for k,v in pairs (LocalPlayer():GetWeapons()) do
if v:GetClass() == gun1 then
draw.SimpleText("Clip: " … v:Clip1(), “ScoreboardText”, 15, 50, Color(242, 204, 51, 225), 0, 0)
– draw.SimpleText("Clip Extra: " … client:GetAmmoCount(v:GetActiveWeapon():GetPrimaryAmmoType()), “ScoreboardText”, 15, 60, Color(242, 204, 51, 225), 0, 0)
draw.SimpleText("Clip Secondary: " … LocalPlayer():GetAmmoCount(v:GetSecondaryAmmoType( )), “ScoreboardText”, 15, 70, Color(242, 204, 51, 225), 0, 0)

end

end
end

hook.Add(“HUDPaint”, “myhud”, myhud)

function DrawPlayerHealth()
if (LocalPlayer():Health() > 0) then
draw.RoundedBox( 6, 5 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 6 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 10 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Health() / 1000), 4, Color(255, 0, 0, 255));
draw.SimpleText("HP: " … LocalPlayer():Health() … “%”, “ScoreboardText”, 16 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerhealth”,DrawPlayerHealth);

function DrawPlayerArmor()
if (LocalPlayer():Armor() > 0) then
draw.RoundedBox(6, 125 + y1, 5 + x1, 100, 27, Color(0, 0, 0, 150))
draw.RoundedBox( 4, 126 + y1, 34 + x1, 98, 10, Color(0, 0, 0, 150));
draw.RoundedBox( 2, 130 + y1, 37 + x1, (ScrW() - 126)*(LocalPlayer():Armor() / 1000), 4, Color(0, 51, 255, 255));
draw.SimpleText("AP: " … LocalPlayer():Armor() … “%”, “ScoreboardText”, 132 + y1, 10 + x1, Color(242, 204, 51, 255), 0, 0)
end
end
hook.Add(“HUDPaint”,“drawplayerarmor”,DrawPlayerArmor);

function hidehud(name)
for k, v in pairs({“CHudHealth”, “CHudBattery”} ) do
if name == v then return false end
end
end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

if SERVER then
function StripAndGive(ply)
ply:StripWeapons()
ply:Give(“weapon_physcannon”)
ply:Give(“weapon_gravgun”)
ply:Give(“gmod_toolgun”)
return true
end
concommand.Add(“StripAndGive”, StripAndGive)
end

DermaPanel = vgui.Create(“DFrame”)
DermaPanel:SetTitle( "Lotus006 Ammo HUD: ")
DermaPanel:SetPos( 25,20 )
DermaPanel:SetTall(425)
DermaPanel:SetWide(360)
DermaPanel:Center()
DermaPanel:MakePopup()

NumSlider = vgui.Create( “DNumSlider”, DermaPanel )
NumSlider:SetPos( 25,50 )
NumSlider:SetWide( 100 )
NumSlider:GetValue( SetHealthX )
NumSlider:SetText( " Set Health: ")
NumSlider:SetMin( 1 ) – Minimum number of the slider
NumSlider:SetValue( HealthX )
NumSlider:SetMax( 300 ) – Maximum number of the slider
NumSlider:SetDecimals( 0 ) – Sets a decimal. Zero means it’s a whole number
NumSlider.Slider:SetSlideX( HealthX ) – This value is between 0 and 1. Since Health is 50 and the max slider is 100 it will be halfway.

SomeCollapsibleCategory = vgui.Create(“DCollapsibleCategory”, DermaPanel)
SomeCollapsibleCategory:SetPos( 25, 100 )
SomeCollapsibleCategory:SetSize( 200, 50 ) – Keep the second number at 50
SomeCollapsibleCategory:SetExpanded( 1 ) – Expanded when popped up
SomeCollapsibleCategory:SetLabel( "Weapon AR2 : On Screen " )

CategoryList = vgui.Create( “DPanelList” )
CategoryList:SetAutoSize( false )
CategoryList:SetSize( 100, 160 )
CategoryList:SetSpacing( 5 )
CategoryList:EnableHorizontal( false )
CategoryList:EnableVerticalScrollbar( true )

SomeCollapsibleCategory:SetContents( CategoryList ) – Add our list above us as the contents of the collapsible category

SetAmmoAR2 = vgui.Create( “DNumSlider” )
SetAmmoAR2:SetSize( 120, 50 ) – Keep the second number at 50
SetAmmoAR2:SetPos( 5, 5 )
SetAmmoAR2:SetText( “Primary Ammo” )
SetAmmoAR2:SetMin( 0 )
SetAmmoAR2:SetMax( 2000 )
SetAmmoAR2:SetValue( )
SetAmmoAR2:SetDecimals( 0 )
SetAmmoAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAR2 )

SetAmmoAltAR2 = vgui.Create( “DNumSlider” )
SetAmmoAltAR2:SetSize( 150, 50 ) – Keep the second number at 50
SetAmmoAltAR2:SetText( “Alt Ammo” )
SetAmmoAltAR2:SetPos( 5, 5 )
SetAmmoAltAR2:SetMin( 0 )
SetAmmoAltAR2:SetMax( 2000 )
SetAmmoAltAR2:SetDecimals( 0 )
SetAmmoAltAR2:SetConVar( “sbox_maxprops” )
CategoryList:AddItem( SetAmmoAltAR2 )

ButtonGAR2 = vgui.Create( “DButton”, DermaPanel );
ButtonGAR2:SetSize( 100, 30 );
ButtonGAR2:SetPos( 50, 30 );
ButtonGAR2:SetText( “Give AR2” );
ButtonGAR2.DoClick = function()
RunConsoleCommand( “StripAndGive” )
end

CategoryList:AddItem( ButtonGAR2 )
[/lua]

This is clientside code it gets run on client

The code I had in last post

is server side code

what you are doing is mixing the two together

I’m not sure about what you talking sorry about this I try to learn lua but this time i’m not sure about this.

you mean in my folder autorun/server/test.lua or

you mean about mixing the code ?

It doesn’t work on clientside sorry you will have to use gm_giveswep or gm_spawnswep for that. Requires sandbox, or Roleplay servers.

lua_openscript_cl Opens clientside code
lua_openscript opens serverside code

oh ok thanks I see this in wiki now but do you think can be ok ?
([URL=“http://wiki.garrysmod.com/?title=Gm_giveswep”]http://wiki.garrysmod.com/?title=Gm_giveswep)

[lua]ButtonGAR2 = vgui.Create( “DButton”, DermaPanel );
ButtonGAR2:SetSize( 100, 30 );
ButtonGAR2:SetPos( 50, 30 );
ButtonGAR2:SetText( “Give AR2” );
ButtonGAR2.DoClick = function()
RunConsoleCommand( “StripAndGive” )
end

CategoryList:AddItem( ButtonGAR2 )

– Fixed
if SERVER then
function StripAndGive(ply)

gm_giveswep(“weapon_physcannon”)
return true
end
concommand.Add(“StripAndGive”, StripAndGive)
end[/lua]