Jump to content

ZoneManager 0.0.1

   (4 reviews)

4 Screenshots

About This File

RageMP-ZoneManager

A very useful client-side system which let you create four squares or hexagons in any shape like colshapes which support Z axis

GIT REPO

Why i needed something like this

I was creating a traffic system which needed me to be able to check if a guy entered any crossroads and colshapes wasn't the thing i wanted + i wanted to sell farms by their shape and some of them wasn't shaped exaclty foursquare and i needed a little more, so i craeted this script to be able to make those things possible easily.

Features

  • You can create 4 types of zone which are defined az mp.zones.types in the script.
  • You can loop through your zones and remove them.
  • You can register zones by desired name.
  • You may delete any zone any time.
  • Server-side events also included.
  • It supports Z axis which is still not very clever since it's not a big deal, all i needed was to prevent people to trigger some events from above the ground
  • Have 4 testing functions which let you draw your zone on the map to see how it fits
  • You can now register zones by any vector pointes above 2

Functions (Client-Side)

/*
	Check if a zone is registered by it's name and it's dimension
*/
mp.zones.isZoneRegistered(zoneName, dimension)

/*
	Unregister a zone by it's name and dimension
*/
mp.zones.unRegisterZone(zoneName, dimension)

/*
	Register a zone by a list of vectors, height , zoneName, type, dimension
	Vectors: an arrayList of vectors depending on the type of the zone you are
	choosing to create for example if you are creating a 2PointZone all you need
	is 2 Vectors inside an array which are the starting point and the ending point
	and you have to pass height as -1 since it's not used in that type of zone
	if you are creating a 4PointZone you need to have an arrayList of vectors with
	4 Vectors inside and height is used this time, same as 4PointZone in 6PointZone
	you need to pass 6 vectors and the height.
	
	Returns ZoneObject (contains name, type, positions, and zone.data [which never used it my self])
*/
mp.zones.registerZone(Vectors, height, zoneName, type, dimension)


/*
	Get ZoneObject by it's name and dimension
*/
mp.zones.getZoneByName(zoneName, dimension)


/*
	Draw a 2PointZone for testing
	Requires 2 vectors
*/
mp.zones.drawZoneBy2(startPosition, endPosition)

/*
	Draw a 4PointZone for testing
	Requires 4 vectors and height
*/
mp.zones.drawZoneBy4(Vectors, height)

/*
	Draw a 6PointZone for testing
	Requires 6 vectors and height
*/
mp.zones.drawZoneBy6(Vectors, height)

/*
	Draw a NPointZone for testing
	Requires array of vectors and height
	Unlimited number of points supported by this code
*/
mp.zones.drawZoneByN(Vectors, height)

/*
	Check whether a point on the map is inside the zone or not
*/
mp.zones.isPointInZone(point, zoneName, dimension)

/*
	This is a list of registered zone names used for looping through zones
*/
mp.zones.registered 

Events (Server-Side/Client-Side)

On client side the player parameter is mostly the local player it self.


/*
    mp.events.add('ZoneManager_PlayerEnterZone', (player, zoneName) => {
        //Your Code


    })
    mp.events.add('ZoneManager_PlayerExitZone', (player, zoneName) => {
        //Your Code

    })
*/

Changelog

4/1/2020 - v0.0.1
- Added support for dimension
- Addes support for NPointZone type which let you create zones by any number of points
- Changed some functions to support dimensions, if you already used the script you may need to change them
- getZoneByName now returns undefined if the zone on the dimension does not exists (this thing existed before but i forgot to mention it before)

What's New in Version 0.0.1   See changelog

Released

 Added support for dimension
- Added support for NPointZone type which let you create zones by any number of points
- Changed some functions to support dimensions, if you already used the script you may need to change them
- getZoneByName now returns undefined if the zone on the dimension does not exists (this thing existed before but i forgot to mention it before)
  • Like 3
  • Mask 3

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

n0minal

· Edited by n0minal

   2 of 2 members found this review helpful 2 / 2 members

Looks good bro, but why create diferente functions to achieve the same goal? You could get the vectors array size and then apply the logic depending on it. Also, you could drastically improve the performance and reduce code complexity using javascript array higher-order functions, for example:

 

  for(i in mp.zones.registered)
    {
        var ZoneObject = mp.zones.registered[i];

        if(ZoneObject.zoneName == zoneName)

Could be converted to:

 

const zoneObject = mp.zones.registered.find(zone => zone.zoneName === zoneName);

And it would reduce a lot of unecessary iterations in your code, there's also a huge number of other possible improvements on it.

 

Anyways it's a great resource, if I find some free time I will fork it to make some pull requests improving your code, congratulations for the great release 😃 

Response from the author:

thanks for the tip man , i wan't paying attention to these coding techniques i just wanted to get the job done for my server so sorry for that xd
looking forward to see your edits and learn these improvements i also need to update the resource to add dimension support, great to see it's useful 

Link to review
×
×
  • Create New...