botanist Posted December 25, 2009 Posted December 25, 2009 Hi, I want to know something. Is it possible to create 2 resources which work together? Like resource 1 has an event, but resource 2 says when that event have to be triggered. And when I use setElementData ( someElement, "someData", someValue ), can I use getElementData ( someElement, "someData" ) in another resource?
robhol Posted December 25, 2009 Posted December 25, 2009 Of course. Events, triggering and element data are all independent of resources. In fact, many resources trigger their own events so you can catch and modify what happens in them, without actually modifying said resources.
eAi Posted December 25, 2009 Posted December 25, 2009 Events are the main way resources should communicate that things have happened - many of the built-in resources do this. See https://wiki.multitheftauto.com/wiki/Resource:Map ... red_events and https://wiki.multitheftauto.com/wiki/Resource:Rac ... sion_0.8.3 for example.
botanist Posted December 25, 2009 Author Posted December 25, 2009 Okay But I saw also something about exporting function. Is that for when i want to do this: Resource 1 contains a function called function doSomethingLol( source ), and I want to trigger that in resource 2 when I spawn. Do I have to do something important or can I just do this?
50p Posted December 25, 2009 Posted December 25, 2009 You have to tell resource which function you want to export. To do this, you need to add export node in your meta.xml: https://wiki.multitheftauto.com/wiki/Meta.xml If you use MTA:SE you can start typing "exp" and you'll see a list of exported functions from other resources or you can see function list to the right of the window (includes exported functions from every resource).
botanist Posted December 27, 2009 Author Posted December 27, 2009 Okay, thank you all So in fact, this is what I need to do?: Resource 1: addEventHandler("onPlayerWasted", getRootElement(), function ( ammo, attacker, weapon, bodypart ) setElementData( source, "Status", "DEAD" ) --This triggerEvent( "onMyEvent", getRootElement(), source ) --This call(getResourceFromName("resource2"), "setSpectating", true , source) --This end ) Resource 2: addEvent ( "onMyEvent", true ) function myEventHandler ( source ) --some code end addEventHandler ( "onMyEvent", getRootElement(), myEventHandler ) function setSpectating( theBool, source) --some code end
eAi Posted December 27, 2009 Posted December 27, 2009 If it works, it's right, if not it's not. We can't do a better job at compiling code than the server can?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now