Zone API 1.1.0

   (3 reviews)
Sign in to follow this  

About This File

This resource adds 3 functions to the serverside mp.world object that provides zone name and type information.

 

Serverside API

/**
 * Returns the name of the area/zone at specified coords, ignores heights.
 * @param  {object} coords An object with "x" and "y" properties.
 * @return {string}        Zone name.
 */
mp.world.getNameOfZone2D(coords);

/**
 * Returns the name of the area/zone at specified coords.
 * @param  {object} coords An object with "x", "y" and "z" properties, such as mp.Vector3.
 * @return {string}        Zone name.
 */
mp.world.getNameOfZone3D(coords);

/**
 * Returns the type of the area/zone at specified coords.
 * @param  {object} coords An object with "x" and "y" properties.
 * @return {string}        Zone type, either "city" or "countryside".
 */
mp.world.getTypeOfZone(coords);

 

Example

const coords = new mp.Vector3(1823.961, 4708.14, 42.4991); // Grapeseed Bunker
console.log(`Name 2D: ${mp.world.getNameOfZone2D(coords)}`); // Expected output: Grapeseed
console.log(`Name 3D: ${mp.world.getNameOfZone3D(coords)}`); // Expected output: Grapeseed
console.log(`Zone Type: ${mp.world.getTypeOfZone(coords)}`); // Expected output: countryside

 

Notes

  • Available on GitHub: https://github.com/root-cause/ragemp-zone-api
  • N.O.O.S.E area returns Tataviam Mountains instead.
  • There might be other areas with inaccuracies, feel free to share a fix in comments/send a pull request.

What's New in Version 1.1.0   See changelog

Released

Added more RAGEMP-like syntax, now you can use:

mp.world.zone.getName2d(coords); // == mp.world.getNameOfZone2D
mp.world.zone.getName3d(coords); // == mp.world.getNameOfZone3D
mp.world.zone.getType(coords); // == mp.world.getTypeOfZone

 

  • Like 2



User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

DingoDongBlueBalls

· Edited by DingoDongBlueBalls

  

Perfect

 

getTypeOfZone is really useful to use in combination with the car generators: 

 

I used the getTypeOfZone method to check if the position of the car from generator is in the city or countryside and change spawn chance accordingly(since the vehicles in countryside are more spread out and thus can have a higher spawn chance per vehicle whereas in the city the vehicles are much closer together and thus spawn chance should be much lower as to not exceed vehicle limit).

Share this review


Link to review
ragempdev

  

RAGEMP-like 5/5

Share this review


Link to review
Captien

  

thanks, i found my friendzone...

Share this review


Link to review