Jump to content

Check if resource is a map clientside?


koragg

Recommended Posts

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

@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 by IIYAMA
  • Like 1
Link to comment
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 :D

Edited by koragg
  • Haha 1
Link to comment
  • 2 weeks later...

 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^

  • Like 1
Link to comment
  • Moderators

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 by IIYAMA
  • 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...