Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define TOTAL_AREAS 5
- forward OnPlayerInArea();
- new bool:parea[MAX_PLAYERS];
- //Agora coloque as suas 300 reas nessas arrays, a primeira array o X-, Y-, X+ e Y+ de cada rea;
- //e a segunda array o nome de cada rea correnpondente ao index da primeira array
- new Float:area_coords[TOTAL_AREAS][4] = //4 = nmero de coordenadas (x-,y-,x+,y+)
- {
- {123.0, 123.0, 123.0, 123.0}, //0
- {234.0, 234.0, 234.0, 234.0}, //1
- {345.0, 345.0, 345.0, 345.0}, //2
- {456.0, 456.0, 456.0, 456.0}, //3
- {567.0, 567.0, 567.0, 567.0} //4
- };
- new area_names[TOTAL_AREAS][64] = //64 = tamanho das strings
- {
- "La Sierra Robada", //0
- "Las Payasadas", //1
- "Fort Carson", //2
- "Angel Pine", //3
- "Bayside" //4
- };
- public OnFilterScriptInit()
- {
- SetTimer("OnPlayerInArea", 300, 1);
- return 1;
- }
- public OnPlayerInArea()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- for(new j; j < TOTAL_AREAS; j++)
- {
- if(PlayerInArea(i, area_coords[j]))
- {
- if(j == 2) //se a area a as coordenadas de fort carson
- {
- new string[128];
- format(string, sizeof string, "Voc entrou em %s.", area_names[j]);
- SendClientMessage(i, 1010580650, string);
- } else if(j == 4) //se for as coords de bayside
- {
- new Float:health;
- GetPlayerHealth(i, health);
- SetPlayerHealth(i, health + 0.1);
- }
- }
- }
- }
- }
- stock PlayerInArea(playerid, Float:area[4])
- {
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- if(X >= area[0] && Y >= area[1] && X <= area[2] && Y <= area[3])
- {
- if(!parea[playerid])
- {
- parea[playerid] = true;
- return 1;
- } else {
- return 0;
- }
- } else {
- parea[playerid] = false;
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment