Jump to content

start a resource in a defined time


Recommended Posts

It works getTickCount or setTimer ?

really i want a timer showing like: in 4:00:00 hours it will start the resource zombies and when it reaches to 0:00:00 start

some like:

    function iniciar 
    startResource ( zombies ) 
        outputChatBox ("La horda de zombies ha comenzado!") 
    end 
    setTimer (iniciar,576000000,1) -- 576000000 = 4 real hours 
     
    function detener 
    stopResource ( zombies ) 
       outputChatBox ("La horda se ha detenido!") 
    end 
    setTimer (detener,144000000,1) -- 144000000 = 1 real hour 

but with a counter showing up like this:

gtasa2012052123441175.png

http://img152.imageshack.us/img152/8029/gtasa2012052123441175.png

Link to comment

you should use

  
getResourceFromName 

instead of variable zombies and check resource (loaded/running).

  
local pZombieResource = getResourceFromName 'zombies' 
  
setTimer( 
    function( ) 
        local nHour = getTime( ) -- get hour 
        if nHour == 0 then 
            if getResourceState( pZombieResource ) == 'loaded' then -- check 
                startResource( pZombieResource ) -- start resource 
                outputChatBox 'La horda de zombies ha comenzado!' 
            end 
        elseif nHour == 4 then 
            if getResourceState( pZombieResource ) == 'running' then -- check 
                stopResource( pZombieResource ) -- stop resource 
                outputChatBox 'La horda se ha detenido!' 
            end 
        end 
    end, 
1000, 
0 ) 

Don't forget add rights for this resource.

Link to comment
local pZombieResource = getResourceFromName 'zombies' 
  
setTimer( 
    function( ) 
        local nHour = getTime( ) -- get hour 
        if (nHour >= 0 and nHour <= 4) then 
            if getResourceState( pZombieResource ) == 'loaded' then -- check 
                startResource( pZombieResource ) -- start resource 
                outputChatBox 'La horda de zombies ha comenzado!' 
            end 
        elseif nHour >= 4 then 
            if getResourceState( pZombieResource ) == 'running' then -- check 
                stopResource( pZombieResource ) -- stop resource 
                outputChatBox 'La horda se ha detenido!' 
            end 
        end 
    end, 
1000, 
0 ) 

- Try it. Is the Kenix example, but I modified the nHour condition.

- I don't know if is it what you want, but between 0:00 and 4:00am, the zombie resource will be started.

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