Jump to content

send money bug


Castillo

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...