I am trying to create a addon that maxes the hp you can set at 250 but when I use this it says it's a string, how do I turn it into a integer format?
if SERVER then
hook.Add( "PlayerSay", "CommandIdent", function( ply, text, team )
if( string.sub( text, 1, 3 ) == "/hp" ) then
if string.sub( text, 4 ) < 250 then
if ply:canAfford(200) then
ply:addMoney( -200 )
ply:SetHealth(string.sub( text, 4 ))
DarkRP.notify(ply, 1, 4, "Deducted 200$")
else
DarkRP.notify(ply, 1, 4, "You don't have enough money!")
end
else
DarkRP.notify(ply, 1, 4, "Use a value between 1 and 250!")
end
end
end)
end
Turn your string into a number using tonumber
so like this?
tonumber(string.sub(text, 1, 5))
No, you just add a tonumber call to the string.sub call inside of ply:SetHealth.
string.sub(tonumber(text), 1, 5)
No.
ply:SetHealth(tonumber(string.sub(text, 5))
I get that, I didn't read all of his code. I was just replying to his comment, and unfortunately I was uneducated about the entire post due to my choice of not reading it.
Is there a way to set a thread as completed on the new design?
Not yet.
oh
Sorry, you need to Log In to post a reply to this thread.