top sniper Posted March 15, 2012 Posted March 15, 2012 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)
mjau Posted March 15, 2012 Posted March 15, 2012 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
Kenix Posted March 15, 2012 Posted March 15, 2012 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 )
Scooby Posted March 15, 2012 Posted March 15, 2012 not sure which you used, but make sure u have a check for: if tonumber(amount) > 0 then in it or people will be able to use the function to take money from other players.
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