theralio Posted August 14, 2018 Posted August 14, 2018 Hello, I search a Function like this http://wiki.sa-mp.com/wiki/IsPlayerInRangeOfPoint i still dont find anything. Greets, Sebastian
izcream* Posted August 14, 2018 Posted August 14, 2018 mp.players.forEachInRange(player.position, int: range, (player) => { //do }) Ref: Wiki
Protocole Posted August 14, 2018 Posted August 14, 2018 Else, you can try vectorial maths: https://math.stackexchange.com/questions/42640/calculate-distance-in-3d-space
paccoderpster Posted August 17, 2018 Posted August 17, 2018 /** * @author Paccoderpster * @param {mp.Vector3} pos1 * @param {mp.Vector3} pos2 * @param {number} range * @return true if the player is range; false if not */ global.isInRange = function isInRange(pos1, pos2, range) { return ( Math.sqrt( Math.pow(pos1.x - pos2.x, 2) + Math.pow(pos1.y - pos2.y, 2) + Math.pow(pos1.z - pos2.z, 2) ) <= range ); }
Doom Posted August 19, 2018 Posted August 19, 2018 (edited) You may also find this function useful as well: https://wiki.rage.mp/index.php?title=Entity::dist Clientside: https://wiki.rage.mp/index.php?title=System::vdist https://wiki.rage.mp/index.php?title=System::vdist2 Edited August 19, 2018 by Doom
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