[CODE]function giverpg( ply, comand, args)
if (ply:GetPData("Money") > 800) then
(ply:SetPData("money") = ply:SetPData("money") - 800)
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/CODE]
when I type giverpg in console nothing happens
[CODE]function giverpg( ply, comand, args)
if (ply:GetPData("Money") > 800) then
(ply:SetPData("money", ply:GetPData("money") - 800) )
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/CODE]
Try that.
[QUOTE=Fortune11709;43456955][CODE]function giverpg( ply, comand, args)
if (ply:GetPData("Money") > 800) then
(ply:SetPData("money", ply:GetPData("money") - 800) )
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/CODE]
Try that.[/QUOTE]
Didnt work :(
Check the syntax for [URL="http://wiki.garrysmod.com/page/Player/GetPData"]GetPData[/URL] and [URL="http://wiki.garrysmod.com/page/Player/SetPData"]SetPData[/URL].
What about posting the error it makes it easier to find out whats wrong
[QUOTE=Doge is Hope;43458738]What about posting the error it makes it easier to find out whats wrong[/QUOTE]
He doesn't have to post an error, I posted the syntax, all he has to do is follow it.
[QUOTE=BOT Faggot;43456849][CODE]function giverpg( ply, comand, args)
if (ply:GetPData("Money") > 800) then
(ply:SetPData("money") = ply:SetPData("money") - 800)
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/CODE]
when I type giverpg in console nothing happens[/QUOTE]
In this line:[CODE]if (ply:GetPData("Money") > 800) then[/CODE]
You have money capitalized.
[code]
function giverpg( ply, comand, args)
if (ply:GetPData("money") > 800) then
ply:SetPData("money", ply:GetPData("money") - 800 )
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/code]
goddangit why is everyone getting this wrong
[code]
function giverpg( ply, command, args)
if ply:GetPData("money") > 800 then
ply:SetPData("money", ply:GetPData("money") - 800 )
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )
[/code]
All the code posted so far is not providing a default value as the second parameter to GetPData.
[lua]local function giverpg( ply, command, args)
local money = ply:GetPData("money", 0)
if money >= 800 then
ply:SetPData("money", money - 800 )
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/lua]
And of course make sure this is running serverside.
[QUOTE=wh1t3rabbit;43465869]All the code posted so far is not providing a default value as the second parameter to GetPData.
[lua]local function giverpg( ply, command, args)
local money = ply:GetPData("money", 0)
if money >= 800 then
ply:SetPData("money", money - 800 )
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/lua]
And of course make sure this is running serverside.[/QUOTE]
setting the money to zero defeats the whole purpose of having it. Earlier in the code, on initial spawn, I already did this
[QUOTE=BOT Faggot;43466188]setting the money to zero defeats the whole purpose of having it. Earlier in the code, on initial spawn, I already did this[/QUOTE]
It never does it, ply:GetPData("money", 0) returns money or if there are no money, it returns 0 instead of nil.
[QUOTE=wh1t3rabbit;43465869]All the code posted so far is not providing a default value as the second parameter to GetPData.
[lua]local function giverpg( ply, command, args)
local money = ply:GetPData("money", 0)
if money >= 800 then
ply:SetPData("money", money - 800 )
ply:Give("weapon_rpg")
end
end
concommand.Add( "giverpg", giverpg )[/lua]
And of course make sure this is running serverside.[/QUOTE]
[B]THANK YOU. [/B]
Finally someone posted what I wanted to see.
Sorry, you need to Log In to post a reply to this thread.