toribio

toribio

Apr 24th, 2009
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 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][TOTAL_AREAS];
  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 = n�mero 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(!parea[i][j])
  45.                 {
  46.                     new string[128];
  47.                     format(string, sizeof string, "Voc� entrou em %s.", area_names[j]);
  48.                     SendClientMessage(i, 1010580650, string);
  49.                     parea[i][j] = true;
  50.                 }
  51.             } else {
  52.                 parea[i][j] = false;
  53.             }
  54.         }
  55.     }
  56. }
  57.  
  58. stock PlayerInArea(playerid, Float:area[4])
  59. {
  60.     new Float:X, Float:Y, Float:Z;
  61.     GetPlayerPos(playerid, X, Y, Z);
  62.     return X >= area[0] && Y >= area[1] && X <= area[2] && Y <= area[3];
  63. }
Add Comment
Please, Sign In to add comment