Jump to content

automatically restart


Estevam2d

Recommended Posts

Posted
function restartAllResources() 
    local allResources = getResources() 
    for index, res in ipairs(allResources) do 
        if getResourceState(res) == "JOBpl" then 
            restartResource(res) 
        end 
    end 
end 
addCommandHandler( "pl", restartAllResources ) 

how can I put a time to start and stop automatically activated without charge?

I think this script is wrong.

Posted

Use a timer.

setTimer 

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 want to restart only the resource "JOBpl"?

function restartRes ( ) 
    local res = getResourceFromName ( "JOBpl" ) 
    if ( res ) then 
        restartResource ( res ) 
    end 
end 
setTimer ( restartRes, 60000, 0 ) 

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

Try this:

setTimer(function () 
    local allResources = getResources() 
    for index, res in ipairs(allResources) do 
        if getResourceState(res) == "JOBpl" then 
            restartResource(res) 
        end 
    end 
    end,60000,0) 

It will restart the resources after one minute.

It's fine to celebrate success but it is more important to heed the lessons of failure.

Posted

"JOBpl" is not a valid resource state.

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

Have you tried my code?

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

My code will restart the resource "JOBpl" if exists every minute.

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're welcome.

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 want only vehicle created from JOBpl to be destroyed?

You can use getResourceRootElement.

addEventHandler("onVehicleExplode", getResourceRootElement(getResourceFromName("JOBpl")), 
function() 
    destroyElement(source) 
end) 

CiTLh.png

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