koragg Posted November 20, 2018 Share Posted November 20, 2018 Hey guys, Recently I tried to fix one bug in my ghost spectate resource but I need to check if a resource is indeed a map or not clientside. I know that the mapmanager has a serverside function which does this but I need a clientside way so I can use onClientResourceStop handler on resources that are maps. Otherwise the code shouldn't work if I restart a normal script for example. Link to comment
Moderators IIYAMA Posted November 20, 2018 Moderators Share Posted November 20, 2018 (edited) @koragg The resource type isn't synced in the first place.(afaik) All below is just a guess: If you are not going to use a resource to sync that information, then there is a possible way to figure out if that resource is using map files. Technically it should be possible with this function: https://wiki.multitheftauto.com/wiki/GetElementChildren https://wiki.multitheftauto.com/wiki/Element_tree The element tree is attaching map elements on the mapRoot. The mapRoot should be attached to the resourceRoot. If this mapRoot is synced + synced before the resource starts clientside, then yes you might figure out if this resource can be considered a map. The only problem is that every resource can serve map files. Next to that, you can maybe find some element data leftovers from those (sub)root elements: https://wiki.multitheftauto.com/wiki/GetAllElementData https://wiki.multitheftauto.com/wiki/GetElementID Let me know if you find something interesting! Edited November 20, 2018 by IIYAMA 1 Link to comment
koragg Posted November 20, 2018 Author Share Posted November 20, 2018 (edited) 35 minutes ago, IIYAMA said: @koragg The resource type isn't synced in the first place.(afaik) All below is just a guess: If you are not going to use a resource to sync that information, then there is a possible way to figure out if that resource is using map files. Technically it should be possible with this function: https://wiki.multitheftauto.com/wiki/GetElementChildren https://wiki.multitheftauto.com/wiki/Element_tree The element tree is attaching map elements on the mapRoot. The mapRoot should be attached to the resourceRoot. If this mapRoot is synced + synced before the resource starts clientside, then yes you might figure out if this resource can be considered a map. The only problem is that every resource can serve map files. Next to that, you can maybe find some element data leftovers from those (sub)root elements: https://wiki.multitheftauto.com/wiki/GetAllElementData https://wiki.multitheftauto.com/wiki/GetElementID Let me know if you find something interesting! Will do but probably in December as I'm attacked by tests almost every day in university now Edited November 20, 2018 by koragg 1 Link to comment
Moderators IIYAMA Posted November 20, 2018 Moderators Share Posted November 20, 2018 5 minutes ago, koragg said: Will do but probably in December as I'm attacked by tests almost every day in university now That are murderous tests :(, I wish you good luck! 1 Link to comment
koragg Posted November 30, 2018 Author Share Posted November 30, 2018 Just realized. Can't I make this work with events? Seems easier tbh. Will try checking if it's a map by triggering a server event and then triggering a client event from the server event which would make the client know if it's a map or not. If this doesn't work I'll try the above^ 1 Link to comment
Moderators IIYAMA Posted November 30, 2018 Moderators Share Posted November 30, 2018 (edited) Yea that is a possibility. @koragg Just keep in mind that: (if this issue is still around) 1. if you were listening serverside with the event onResourceStart. 2. Trigger the resourceRoot of that specific resource to clientside. 3. That after validating, the resourceRoot is not available yet. (Just run these 3 steps and you will understand what this means) Send over the resourceName instead and wait for onClientResourceStart(with high addEventHandler priority) Edited November 30, 2018 by IIYAMA 1 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