xXMADEXx Posted December 18, 2012 Share 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) Link to comment
Castillo Posted December 18, 2012 Share Posted December 18, 2012 Simple add: if ( tonumber ( amount ) < 0 ) then return end Before: if (getPlayerMoney(thePlayer) >= amount) then Link to comment
xXMADEXx Posted December 18, 2012 Author Share Posted December 18, 2012 Simple add: if ( tonumber ( amount ) < 0 ) then return end Before: if (getPlayerMoney(thePlayer) >= amount) then Humm... Command will not work Link to comment
xXMADEXx Posted December 18, 2012 Author Share 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) Link to comment
Vision Posted December 18, 2012 Share 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) Link to comment
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