toribio

toribio

Apr 24th, 2009
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define TOTAL_AREAS 5
  4.  
  5. forward OnPlayerInArea();
  6.  
  7. new bool:parea[MAX_PLAYERS];
  8.  
  9. //Agora coloque as suas 300 reas nessas arrays, a primeira array o X-, Y-, X+ e Y+ de cada rea;
  10. //e a segunda array o nome de cada rea correnpondente ao index da primeira array
  11.  
  12. new Float:area_coords[TOTAL_AREAS][4] = //4 = nmero de coordenadas (x-,y-,x+,y+)
  13. {
  14.     {123.0, 123.0, 123.0, 123.0}, //0
  15.     {234.0, 234.0, 234.0, 234.0}, //1
  16.     {345.0, 345.0, 345.0, 345.0}, //2
  17.     {456.0, 456.0, 456.0, 456.0}, //3
  18.     {567.0, 567.0, 567.0, 567.0}  //4
  19. };
  20.  
  21. new area_names[TOTAL_AREAS][64] = //64 = tamanho das strings
  22. {
  23.     "La Sierra Robada", //0
  24.     "Las Payasadas",    //1
  25.     "Fort Carson",      //2
  26.     "Angel Pine",       //3
  27.     "Bayside"           //4
  28. };
  29.  
  30. public OnFilterScriptInit()
  31. {
  32.     SetTimer("OnPlayerInArea", 300, 1);
  33.     return 1;
  34. }
  35.  
  36. public OnPlayerInArea()
  37. {
  38.     for(new i = 0; i < MAX_PLAYERS; i++)
  39.     {
  40.         for(new j; j < TOTAL_AREAS; j++)
  41.         {
  42.             if(PlayerInArea(i, area_coords[j]))
  43.             {
  44.                 if(j == 2) //se a area a as coordenadas de fort carson
  45.                 {
  46.                     new string[128];
  47.                     format(string, sizeof string, "Voc entrou em %s.", area_names[j]);
  48.                     SendClientMessage(i, 1010580650, string);
  49.                 } else if(j == 4) //se for as coords de bayside
  50.                 {
  51.                     new Float:health;
  52.                     GetPlayerHealth(i, health);
  53.                     SetPlayerHealth(i, health + 0.1);
  54.                 }
  55.             }
  56.         }
  57.     }
  58. }
  59.  
  60. stock PlayerInArea(playerid, Float:area[4])
  61. {
  62.     new Float:X, Float:Y, Float:Z;
  63.     GetPlayerPos(playerid, X, Y, Z);
  64.     if(X >= area[0] && Y >= area[1] && X <= area[2] && Y <= area[3])
  65.     {
  66.         if(!parea[playerid])
  67.         {
  68.             parea[playerid] = true;
  69.             return 1;
  70.         } else {
  71.             return 0;
  72.         }
  73.     } else {
  74.         parea[playerid] = false;
  75.         return 0;
  76.     }
  77. }
  78.  
Add Comment
Please, Sign In to add comment