Jump to content

guiRoot


'LinKin

Recommended Posts

Hello,

I've an event like this:

addEventHandler("onClientGUIChanged", guiRoot, doStuff)

So it's attached to all gui elements,

but also, if I wanted to make this event called ONLY from the resource where it's running, would I have to change guiRoot to resourceRoot?

Thanks.

Link to comment

Good, thank you.

I'll use this topic to ask something else.

What happens when we have "global" events such as onPlayerChat or onRaceStateChanging attached to resourceRoot?

I've tested and attaching onRaceStateChanging to resourceRoot works,

But not for onPlayerChat. This event must be attached to root.

But hm, I think I have a better understanding now. In short, use resourceRoot when you're working with events made by yourself

Link to comment

Hmm.

How to check if the source that triggers the event is different from the resource where it's added?

I've 2 scripts, they're both the same but with different name.

Client-side:

In #1 I have: triggerServerEvent("test", localPlayer)

In #2 I have: triggerServerEvent("test", resourceRoot)

Server-side:

In #1: addEventHandler("test", root, function)

In #2: addEventHandler("test", resourceRoot, function)´

-- When I trigger the event from #1 the #2 doesn't listen to it.

-- When I trigger the event from #2 the #1 AND the #2 listen to it.. So executes the function attached to the event twice. Having duplicated stuff.

In #2, inside the event's attached function I wrote outputChatBox(getElementType(getElementParent(source))) and it output 'root'. But why?

How can I make it so that if the source is NOT the same resource where it's located, it returns the function?

if source ~= getThisResource() then return end 

Didn't work, because source is 'root'..

EDIT:

This is what I was looking for (https://wiki.multitheftauto.com/wiki/Script_security).

Now it's like this:

if source ~= resourceRoot then return end 

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