Jump to content

Recommended Posts

Posted
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.

Posted
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/
  • 1 year later...
Posted
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

  • 2 weeks later...
Posted (edited)

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

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...