Jump to content
RAGE Multiplayer Community

Get objects coordinates


azonsea
 Share

Recommended Posts

Trying to get coordinates of nearest ATM.

let joaat = mp.game.joaat("prop_atm_03");
return mp.game.object.getClosestObjectOfType(player.position.x, player.position.y, player.position.z, 1000000, joaat, false, true, true);

I'm getting integer something like 502585

How to get real object ?

 

I tried mp.objects.at(502585) and atHandle

Getting null in any case.

 

Thank you.

Link to comment
Share on other sites

let joaat = mp.game.joaat("prop_atm_03");
return mp.game.object.getClosestObjectOfType(player.position.x, player.position.y, player.position.z, 1000000, joaat, false, true, true);

In this case getClosestObjectOfType returns different values every time/
Link to comment
Share on other sites

I am not sure if getClosestObjectOfType is suitable to get default map props, maybe try with isMission set to true? Anyway, I suggest you using this file. It has the position of all the default ATMs. You could put a colshap on the position.

 https://github.com/DurtyFree/gta-v-data-dumps/blob/master/objectslocations/worldAtms.json

Edited by Pilatus
Link to comment
Share on other sites

  • 1 year later...
const atm_hashes = [
    {Name: 'prop_atm_01'},
    {Name: 'prop_atm_02'},
    {Name: 'prop_atm_03'},
    {Name: 'prop_fleeca_atm'}
]


const checkForAtm = () => {
    var playerpos = mp.players.local.position;
    var maxdistance = 1.0;

    atm_hashes.forEach((atm) => {
        var object = mp.game.object.getClosestObjectOfType(playerpos.x, playerpos.y, playerpos.z, maxdistance, mp.game.joaat(atm.Name), false, false, false);
        if(object != 0) {
            // ATM found
        }
    });	
}


Use this one instead, it will shorten your code by a huge amount of lines

Link to comment
Share on other sites

  • 2 weeks later...

If you want to get multiplayer object instnance from game object use something like this:
 

const Handle = mp.game.object.getClosestObjectOfType(Player.position.x, Player.position.y, Player.position.z, 5, Model, false, true, true);
    if (Handle) {
        const Object = mp.objects.newWeak(Handle);
        mp.game.waitAsync(1);
        if (Object) {
            Object.destroy();
        }
    }
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...