08.01.2016, 13:53
(
Last edited by Frenk96; 13/01/2016 at 02:07 PM.
Reason: New version (1.1)
)
Zone management [zone.inc]
Intro
Hi, I state that my English is not very good.
This is the first that includes place on the forum. Initially I designed because I needed it for my GM, but then I decided to bring us some of the changes and publish it here.
This includes very simple, allows you to create and manage zones. Or you can create them using the minimum and maximum coordinates or using a center coordinate and a range.
The area will also be visible on the map thanks to the GangZoneCreate.
In addition to these there are some that allow you to check if a player is in a zone or area in which it is located.
And then there are two callbacks that are called when a player (or NPC) enters or leaves a zone.
Also, when a player is in an area it creates a small text draw on the minimap that shows the name of the area.
I hope this includes you may require. I am open to any criticism, suggestion or even to simple compliments.
Changelog
Code:
Version 1.0 - It includes the release. Version 1.1 - Inserted: CreateRhombusZone() e CreateTriangleZone(); Changed: GetTypeZone() in GetZoneType();
Code:
native CreateZone(Float:minX, Float:minY, Float:maxX, Float:maxY, color = COLOR_WHITE, name[] = "None", type[] = "None"); native CreateZoneByRange(Float:X, Float:Y, Float:Range = 5.0, color = COLOR_WHITE, name[] = "None", type[] = "Safe"); // NEW native CreateRhombusZone(Float:X, Float:Y, Float:Range = 50.0, color = COLOR_WHITE, name[] = "None", type[] = "None") native CreateTriangleZone(Float:X, Float:Y, Float:Range = 50.0, cardinalPoint[] = "North", color = COLOR_WHITE, name[] = "None", type[] = "None") // native GetZoneType(zoneid); // Changed native GetZoneName(zoneid); // Player functions native IsPlayerInZone(playerid, zoneid); native IsPlayerInAnyZone(playerid); native GetPlayerZone(playerid); native Zone_OnPlayerConnect(playerid);
Code:
CreateZone(Float:minX, Float:minY, Float:maxX, Float:maxY, color = COLOR_WHITE, name[] = "None", type[] = "None"); Float:minX - Minimum coordinate X. Float:minY - Minimum coordinate Y. Float:maxX - Maximum coordinate X. Float:maxY - Maximum coordinate Y. color - The colors already defined are red, green, blue, yellow, white (default), gray and blue. name[24] - The name of the area. If not set it will be "Zone id". Type[24] - The type of area. If not set it will be "None". Will return the id of the area. CreateZoneByRange(Float:X, Float:Y, Float:Range = 5.0, color = COLOR_WHITE, name[] = "None", type[] = "Safe"); Watch function Create Zone. Float:Rage - Necessary to calculate the minimum and maximum coordinates. Default is 5.0.
Code:
CreateRhombusZone(Float:X, Float:Y, Float:Range = 50.0, color = COLOR_WHITE, name[] = "None", type[] = "None"); Float:X - Coordinate X. Float:Y - Coordinate Y. Float:Rage - Necessary to calculate the minimum and maximum coordinates. Default is 5.0. color - The colors already defined are red, green, blue, yellow, white (default), gray and blue. name[24] - The name of the area. If not set it will be "Zone id". Type[24] - The type of area. If not set it will be "None". Will Returns the number of zones created.
Code:
CreateTriangleZone(Float:X, Float:Y, Float:Range = 50.0, cardinalPoint[] = "North", color = COLOR_WHITE, name[] = "None", type[] = "None"); Float:X - Coordinate X. Float:Y - Coordinate Y. Float:Rage - Necessary to calculate the minimum and maximum coordinates. Default is 50.0. cardinalPoint[] - It indicates the direction of the triangle. Default is "North". color - The colors already defined are red, green, blue, yellow, white (default), gray and blue. name[24] - The name of the area. If not set it will be "Zone id". Type[24] - The type of area. If not set it will be "None". Will Returns the number of zones created.
Code:
GetZoneType(zoneid); - Returns the type of the area giving it as input the id. GetZoneName(zoneid); - Returns the name of the area giving it as input the id.
IsPlayerInZone & IsPlayerInAnyZone & GetPlayerZone
Code:
IsPlayerInZone(playerid, zoneid); - Returns 1 if the player is in that area else 0. IsPlayerInAnyZone(playerid); - Returns 1 if the player is in any zone else 0. GetPlayerZone(playerid); - Return the id of the area where the player else 0.
Code:
Zone_OnPlayerConnect(playerid); - Added OnPlayerConnect of your GM in case of include OnPlayerConnect cause problems.
Code:
forward OnPlayerEnterZone(playerid, zoneid); - It is prompted when the player enters a zone. forward OnPlayerExitZone(playerid, zoneid); - It is prompted when the player comes out of a zone.
Code:
public OnPlayerEnterZone(playerid,zoneid) { if(strcmp(GetTypeZone(zoneid), "Blue")==0) { GameTextForPlayer(playerid, "~b~You went into a blue zone.", 3000, 3); } else if(strcmp(GetTypeZone(zoneid), "Red")==0) { GameTextForPlayer(playerid, "~r~Warning!~n~~w~You went into a red zone.", 3000, 3); } else GameTextForPlayer(playerid, "~w~You went into a zone.", 3000, 3); return 1; } public OnPlayerExitZone(playerid,zoneid) { GameTextForPlayer(playerid, "~w~You are come out of a zone.", 3000, 3); return 1; }