Advertisement
Johurt

[FS] jSZS

Jan 24th, 2012
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.04 KB | None | 0 0
  1. /*
  2.     Filterscripta sukure Johurt(Edgaras), padejo Robertas ir Elonas specialiai Gta-Online.lt
  3.     Viskas daryta pagal wiki.sa-mp.com:
  4.  
  5.     http://wiki.sa-mp.com/wiki/SetTimer
  6.     http://wiki.sa-mp.com/wiki/GangZoneCreate
  7.  
  8.     http://pastebin.com/HpQHTrZS - F-ja sugeneruoti minX, minY, maxX, maxY kord.
  9. */
  10. #define FILTERSCRIPT
  11. #include <a_samp>
  12.  
  13. #define MAX_ZONES  5 // Maksimalos saugiu zonu kiekis.
  14. #define MAX_WARNS  5 // Maksimalus ispejimu kiekis.
  15. #define WARN_COLOR 0xf6102bFF // Ispejimo spalva.
  16. #define ZONE_COLOR 0xFFFF0096 // Saugiu zonu spalva.
  17.  
  18. forward ShowText();
  19. enum kords
  20. {
  21.      Float:minX,
  22.      Float:minY,
  23.      Float:maxX,
  24.      Float:maxY
  25. };
  26.  
  27. new Float:ZoneCords[MAX_ZONES][kords] =
  28. {
  29.      // minX, minY, maxX, maxY
  30.      {-2696.9824, -60.6852, -2613.1055, 29.8879}, // San Fierro
  31.      {-2001.5415, 77.9670, -1950.7507, 218.3597}, // San Fierro
  32.      {2077.4653, 1197.4258, 2182.3826, 1369.1112}, // Las Venturas
  33.      {1810.8127, 1456.8585, 2037.8066, 1709.1813}, // Las Venturas
  34.      {2192.7255, 2032.4004, 2312.0420, 2067.6936} // Las Venturas
  35. };
  36.  
  37. new Zone[MAX_ZONES], Warns[MAX_PLAYERS], bool:IsPlayerInZone[MAX_PLAYERS];
  38. new Text:Text, Timer;
  39.  
  40. public OnFilterScriptInit()
  41. {
  42.      print("\n--------------------------------------------");
  43.      print("[FS]jSZS - Save Zones System by Johurt loaded.");
  44.      print("--------------------------------------------\n");
  45.      Text = TextDrawCreate(456.0, 381.0, "Saugi_Zona");
  46.      TextDrawFont(Text, 3);
  47.      TextDrawLetterSize(Text, 0.569999, 2.399999);
  48.      TextDrawSetOutline(Text, 0);
  49.      TextDrawBackgroundColor(Text, 1717986918);
  50.      TextDrawColor(Text, -65386);
  51.      TextDrawSetOutline(Text, 0);
  52.      TextDrawSetProportional(Text, 1);
  53.      TextDrawSetShadow(Text, 1);
  54.      for(new z = 0; z < MAX_ZONES; z++)
  55.      {
  56.           Zone[z] = GangZoneCreate(ZoneCords[z][minX], ZoneCords[z][minY], ZoneCords[z][maxX], ZoneCords[z][maxY]);
  57.           GangZoneShowForAll(Zone[z], ZONE_COLOR);
  58.      }
  59.      for(new p = 0; p < MAX_PLAYERS; p++) IsPlayerInZone[p] = false;
  60.      Timer = SetTimer("ShowText", 1000, true);
  61.      return 1;
  62. }
  63.  
  64. public OnFilterScriptExit()
  65. {
  66.      print("\n----------------------------------------------");
  67.      print("[FS]jSZS - Save Zones System by Johurt unloaded.");
  68.      print("----------------------------------------------\n");
  69.      for(new z = 0; z < MAX_ZONES; z++) GangZoneDestroy(Zone[z]);
  70.      for(new p = 0; p < MAX_PLAYERS; p++) IsPlayerInZone[p] = false;
  71.      KillTimer(Timer); TextDrawDestroy(Text);
  72.      return 1;
  73. }
  74.  
  75. public OnPlayerConnect(playerid)
  76. {
  77.      Warns[playerid] = 0; IsPlayerInZone[playerid] = false;
  78.      for(new z = 0; z < MAX_ZONES; z++) GangZoneShowForPlayer(playerid, Zone[z], ZONE_COLOR);
  79.      TextDrawHideForPlayer(playerid, Text);
  80.      return 1;
  81. }
  82.  
  83. public OnPlayerDisconnect(playerid, reason)
  84. {
  85.      for(new z = 0; z < MAX_ZONES; z++) GangZoneHideForPlayer(playerid, Zone[z]);
  86.      TextDrawHideForPlayer(playerid, Text);
  87.      return 1;
  88. }
  89.  
  90. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
  91. {
  92.      if(issuerid != INVALID_PLAYER_ID)
  93.      {
  94.           if(IsPlayerInZone[playerid] == true)
  95.           {
  96.                new Float:phealt; GetPlayerHealth(playerid, phealt);
  97.                new Float:ihhealt; GetPlayerHealth(issuerid, ihhealt);
  98.                SetPlayerHealth(playerid, phealt + amount); SetPlayerHealth(issuerid, ihhealt - amount);
  99.                Warns[issuerid] += 1;
  100.                new msg[110];
  101.                format(msg, sizeof(msg), "Ispejame. Jeigu ir toliau saudysite i civilius saugiuose zonuose busite nubaustas. Gavote %d ispejima(Max %d).", Warns[issuerid], MAX_WARNS);
  102.                SendClientMessage(issuerid, WARN_COLOR, msg);
  103.                if(Warns[issuerid] >= MAX_WARNS)
  104.                {
  105.                     SendClientMessage(issuerid, WARN_COLOR, "Jus ismestas is serverio uz saudyma i civilius saugiose zonuose.");
  106.                     Kick(issuerid);
  107.                }
  108.           }
  109.      }
  110.      return 1;
  111. }
  112.  
  113. public ShowText()
  114. {
  115.      for(new p = 0; p < MAX_PLAYERS; p++)
  116.      {
  117.           if(!IsPlayerConnected(p)) continue;
  118.           for(new z = 0; z < MAX_ZONES; z++)
  119.           {
  120.                if(!PlayerInZone(p, ZoneCords[z][minX], ZoneCords[z][minY], ZoneCords[z][maxX], ZoneCords[z][maxY]))
  121.                {
  122.                     if(IsPlayerInZone[p] == true)
  123.                     {
  124.                          IsPlayerInZone[p] = false;
  125.                          TextDrawHideForPlayer(p, Text);
  126.                     }
  127.                     continue;
  128.                }
  129.                else if(IsPlayerInZone[p] == false)
  130.                {
  131.                     IsPlayerInZone[p] = true;
  132.                     TextDrawShowForPlayer(p, Text);
  133.                }
  134.                return 1;
  135.           }
  136.      }
  137.      return 1;
  138. }
  139.  
  140. stock PlayerInZone(playerid, Float:min_X, Float:min_Y, Float:max_X, Float:max_Y)
  141. {
  142.      new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  143.      if((pos[0] <= max_X && pos[0] >= min_X) && (pos[1] <= max_Y && pos[1] >= min_Y)) return 1;
  144.      return 0;
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement