Advertisement
LinkiNPark

gate

Jun 1st, 2014
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.15 KB | None | 0 0
  1. #include a_samp
  2. #define LIMIT_GATE 20
  3. new
  4.     Float: CLOSE [LIMIT_GATE] [3],
  5.     Float: OPEN [LIMIT_GATE] [3],
  6.     NAME_ENTER [LIMIT_GATE] [24],
  7.     D_POINT [LIMIT_GATE],
  8.     ID_GATE [LIMIT_GATE],
  9.     bool: CREATED_GATE [LIMIT_GATE],
  10.     AUTO_CLOSE [LIMIT_GATE],
  11.     TIME_GATE [LIMIT_GATE];
  12. stock GetLastIDGate ()
  13. {
  14.     for (new i; i != LIMIT_GATE; ++ i)
  15.         if (!CREATED_GATE [i]) return i;
  16.     return LIMIT_GATE;
  17. }
  18. stock AddAutoGate(modelid,Float:cX,Float:cY,Float:cZ,Float:rX,Float:rY,Float:rZ,Float:oX,Float:oY,Float:oZ,namecanenter[24],open_distance, close_time = 5)
  19. {
  20.     new
  21.     i = GetLastIDGate ();
  22.     if (i == LIMIT_GATE) return 0; //превышен лимит
  23.  
  24.     CLOSE [i] [0] = cX, CLOSE [i] [1] = cY, CLOSE [i] [2] = cZ;
  25.     OPEN [i] [0] = oX, OPEN [i] [1] = oY, OPEN [i] [2] = oZ;
  26.     format (NAME_ENTER [i], 24, "%s", namecanenter);
  27.     D_POINT [i] = open_distance;
  28.     ID_GATE [i] = CreateObject (modelid, cX, cY, cZ, rX, rY, rZ);
  29.     CREATED_GATE [i] = true, TIME_GATE [i] = close_time;
  30.     if (!i) SetTimer ("CheckGates", 1000, false);
  31.     return 1;
  32. }
  33. forward CheckGates();
  34. public CheckGates()
  35. {
  36.     for (new gate, PLAYER_NAME [MAX_PLAYER_NAME]; gate != LIMIT_GATE; ++ gate)
  37.     {
  38.     if (!CREATED_GATE [gate]) continue;
  39.     for (new i = GetMaxPlayers(); i != -1; --i)
  40.     {
  41.             if(!IsPlayerConnected(i)) continue;
  42.         GetPlayerName (i, PLAYER_NAME, MAX_PLAYER_NAME);
  43.         if (IsPlayerInRangeOfPoint (i, D_POINT [gate], CLOSE [gate] [0], CLOSE [gate] [1], CLOSE [gate] [2]) &&
  44.         !strfind (PLAYER_NAME, NAME_ENTER [gate], true))
  45.         MoveObject (ID_GATE [gate], OPEN [gate] [0], OPEN [gate] [1], OPEN [gate] [2], 1),
  46.                     AUTO_CLOSE [gate] = TIME_GATE [gate];
  47.         if (-- AUTO_CLOSE [gate] < 0) MoveObject (ID_GATE [gate], CLOSE [gate] [0], CLOSE [gate] [1], CLOSE [gate] [2], 1);
  48.     }
  49.     }
  50.     SetTimer ("CheckGates", 1000, false);
  51.     return 1;
  52. }
  53.  
  54. //используй так же как и старый инклуд,
  55. //но я добавил новый параметр close_time = 5
  56. //это время в сек через которое закроются ворота(по умолчанию 5сек)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement