Jump to content

send money bug


top sniper

Recommended Posts

hi ..

there is a problem with share money code ..

the problem is some players take money from anther players by sending to them -(amount)

this is the code

addEvent("sendMoney", true) 
addEventHandler("sendMoney", getRootElement(), 
function ( playerNick, amount ) 
local cash = getPlayerMoney(source) 
if (cash > tonumber">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) 

Link to comment

addEvent("sendMoney", true) 
addEventHandler("sendMoney", getRootElement(), 
function ( playerNick, amount ) 
local cash = getPlayerMoney(source) 
if (cash > tonumber(amount)) and tonumber(amount) > 0 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) 

Try this

Link to comment
addEvent( 'sendMoney', true) 
addEventHandler( 'sendMoney', root, 
    function ( sNick, nAmmount ) 
        if sNick and nAmmount then 
            local nAmmount = tonumber( nAmmount ) 
            local nMoney = getPlayerMoney( source ) 
            if cash >= nAmmount then 
                local uPlayer = getPlayerFromName( sNick ) 
                if uPlayer then 
                    givePlayerMoney( uPlayer, nAmmount ) 
                    takePlayerMoney( source, nAmmount ) 
                    outputChatBox(  
                        string.format(  
                            'You\'ve given money amount of: %s $ to: %s',  
                            nAmmount, 
                            sNick 
                        ), 
                        source, 
                        255, 
                        255, 
                        150 
                    ) 
                    outputChatBox(  
                        string.format(  
                            '%s has given you money amount of: %s $!',  
                            getPlayerName( source ), 
                            nAmmount 
                        ), 
                        uPlayer, 
                        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( 'DEBUG: sNick and nAmmount arguments nil or false', source, 255, 0, 0 ) 
        end 
    end 
) 

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