Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #pragma tabsize 0
- #define MAX_ZONE 1024
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLUE 0x0080C055
- /*
- // Zone functions
- 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[] = "None");
- // 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);
- // Callbacks
- forward OnPlayerEnterZone(playerid, zoneid);
- forward OnPlayerExitZone(playerid, zoneid);
- */
- new CountZone=0;
- enum EnumZone
- {
- ID,
- Name[24],
- Type[24],
- Color,
- Float:MinX,
- Float:MinY,
- Float:MaxX,
- Float:MaxY
- };
- new Zone[MAX_ZONE][EnumZone];//global
- new InZone[MAX_PLAYERS];
- new PlayerText:TextZone[MAX_PLAYERS];
- forward OnPlayerEnterZone(playerid,zoneid);
- forward OnPlayerExitZone(playerid,zoneid);
- forward Functions(playerid);
- public Functions(playerid)
- {
- if(IsPlayerInAnyZone(playerid)==1)
- {
- if(InZone[playerid] == -1)
- {
- InZone[playerid] = GetPlayerZone(playerid);
- CallLocalFunction("OnPlayerEnterZone", "dd", playerid, InZone[playerid]);
- TextZone[playerid] = CreatePlayerTextDraw(playerid, 45 ,320, GetZoneName(InZone[playerid]));
- PlayerTextDrawFont(playerid, TextZone[playerid] , 1);
- PlayerTextDrawLetterSize(playerid, TextZone[playerid] , 0.6, 2);
- PlayerTextDrawColor(playerid, TextZone[playerid] , 0xd6bd00FF);
- PlayerTextDrawSetOutline(playerid, TextZone[playerid] , false);
- PlayerTextDrawSetProportional(playerid, TextZone[playerid] , true);
- PlayerTextDrawSetShadow(playerid, TextZone[playerid] , 1);
- PlayerTextDrawShow(playerid, TextZone[playerid]);
- }
- }
- else
- {
- if(InZone[playerid]!=-1)
- {
- CallLocalFunction("OnPlayerExitZone", "dd", playerid, InZone[playerid]);
- PlayerTextDrawDestroy(playerid, TextZone[playerid]);
- InZone[playerid] = -1;
- }
- }
- return 1;
- }
- // Zone Function
- stock CreateZone(Float:minX, Float:minY, Float:maxX, Float:maxY, color = COLOR_WHITE, name[] = "None", type[] = "None")
- {
- if(CountZone >= MAX_ZONE) return 0;
- new zoneid=GangZoneCreate(minX,minY,maxX,maxY);
- Zone[zoneid][ID]= zoneid;
- Zone[zoneid][Color]= color;
- Zone[zoneid][MinX]= minX;
- Zone[zoneid][MinY]= minY;
- Zone[zoneid][MaxX]= maxX;
- Zone[zoneid][MaxY]= maxY;
- strcat(Zone[zoneid][Type], type);
- if(strcmp(name, "None")==0) format(Zone[zoneid][Name],24,"Zone %d", zoneid);
- else format(Zone[zoneid][Name],24,"%s", name);
- CountZone++;
- GangZoneShowForAll(zoneid, color);
- return zoneid;
- }
- stock CreateZoneByRange(Float:X, Float:Y, Float:Range = 50.0, color = COLOR_WHITE, name[] = "None", type[] = "None")
- {
- if(CountZone >= MAX_ZONE) return 0;
- new Float:minX = X-Range, Float:minY = Y-Range, Float:maxX = X+Range, Float:maxY = Y+Range;
- new zoneid=GangZoneCreate(minX,minY,maxX,maxY);
- Zone[zoneid][ID]= zoneid;
- Zone[zoneid][Color]= color;
- Zone[zoneid][MinX]= minX;
- Zone[zoneid][MinY]= minY;
- Zone[zoneid][MaxX]= maxX;
- Zone[zoneid][MaxY]= maxY;
- format(Zone[zoneid][Type],24,"%s", type);
- if(strcmp(name, "None")==0) format(Zone[zoneid][Name],24,"Zona %d", zoneid);
- else format(Zone[zoneid][Name],24,"%s", name);
- CountZone++;
- GangZoneShowForAll(zoneid, color);
- return zoneid;
- }
- stock CreateRhombusZone(Float:X, Float:Y, Float:Range = 50.0, color = COLOR_WHITE, name[] = "None", type[] = "None")
- {
- new Float:minX, Float:minY, Float:maxX, Float:maxY;
- new i=0;
- while(i <= Range)
- {
- minX = X-Range+i; minY = Y-i; maxX = X+Range-i; maxY = Y+i;
- CreateZone(minX, minY, maxX, maxY, color, name, type);
- i++;
- }
- return i;
- }
- stock CreateTriangleZone(Float:X, Float:Y, Float:Range = 50.0, cardinalPoint[] = "North", color = COLOR_WHITE, name[] = "None", type[] = "None")
- {
- new Float:minX, Float:minY, Float:maxX, Float:maxY;
- new i=0;
- while(i <= Range)
- {
- if(strcmp(cardinalPoint, "North")==0) { minX = X-Range+i; minY = Y; maxX = X+Range-i; maxY = Y+i; }
- else if(strcmp(cardinalPoint, "South")==0) { minX = X-Range+i; minY = Y-i; maxX = X+Range-i; maxY = Y; }
- else if(strcmp(cardinalPoint, "East")==0) { minX = X; minY = Y-i; maxX = X+Range-i; maxY = Y+i; }
- else if(strcmp(cardinalPoint, "West")==0) { minX = X-Range+i; minY = Y-i; maxX = X; maxY = Y+i; }
- CreateZone(minX, minY, maxX, maxY, color, name, type);
- i++;
- }
- return i;
- }
- stock GetZoneType(zoneid)
- {
- new type[24] = "Invalid Zone";
- format(type,24,"%s", Zone[zoneid][Type]);
- return type;
- }
- stock GetZoneName(zoneid)
- {
- new name[24] = "Invalid Zone";
- format(name,24,"%s", Zone[zoneid][Name]);
- return name;
- }
- // Player function
- stock IsPlayerInZone(playerid, zoneid)
- {
- new Float:Px, Float:Py, Float:Pz;
- GetPlayerPos(playerid, Px, Py, Pz);
- if(Px>Zone[zoneid][MinX] && Py>Zone[zoneid][MinY] && Px<Zone[zoneid][MaxX] && Py<Zone[zoneid][MaxY]) return 1;
- else return 0;
- }
- stock IsPlayerInAnyZone(playerid)
- {
- new Float:Px, Float:Py, Float:Pz;
- GetPlayerPos(playerid, Px, Py, Pz);
- for(new i = 0; i < CountZone; i++)
- {
- if(Px>Zone[i][MinX] && Py>Zone[i][MinY] && Px<Zone[i][MaxX] && Py<Zone[i][MaxY]) return 1;
- }
- return 0;
- }
- stock GetPlayerZone(playerid)
- {
- new Float:Px, Float:Py, Float:Pz;
- GetPlayerPos(playerid, Px, Py, Pz);
- for(new i = 0; i < CountZone; i++)
- {
- if(Px>Zone[i][MinX] && Py>Zone[i][MinY] && Px<Zone[i][MaxX] && Py<Zone[i][MaxY]) return i;
- }
- return -1;
- }
- stock Zone_OnPlayerConnect(playerid)
- {
- for(new i = 0; i <= CountZone; i++)
- {
- GangZoneShowForAll(i, Zone[i][Color]);
- }
- InZone[playerid] = -1;
- SetTimerEx("Functions", 500, true, "i", playerid);
- return 1;
- }
- // Callbacks
- public OnPlayerConnect(playerid)
- {
- Zone_OnPlayerConnect(playerid);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment