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 )