Jump to content

[RESOLVED]My "world" is loading twice! (onResourceStart)


Oscuro87

Recommended Posts

Hi, it's me again! (oh noes! :P)

Ok i'll briefly describe my problem :

My world is loading twice when I use "onResourceStart" to setup all the stuff.

Here is how I setup vehicles for example :

  
function setupAllVehicles() 
        [Here is the stuff to spawn vehicles, all that] 
end 
addEventHandler("onResourceStart", root, setupAllVehicles) 
  

I already checked several possibilities, including : me spawning the cars twice, but nope, I don't do that.

IMPORTANT NOTE :

This only happens when I first start the server (aka, when i double click on the MTA server icon to run it.)

When i restart my resource ("restart oscuromode" in console), it DOES NOT load twice.

Edited by Guest
Link to comment
Guest Guest4401

Simply change

addEventHandler("onResourceStart", root, setupAllVehicles) 

to

addEventHandler("onResourceStart", resourceRoot, setupAllVehicles) 

If you attach this event to the root element it will called when any resource starts, not just the resource your script is running inside. As such, most of the time you will want to check that the resource passed to this event matches your resource (compare with the value returned by getThisResource) before doing anything. Alternatively you can attach the event to getResourceRootElement(getThisResource())
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...