Jump to content

[SOLVED] startResource


rain_gloom

Recommended Posts

I'm not sure if this is intended behavior or just me messing things up. I have a resource that stops any resource being started, does a few modifications on it then starts it again, but the new resource does not actually start.

All I see in the server log is:

start: Resource "test" start was requested () 

here is the relevant code:

local startSet = {} 
  
local function procd ( resource ) 
    if startSet [ resource ] then 
        startSet [ resource ] = nil 
    else 
        cancelEvent () 
        processResource ( resource.name ) 
        startSet [ resource ] = true 
        startResource ( resource ) 
    end 
end 
addEventHandler ( 'onResourcePreStart', root, procd ) 

If I manually start it after that message, it works as expected and the processing is not run.

Edited by Guest
Link to comment
  • Moderators

Maybe the new modified resource now contains errors that prevents it to start, or maybe you should delay the start of the modified resource to let the onResourcePreStart and the cancelEvent finish what they are supposed to do.

I would go for a setTimer of 500ms or 1sec to call the startResource (don't forget to send the resource as an argument with the setTimer).

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