Jump to content

send money bug


Castillo

Recommended Posts

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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!

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

Thanks it worked :D

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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...