Jump to content

Get objects coordinates


azonsea

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, it will look for game object, make instance of ragemp object and delete object.
 

const object = mp.game.object.getClosestObjectOfType(x, y, z, 2, modelHash, false, true, true);
    if (!object) return;
 
    const mpObject = mp.objects.newWeak(object);
 
    for (let i = 0; i < 150; i++) {
        if (!mpObject || !mp.objects.exists(mpObject))
            mp.game.wait(1);
    }
 
    if (!mpObject) return;
    mpObject.setAsMission(true, true);
    mpObject.markForDeletion();
    mpObject.destroy();
Edited by Kopra
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
  • Recently Browsing   0 members

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