Jump to content

1 minute timer


FSXTim

Recommended Posts

Hello,

I have a question. This script ir working perfectly, but how can I make that the player can only do that one time in 60 seconds?

If the player already used the function for example 30 seconds ago, the ChatBox says "You can only use this function one time in 60 seconds! You have to wait "..xx.." seconds!"

function bombe10_Button (state) 
    if state == "left" then 
        if source == GUIEditor_Button[12] then 
            local vehicle = getPedOccupiedVehicle (getLocalPlayer())  
            local x,y,z = getElementPosition (getLocalPlayer())      
            triggerServerEvent ( "Feuerwerk", root )                 
        end 
    end 
end  
addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) 
  

Please help me.

Greets

Link to comment

Try this one:

function bombe10_Button (state) 
    local me = getLocalPlayer() 
    if tonumber(getElementData(me,"FeuerwerkTrigger")) > getTickCount() then 
        local second = (tonumber(getElementData(me,"FeuerwerkTrigger")) - getTickCount()) / 1000 
        outputChatBox("You can only use this function one time in 60 seconds! You have to wait "..second.." seconds!")  
        return 
    end 
    removeElementData(me,"FeuerwerkTrigger") 
    if state == "left" then 
        if source == GUIEditor_Button[12] then 
            local vehicle = getPedOccupiedVehicle (getLocalPlayer()) 
            local x,y,z = getElementPosition (getLocalPlayer())     
            triggerServerEvent ( "Feuerwerk", root )  
            setElementData(me,"FeuerwerkTrigger",getTickCount()+60000) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) 
  

Link to comment
function bombe10_Button ( state ) 
    if ( state == "left" ) then 
        if ( source == GUIEditor_Button[12] ) then 
            if ( isTimer ( coldDownTimer ) ) then 
                outputChatBox ( "You can use it again on ".. math.floor ( getTimerDetails ( coldDownTimer ) / 1000 ) .." seconds." ) 
            else 
                coldDownTimer = setTimer ( function ( ) end, 60000, 1 ) 
                triggerServerEvent ( "Feuerwerk", localPlayer ) 
            end 
        end 
    end 
end 
addEventHandler ( "onClientGUIClick", getRootElement(), bombe10_Button ) 

Link to comment

One thing:

I want to trigger this clientside script:

function tampa1_Button (state) 
    if state == "left" then 
        if source == GUIEditor_Button[3] then    
            if ( isTimer ( coldDownTimer5 ) ) then   
                outputChatBox ( "Du kannst Dein Auto erst wieder in ".. math.floor ( getTimerDetails ( coldDownTimer5 ) / 1000 ) .." Sekunden in eine Stretch verwandeln!", 255, 48, 48 ) 
            else         
                coldDownTimer5 = setTimer ( function ( ) end, 120000, 1 )            
                local lp = getLocalPlayer()  
                local vehicle = getPedOccupiedVehicle (getLocalPlayer())     
                outputChatBox ( "Dein Auto wurde in eine Stretch verwandelt!", 65, 105, 225 ) 
                triggerServerEvent ( "Stretch", lp )                 
            end 
        end 
    end 
end  
addEventHandler("onClientGUIClick", getRootElement(), tampa1_Button) 
addCommandHandler ("tampa", getRootElement(), tampa1_Button) 

So I did it like this:

function Stretch () 
    local vehicle = getPedOccupiedVehicle ( thePlayer)  
    setElementModel ( vehicle, 409 ) 
end 
addEvent ( "Stretch", true ) 
addEventHandler ( "Stretch", getRootElement(), Stretch ) 

Errors:

Line 2: Bad argument @ 'getPedOccupiedVehicle'

Line 3: Bad argument @ 'setElementModel'

I want to trigger it, because when I set the 'setElementModel' function clientside, than only the player, who perform the function, will see his car as a Stretch.

Greets

Link to comment

@Solidsnake14

Thanks, that's working now.

You're very good and you help me everytime, so I have to say thanks for all.

And I have a question: How long are you scripting now? 2 years, or 3?

There is also one thing. I have problems with my database, and I want to pay you, if you would help me. It's a big problem and we don't need 5 minutes to fix it, I think it would take an hour or more. So if you want to earn some money, just tell me!

Greets

Link to comment

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...