Jump to content

Zone API 1.1.0

   (3 reviews)

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 4

User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

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

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

Link to review
×
×
  • Create New...