Jump to content

on espesific resource start do something


mrvicio

Recommended Posts

what abuout this ?

function restartAllResources() 
    -- we store a table of resources 
    local allResources = getResources() 
    -- for each one of them, 
    for index, res in ipairs(allResources) do 
        -- if it's running, 
        if getResourceState(res) == "running" then 
            -- then restart it 
            restartResource(res) 
        end 
    end 
end 

Link to comment

Thanks! John_Michael I had not thought of only add the colum calling the scoreboard, is has improve efficiency,

now only left the element that i must attach to the handler :P

remeber, the element below dont work

getResourceRootElement(getResourceFromName("scoreboard")-- <<<---Dont work 

it dont get launched

Link to comment

let me explain better

Event handlers have 3 variables

addEventHandler(var1,var2,var3) ok?

var1 is the name of the event

var3, YES VAR3! is the name of the function to execute when the event is triggered

and

var2, is the element that the eventHandler must be attached, and the event only will trigger the fuction when the event occurs on the element attached, in this case "var2", or childs of var2(attachedElement).

im just looking the element that i must attach to my EventHandler

in this case var3, but in My case, something related to the elementResourceScoreboard

because lot of peoples recomend me to use the element "getResourceRootElement(getResourceFromName("scoreboard"))" i tried the line below

addEventHandler("onResourceStart",getResourceRootElement(getResourceFromName("scoreboard")),nameOfMyFunction) 

but it dont work, because of that, i said that the element

"getResourceRootElement(getResourceFromName("scoreboard"))" 

dont work in my EventHandler :P

any doubt? xD

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