Castillo Posted June 23, 2010 Share Posted June 23, 2010 hey there, i got a problem in my send money function, all works fine but when i send to someone -2222 or -9999 it gives to me that money also, here is my code. function ( playerNick, amount ) local cash = getPlayerMoney(source) if (cash > tonumber(amount)) then toWho = getPlayerFromName(playerNick) if (toWho ~= false) then givePlayerMoney(toWho,amount) name = getPlayerName(source) takePlayerMoney(source,amount) outputChatBox("You've given money amount of: " .. amount .. "$ to: " .. playerNick,source,255,255,150) outputChatBox(name .. " has given you money amount of: " .. amount .. "$!",toWho,255,255,245) else outputChatBox("Player did not exist",source,255,0,0) end else outputChatBox("Insufficient founds!",source,255,0,0) end end) btw, i have the GUI part in client side where i trigger user and amount Link to comment
dzek (varez) Posted June 23, 2010 Share Posted June 23, 2010 just check (can be client side) if somebody put in edit field a negative value - if yes - dont send it.. function (playerNick, amount) local cash = getPlayerMoney(source) if (tonumber(amount)>0) then if (cash>=tonumber(amount)) then toWho = getPlayerFromName(playerNick) if (toWho ~= false) then givePlayerMoney(toWho,amount) takePlayerMoney(source,amount) name = getPlayerName(source) outputChatBox("You've given money amount of: " .. amount .. "$ to: " .. playerNick,source,255,255,150) outputChatBox(name .. " has given you money amount of: " .. amount .. "$!",toWho,255,255,245) else outputChatBox("Player did not exist",source,255,0,0) end else outputChatBox("Insufficient founds!",source,255,0,0) end else outputChatBox("Amount have to be greater than 0!",source,255,0,0) end end) btw: use indentations! they really help! Link to comment
kevin11 Posted June 23, 2010 Share Posted June 23, 2010 has this anything to do with userpanel?? because it works for me -999 isnt working 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