xXMADEXx Posted December 18, 2012 Posted December 18, 2012 I have this command ( /give and /pay ) but i dont know how to make it so that the player sending money haves to have the amount of money that there sending. Like, i dont want sender want to be able to go in negative money. function givecash(thePlayer, command, who, amount) local noobwiegeldkrijgt = getPlayerFromName ( who ) local noobdiegeldgeeft = getPlayerFromName ( thePlayer ) if (getPlayerMoney(thePlayer) >= amount) then givePlayerMoney (noobwiegeldkrijgt, math.abs(tonumber(amount))) takePlayerMoney (thePlayer, math.abs(tonumber(amount))) else outputChatBox("Sorry, You Do Not Have That Much Money To Give.", thePlayer, 255, 0, 0 ) end end addCommandHandler ("give", givecash) addCommandHandler ("pay", givecash) The Ultimate Lua Tutorial! | MTA PHP SDK
Castillo Posted December 18, 2012 Posted December 18, 2012 Simple add: if ( tonumber ( amount ) < 0 ) then return end Before: if (getPlayerMoney(thePlayer) >= amount) then San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
xXMADEXx Posted December 18, 2012 Author Posted December 18, 2012 Simple add: if ( tonumber ( amount ) < 0 ) then return end Before: if (getPlayerMoney(thePlayer) >= amount) then Humm... Command will not work The Ultimate Lua Tutorial! | MTA PHP SDK
Castillo Posted December 18, 2012 Posted December 18, 2012 Post the script. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
xXMADEXx Posted December 18, 2012 Author Posted December 18, 2012 Post the script.function givecash(thePlayer, command, who, amount) local noobwiegeldkrijgt = getPlayerFromName ( who ) local noobdiegeldgeeft = getPlayerFromName ( thePlayer ) if ( tonumber ( amount ) < 0 ) then return end if (getPlayerMoney(thePlayer) >= amount) then givePlayerMoney (noobwiegeldkrijgt, math.abs(tonumber(amount))) takePlayerMoney (thePlayer, math.abs(tonumber(amount))) else outputChatBox("Sorry, You Do Not Have That Much Money To Give.", thePlayer, 255, 0, 0 ) end end addCommandHandler ("give", givecash) The Ultimate Lua Tutorial! | MTA PHP SDK
Vision Posted December 18, 2012 Posted December 18, 2012 function givecash(thePlayer, command, who, amount) local noobwiegeldkrijgt = getPlayerFromName ( who ) local noobdiegeldgeeft = getPlayerName ( thePlayer ) if ( tonumber ( amount ) < 0 ) then return end if (getPlayerMoney(thePlayer) >= tonumber(amount)) then givePlayerMoney (noobwiegeldkrijgt, math.abs(tonumber(amount))) takePlayerMoney (thePlayer, math.abs(tonumber(amount))) else outputChatBox("Sorry, You Do Not Have That Much Money To Give.", thePlayer, 255, 0, 0 ) end end addCommandHandler ("give", givecash)
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