Jump to content

[Question] How to trigger other resources' events?


Kazafka

Recommended Posts

  • Scripting Moderators
1 hour ago, VaporZ said:

I don't know how Can I do it, so please, give me an example. Or maybe it is like this?


triggerEvent(".res_name:onEventTriggeerred")

 

It is right?

If you want to do so, your event should be attached to root.

resource_1

function onResourceStart()
	triggerEvent("eventHandler", root)
end
addEventHandler("onResourceStart", resourceRoot, onResourceStart)

resource_2

function eventHandler()
	iprint("Serverside function was triggered at resource: "..getResourceName(getThisResource()).." from resource: "..getResourceName(sourceResource))
end
addEvent("eventHandler", true)
addEventHandler("eventHandler", root, eventHandler)

Result:

JAhz3XG.png

  • Thanks 1
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...