Jump to content

Want to know something


botanist

Recommended Posts

Posted

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?

Posted

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.

Posted

Okay :D

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?

Posted

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

Posted

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

Posted

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?

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