Jump to content

triggerClientEvent is heard in two different scripts


'LinKin

Recommended Posts

Hello,

I've a clientside event called openGUI inside Resource1

Then, I made Resource2, and I added a clientside event with the same name (openGUI)

Then, when I trigger the event from Resource2, it opens the GUI of Resource2 BUT ALSO the GUI of Resource1.

How can I avoid this?

Link to comment

I recall the allowRemoteTrigger parameter for addEvent was designed to avoid these type of situations. Set it to false and see if it works.

If it doesn't work, the best way to avoid double-events is to name them after the resource such as Resource1:theEventName.

Link to comment
I recall the allowRemoteTrigger parameter for addEvent was designed to avoid these type of situations. Set it to false and see if it works.

If it doesn't work, the best way to avoid double-events is to name them after the resource such as Resource1:theEventName.

This

or if possible for you, attach the event to resourceRoot instead of root and trigger using resourceRoot, then it will only trigger for the same resource.

Link to comment
  • Moderators
I recall the allowRemoteTrigger parameter for addEvent was designed to avoid these type of situations.

No, it's just telling if the event can be triggered from the other side. So nothing to do with resources.

So as final solution I got this:

Client side: addEventHandler("openGUI", resourceRoot, openGUI)

Server side: triggerClientEvent(thePlayer, "openGUI", resourceRoot)

Yeah exactly. You couldn't use triggerClientEvent(thePlayer, "openGUI", thePlayer) because players are not in the resource tree, but the root tree.

(I saw you asked it before you edit your post ^^)

Watch the schema here to get a visual idea of the element tree system:

https://wiki.multitheftauto.com/wiki/Element_tree

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