Jump to content

Help


Recommended Posts

Posted
local trueNumber = 0 
local price = 0 
  
addCommandHandler("spin",  
    function(theplayer, command, number, amount) 
        number = tonumber(number) 
        amount = tonumber(amount) 
        if (number > 0) then  
            if (amount >= 1000 and amount <= 1000000) then 
                outputChatBox("#999999Your spin #ff5500("..number..") #999999is on the Wheel...", theplayer,255,255,255,true) 
                trueNumber = math.random(1,65) 
                outputChatBox(trueNumber) 
                setTimer(checkspin,7000,1,number,trueNumber, amount, theplayer) 
                spin = false 
                setTime( 
                    function() 
                        spin = true 
                    end, 20000,1) 
            else 
                outputChatBox("Minimum spin amount is '1000' to '1000000'.", theplayer,255,0,0,true) 
            end 
        else 
            outputChatBox("Minimum spin number is '1' to '65'.", theplayer,255,0,0,true) 
        end 
    end 
) 
function checkspin(oldnumber, newnumber, amount, theplayer) 
    if (oldnumber == newnumber) then 
        price = amount * 100 
        outputChatBox("#0088ff"..getPlayerName(theplayer).." Spins #ff8800("..oldnumber..")#0088ff and wins #ff8800($"..price..")#0088ff!",getRootElement(),255,255,255,true) 
    else 
        outputChatBox("#0088ff"..getPlayerName(theplayer).." Spins #ff8800("..oldnumber..")#0088ff and loses.",getRootElement(),255,255,255,true) 
    end 
end 

This is my spin system it's not finished yet but i need help

i want to make that when the player execute the command /spin, i want him not to be able to spin again if a 20 sec. didn't passed.

how would i do that?

Posted

You can use tables and getTickCount, you need to store the current tick count when the player spins, then when he tries to spin again, it'll check if the time has passed.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

you can use it

function Spins() 
  
if spam then 
            outputChatBox('Wait 20 the 2nd',root,255,0,0,true) 
       return  
end 
                    outputChatBox('Your spin ..',root,255,255,255,true) 
         spam = true 
             setTimer(function() Spins = {} spam = false end ,20000,1) 
end 
addCommandHandler("spin", Spins) 
  

Team, MTA Scripters.

Posted

Timers aren't efficient.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Timers are laggy.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

there is another problem :(

i can't get the current player's money... i don't know why but it returns a false value!!

i use this :

  
local money = 0 
  
addCommandHandler("spin",  
    function(theplayer, command, number, amount) 
        money = getPlayerMoney(theplayer) 
        outputChatBox(money) 
    end) 
  

Posted

Show 'meta.xml' file.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

Where is the info line ..?

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted
Where is the info line ..?

lol the info line is not required in fact i won't waste my time filling up a stupid information that i won't need (-_-)

so is there any solution for the get money function?

Posted
The info line is not needed
the info line is not required in fact ...

Sorry, I didn't know that ..

:roll:

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted
Like this?

-- Server --

addCommandHandler("spin", function (thePlayer) 
money = getPlayerMoney(thePlayer) 
outputChatBox(" "..money.." ") end) 

Yes but it's not working for me i don't know why it output on chat "false"!

  
local trueNumber = 0 
local price = 0 
local money = 0 
  
addCommandHandler("spin",  
    function(theplayer, command, number, amount) 
        number = tonumber(number) 
        amount = tonumber(amount) 
        money = getPlayerMoney(thePlayer) 
         
        if (number > 0) then  
            if (amount >= 1000 and amount <= 1000000) then 
                outputChatBox("#999999Your spin #ff5500("..number..") #999999is on the Wheel...", theplayer,255,255,255,true) 
                trueNumber = math.random(1,65) 
                outputChatBox(money, theplayer,255,255,255,true) -- Returns FALSE !! 
                setTimer(checkspin,10000,1,number,trueNumber, amount, theplayer) 
            else 
                outputChatBox("Minimum spin amount is '1000' to '1000000'.", theplayer,255,0,0,true) 
            end 
        else 
            outputChatBox("Minimum spin number is '1' to '65'.", theplayer,255,0,0,true) 
        end 
    end 
) 
function checkspin(oldnumber, newnumber, amount, theplayer) 
    if (oldnumber == newnumber) then 
        price = amount * 100 
        outputChatBox("#0088ff"..getPlayerName(theplayer).." Spins #ff8800("..oldnumber..")#0088ff and wins #ff8800($"..price..")#0088ff!",getRootElement(),255,255,255,true) 
    else 
        outputChatBox("#0088ff"..getPlayerName(theplayer).." Spins #ff8800("..newnumber..")#0088ff and loses.",getRootElement(),255,255,255,true) 
    end 
end 
  

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...