Jump to content

eventHandlers in multiple scripts


'LinKin

Recommended Posts

They are triggered while resource starts.

You misunderstood.

@OP: They are all triggered at once. triggers are global for all running resources, but events are only callable from outside current resource/script if the variable that checks this is set. [ addEventHandler("random", true) ]

keep in mind that server>client and viceversa have some delay. (They are still globally triggered, just from one to the other side.)

Link to comment

I have a kills script for DD, It works using setElementData, so, in the stats script, I have: the event onPlayerFinishDD,

Then I read the killer by getting the elementData of the source, and then at the end I set it to nil (to clear the kill).

And on another script I have the same onPlayerFinishDD event, and I'm trying to get the killer of the source by getting it's elementData, but it's always returning nil. hm.

I had to merge both scripts for it to work.

Link to comment
I have a kills script for DD, It works using setElementData, so, in the stats script, I have: the event onPlayerFinishDD,

Then I read the killer by getting the elementData of the source, and then at the end I set it to nil (to clear the kill).

And on another script I have the same onPlayerFinishDD event, and I'm trying to get the killer of the source by getting it's elementData, but it's always returning nil. hm.

I had to merge both scripts for it to work.

Pretty sure you're destroying the value itself, remind that althought they are triggered all at once they are the same event and are asynchronious. If the nil part was to be before the second part then it was likely to return so.

Link to comment
  • Moderators

I would suggest. (how I created it)

When you hit somebody, you trigger a server event.

You put a delay between them, like 200 ms per update. -- to save a lot of data transfer.

If you use elementdata, you will be using more depending on the player count in the server and you will be constantly using the network.

The next step, which you are asking for in this post.

- Start exporting your data from resource to resource. (which I do recommend, because of the clean way of doing)

- You can also use triggerEvent, like MrBrutus said. But that one uses a lot of memory even it isn't a bad idea.

- Also you use setElementData without synchronisation, which will not use and bandwidth. (but it also creates trash, you have to delete it when you stop the resource)

That are your options.

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