thekoyax123 Posted February 13, 2015 Share Posted February 13, 2015 Hey, so I need someone to explain me if there is a way to connect one resource with another as in being able to call its functions or trigger its events. On some other thread someone said that I can normally do it with triggerServerEvent or triggerClientEvent but obviously I can't. So is this even possible? If not, how do other servers deal with multiple resources? I mean I'm pretty sure it can be done somehow but I just don't know how. Thanks in advance Link to comment
Bonsai Posted February 13, 2015 Share Posted February 13, 2015 Its right. You can just trigger the events. Any resource that has a function attached to that event will call those.. Don't forget to use addEvent. Calling functions directly is possible by using this: https://wiki.multitheftauto.com/wiki/Call Personally I prefer events, as long as there is nothing that has to be returned. Link to comment
thekoyax123 Posted February 13, 2015 Author Share Posted February 13, 2015 So it doesn't matter that the .lua files are at the completely separate folders (resources), the event is added as long as the resource is running and I can trigger it from where ever I want? Link to comment
Bonsai Posted February 13, 2015 Share Posted February 13, 2015 Read this: https://wiki.multitheftauto.com/wiki/Event Link to comment
thekoyax123 Posted February 14, 2015 Author Share Posted February 14, 2015 Thanks, I've got this figured out but now I have a new problem. When I restart one resource the other one gets restarted as well, is there any way to prevent that? Like, I want one resource to keep going while I restart the other one. I don't if it has to do something with the event connection between the two (resource 1 triggers an event from resource 2 at some point). Any ideas? And yeah, I've read the Server Manual on mta wiki, didn't help Link to comment
Bonsai Posted February 14, 2015 Share Posted February 14, 2015 Did you use "include" in meta? The resource that includes others will start/stop/restart those. Link to comment
thekoyax123 Posted February 14, 2015 Author Share Posted February 14, 2015 Nope, no includes Link to comment
JR10 Posted February 15, 2015 Share Posted February 15, 2015 You're either using includes or have a code that restarts the resource, normally it shouldn't restart the other resource. Link to comment
thekoyax123 Posted February 15, 2015 Author Share Posted February 15, 2015 I'm pretty sure I used neither Link to comment
JR10 Posted February 15, 2015 Share Posted February 15, 2015 I stated the normal behavior as far as I know. Make sure that the resource is restarted, perhaps with a debug string or a chat box message. Make sure that there are no other resources running that might be doing that. Link to comment
thekoyax123 Posted February 15, 2015 Author Share Posted February 15, 2015 Found the problem elsewhere. Seems like I had to use resourceRoot instead of getRootElement() for onClientResourceStart event. Thanks anyway Link to comment
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