R1Z Posted January 27, 2022 Share Posted January 27, 2022 Hi guys, im currently in some kind of dilema, i have started scripting randomly, and im just testing some things. So what i want is: If this object is close to me (and returns true, or is there), i want the object to be destroyed and return some console.log or outputChatbox. If i just do it without an IF queue it works without a problem, but if i ask "Is object close" it will keeps returning nothing, even though im standing next to it. Do you have some idea how to do this properly, i tried to avoid asking questions here, but i can't move forward without this getting out of my head. function denearby(player) { mp.objects.forEachInRange(player.position, 2, (table) => { console.log(`You destroyed ID ${table.getVariable("ID")}!`); mp.db.query('DELETE FROM `objects` WHERE ID = ?', [table.data.ID], function (err, res, row) { }); table.destroy(); }) } mp.events.addCommand("delobj", (player, object) => { var obj = mp.objects.forEachInRange(player.position, 2, (table) => { return true; }); if (obj == true) { denearby(player); player.outputChatBox("Success"); } else { player.outputChatBox("No"); } }); This is just some random code i did really quick to describe how im trying it. I tried to do it client-side, with the function of getClosestObjectOfType, but it doesn't work either. If somebody has some kind of input i would really appreciate it. I might make some stupid mistake im too stupid to see. I know im new to this, but learning out of my mistakes might help. Looking forward to your answers. Link to comment Share on other sites More sharing options...
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