BieHDC Posted July 15, 2013 Posted July 15, 2013 Hello, i have an epic bug in the following code, if you spin for a negative ammount of money and loose you get money. but i cant find out how to fix, so please hel me thanks function Spin_Func(thePlayer, cmd, amount) local winchance = math.random(1,3) local spintimer = getElementData(thePlayer,"spintimer") local money = getPlayerMoney(thePlayer) if spintimer == false then if (money >= tonumber(amount)) then if winchance == 1 or winnchance == 3 then outputChatBox("#ffffff"..getPlayerName(thePlayer).." spinned for "..amount.." and lost.", getRootElement(),0,0,0,true) takePlayerMoney(thePlayer,amount) setElementData(thePlayer,"spintimer", true) setTimer( function () setElementData(thePlayer,"spintimer", false) end, 30000,1) elseif winchance == 2 then outputChatBox("#ffffff"..getPlayerName(thePlayer).." spinned for "..amount.."$ and won ".. amount*2 .."$.", getRootElement(),0,0,0,true) givePlayerMoney(thePlayer, amount) setElementData(thePlayer,"spintimer", true) setTimer( function () setElementData(thePlayer,"spintimer", false) end, 30000,1) end else outputChatBox("You don't have enough money!", thePlayer, 255,0,0) end else outputChatBox("You can spin only all 30 Seconds.",thePlayer, 255,0,0) end end addCommandHandler("spin", Spin_Func)
Castillo Posted July 15, 2013 Posted July 15, 2013 Check if the amount is higher than 0. if ( amount > 0 ) then return outputChatBox ( "Invalid amount.", thePlayer, 255, 0, 0 ) end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
BieHDC Posted July 15, 2013 Author Posted July 15, 2013 can you please tell me where to put in this code?
Castillo Posted July 15, 2013 Posted July 15, 2013 function Spin_Func ( thePlayer, cmd, amount ) local winchance = math.random ( 1, 3 ) local spintimer = getElementData ( thePlayer, "spintimer" ) local money = getPlayerMoney ( thePlayer ) local amount = tonumber ( amount ) or 0 if ( amount < 1 ) then outputChatBox ( "Invalid amount.", thePlayer, 255, 0, 0 ) return end if ( spintimer == false ) then if ( money >= amount ) then if ( winchance == 1 or winnchance == 3 ) then outputChatBox ( "#ffffff"..getPlayerName ( thePlayer ) .." spinned for ".. amount .." and lost.", root, 0, 0, 0, true ) takePlayerMoney ( thePlayer, amount ) setElementData ( thePlayer, "spintimer", true ) setTimer ( function ( ) setElementData ( thePlayer, "spintimer", false ) end ,30000, 1 ) elseif ( winchance == 2 ) then outputChatBox ( "#ffffff".. getPlayerName ( thePlayer ) .." spinned for ".. amount .."$ and won ".. ( amount * 2 ) .."$.", root, 0, 0, 0, true ) givePlayerMoney ( thePlayer, amount ) setElementData ( thePlayer, "spintimer", true ) setTimer ( function ( ) setElementData ( thePlayer, "spintimer", false ) end ,30000, 1 ) end else outputChatBox ( "You don't have enough money!", thePlayer, 255, 0, 0 ) end else outputChatBox ( "You can spin only all 30 Seconds.", thePlayer, 255, 0, 0 ) end end addCommandHandler ( "spin", Spin_Func ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
BieHDC Posted July 15, 2013 Author Posted July 15, 2013 dont work, it shouldnt be possible to spin a negative ammount of money but i can do spin -999999 and loose and then i get 999999 money it should chech if amount is over 0 and not if money of player is over 0
Castillo Posted July 15, 2013 Posted July 15, 2013 You must have copied it wrong, it has to work. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted July 15, 2013 Posted July 15, 2013 Copy it again, now it works ( tested ). San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
BieHDC Posted July 15, 2013 Author Posted July 15, 2013 ok works now thank you can i pay you for some script? but its a BIG work
Castillo Posted July 15, 2013 Posted July 15, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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