azonsea Posted June 7, 2020 Posted June 7, 2020 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.
azonsea Posted June 9, 2020 Author Posted June 9, 2020 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/
Pilatus Posted June 9, 2020 Posted June 9, 2020 (edited) 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 June 9, 2020 by Pilatus
Snakzi Posted October 25, 2021 Posted October 25, 2021 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
Kopra Posted November 4, 2021 Posted November 4, 2021 (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 May 25, 2023 by Kopra
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