Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 28th, 2011  |  syntax: PAWN  |  size: 2.79 KB  |  views: 1,244  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //(c) Macluawn
  2.  
  3. forward OnPlayerEnterCheckPointEx(playerid, checkpoint);
  4. forward mcpCheck();
  5.  
  6. enum mcpParamsEx
  7. {
  8.         bool:mcpCreated,
  9.         Float:mcpX,
  10.         Float:mcpY,
  11.         Float:mcpZ,
  12. };
  13.  
  14. new mcpParams[30][mcpParamsEx],
  15.         mcpId = -1,
  16.         mcpUsed,
  17.         bool:mcpShown[MAX_PLAYERS][30],
  18.         bool:mcpEntered[MAX_PLAYERS][30];
  19.  
  20. stock CreateCheckpoint(Float:x, Float:y, Float:z)
  21. {
  22.         mcpId = -1;
  23.         for (new mcpi = 0; mcpi < 30; mcpi++)
  24.         {
  25.                 if(mcpParams[mcpi][mcpX] == 0)
  26.                 {
  27.                         mcpId = mcpi;
  28.                         break;
  29.                 }
  30.         }
  31.         if(mcpId == -1) return -1;
  32.         mcpParams[mcpId][mcpCreated] = true;
  33.         mcpParams[mcpId][mcpX] = x;
  34.         mcpParams[mcpId][mcpY] = y;
  35.         mcpParams[mcpId][mcpZ] = z;
  36.         if(mcpUsed == 0)
  37.         {
  38.                 SetTimer("mcpCheck",150,true);
  39.                 mcpUsed = 1;
  40.         }
  41.         return mcpId;
  42. }
  43.  
  44. stock ShowPlayerCheckpoint(playerid, mcpid, bool:visable = true)
  45. {
  46.         if(0 > mcpid > 29) return 0;
  47.         if(mcpParams[mcpId][mcpCreated] == false) return 0;
  48.         if(visable == true) SetPlayerMapIcon(playerid, mcpid, mcpParams[mcpid][mcpX], mcpParams[mcpid][mcpY], mcpParams[mcpid][mcpZ], 0, 0xff0000AA, MAPICON_GLOBAL_CHECKPOINT);
  49.         else SetPlayerMapIcon(playerid, mcpid, mcpParams[mcpid][mcpX], mcpParams[mcpid][mcpY], mcpParams[mcpid][mcpZ], 0, 0xff000000, MAPICON_GLOBAL_CHECKPOINT);
  50.         mcpShown[playerid][mcpid] = true;
  51.         return 1;
  52. }
  53.  
  54. stock HidePlayerCheckpoint(playerid, mcpid)
  55. {
  56.         if(0 > mcpid > 29) return 0;
  57.         if(mcpShown[playerid][mcpid] == false) return 0;
  58.         if(mcpParams[mcpId][mcpCreated] == 0) return 0;
  59.         RemovePlayerMapIcon(playerid, mcpid);
  60.         mcpShown[playerid][mcpid] = false;
  61.         return 1;
  62. }
  63.  
  64. stock RemoveCheckpoint(mcpid)
  65. {
  66.         if(0 > mcpid > 29) return 0;
  67.         if(mcpParams[mcpid][mcpCreated] == 0) return 0;
  68.         for (new mcpSlots = GetMaxPlayers(), mcpi; mcpi < mcpSlots; mcpi++)
  69.         {
  70.                 if(!IsPlayerConnected(mcpi)) continue;
  71.                 mcpShown[mcpi][mcpid] = false;
  72.                 RemovePlayerMapIcon(mcpi, mcpid);
  73.         }
  74.         mcpParams[mcpid][mcpCreated] = 0;
  75.         return 1;
  76. }
  77.  
  78. stock IsCreated(mcpid)
  79. {
  80.         if(0 > mcpid > 29) return 0;
  81.         if(mcpParams[mcpy][mcpCreated] == true) return 1;
  82.         return 0;
  83. }
  84.  
  85. public mcpCheck() //mcpi = Players      || mcpy = checkpoints
  86. {
  87.         for (new mcpSlots = GetMaxPlayers(), mcpi; mcpi < mcpSlots; mcpi++)
  88.         {
  89.                 if(!IsPlayerConnected(mcpi)) continue;
  90.                 for (new mcpy = 0; mcpy < 30; mcpy++)
  91.                 {
  92.                         if(mcpShown[mcpi][mcpy] == false) continue;
  93.                         if(mcpParams[mcpy][mcpCreated] == false) continue;
  94.                         if(IsPlayerInRangeOfPoint(mcpi, 1.0, mcpParams[mcpy][mcpX], mcpParams[mcpy][mcpY], mcpParams[mcpy][mcpZ]) && mcpEntered[mcpi][mcpy] == false)
  95.                         {
  96.                                 mcpEntered[mcpi][mcpy] = true;
  97.                                 CallLocalFunction("OnPlayerEnterCheckPointEx", "ii", mcpi, mcpy);
  98.                                 continue;
  99.                         }
  100.                         else if(!IsPlayerInRangeOfPoint(mcpi, 1.0, mcpParams[mcpy][mcpX], mcpParams[mcpy][mcpY], mcpParams[mcpy][mcpZ]) && mcpEntered[mcpi][mcpy] == true) mcpEntered[mcpi][mcpy] = false;             
  101.                 }
  102.         }
  103. }
clone this paste RAW Paste Data