Kevin_Linden Posted March 4, 2010 Share Posted March 4, 2010 givePlayerMoney (person, math.abs(tonumber(amount))) It workd before i did checks but i died like a million times when my friends and random people got on my server and killed me. So then i lost tons of money for hospital bills. So i had -$0011890 then someone pays me 5$ , I then have -$0011895 when i should of had -$0011885. Not sure how to prevent that. So right now the code does not work and if it did it would allow people who are negative to keep going negative with they get paid positive. function pay(Player, command, who, amount) local person = getPlayerFromName ( who ) local playerMoney = getPlayerMoney (Player) if ( playerMoney >= tonumber (amount)) and (tonumber (amount) > 0) then givePlayerMoney (person, math.abs(tonumber(amount))) takePlayerMoney (Player, math.abs(tonumber(amount))) outputChatBox ( tostring (amount) .. "$ has been paid to " .. who, Player, 255, 0, 0, false) else outputChatBox ("You cannot pay more money than you have!", Player, 255, 0, 0, false) end addCommandHandler ("pay", pay) Also does MTA care about upper and lowercase on a Linux server? Link to comment
50p Posted March 4, 2010 Share Posted March 4, 2010 You are missing an end before addCommandHandler. Link to comment
Kevin_Linden Posted March 4, 2010 Author Share Posted March 4, 2010 Okay. How can i fix it so if i had -1000 and i get paid $5 i then have -1005 but i should have -995? Link to comment
CTCCoco Posted March 4, 2010 Share Posted March 4, 2010 Okay. How can i fix it so if i had -1000 and i get paid $5 i then have -1005 but i should have -995? Show me your givePlayerMoney (person, math.abs(tonumber(amount))) script please. Link to comment
Kevin_Linden Posted March 4, 2010 Author Share Posted March 4, 2010 There is the script. function pay(Player, command, who, amount) local person = getPlayerFromName ( who ) local playerMoney = getPlayerMoney (Player) if ( playerMoney >= tonumber (amount)) and (tonumber (amount) > 0) then givePlayerMoney (person, math.abs(tonumber(amount))) takePlayerMoney (Player, math.abs(tonumber(amount))) outputChatBox ( tostring (amount) .. "$ has been paid to " .. who, Player, 255, 0, 0, false) else outputChatBox ("You cannot pay more money than you have!", Player, 255, 0, 0, false) end end addCommandHandler ("pay", pay) Link to comment
karlis Posted March 7, 2010 Share Posted March 7, 2010 i think he emans that math.abs is unneded, what was the reason you puted it there? btw heres fix: function pay(Player, command, who, amount) local person = getPlayerFromName ( who ) local playerMoney = getPlayerMoney (Player) if ( playerMoney >= tonumber (amount)) and (tonumber (amount) > 0) then if getPlayerMoney (Player) >= 0 then givePlayerMoney (person, tonumber(amount)) else takePlayerMoney (person, tonumber(amount)) end takePlayerMoney (Player, tonumber(amount)) outputChatBox ( tostring (amount) .. "$ has been paid to " .. who, Player, 255, 0, 0, false) else outputChatBox ("You cannot pay more money than you have!", Player, 255, 0, 0, false) end end addCommandHandler ("pay", pay) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now