SKAzini

Checkpoint Streamer V0.1

Jun 27th, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.12 KB | None | 0 0
  1. // === Checkpoint Streamer V0.1 === //
  2. // === Credits to Oplosthee (Omni), SKAzini & [HiC]TheKiller === //
  3. #define FILTERSCRIPT
  4. #include <a_samp>
  5.  
  6. forward CheckpointCheck();
  7.  
  8. stock Float: GetDistanceToPoint(playerid,Float: X2,Float:Y2 ,Float: Z2)
  9. {
  10.     new Float:X,Float:Y,Float:Z;
  11.     GetPlayerPos(playerid,X,Y,Z);
  12.     return floatsqroot ( floatpower ( floatabs ( floatsub ( X , X2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Y , Y2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Z , Z2 ) ) , 2 ) );
  13. }
  14.  
  15. new SendMsg[MAX_PLAYERS];
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.     printf("\nCheckpoint Streamer by Oplosthee has been loaded\n");
  20.     SetTimer("CheckpointCheck",500,1);
  21.     return 1;
  22. }
  23.  
  24. public OnPlayerConnect(playerid)
  25. {
  26.  
  27.     SendMsg[playerid] = 1;
  28.     return 1;
  29. }
  30.  
  31. public OnPlayerEnterCheckpoint(playerid)
  32. {
  33.     if(GetDistanceToPoint(playerid,2096, 1287, 10)<=2)//the same X,Y,Z coords as the ones you put into the timer || the 2 should be your checkpoint radius
  34.     {
  35.         if(SendMsg[playerid] == 1)
  36.         {
  37.             SendMsg[playerid] = 0;
  38.             SendClientMessage(playerid, 0xFFFFFFAA, "You reached a checkpoint.");
  39.         }
  40.         if(GetDistanceToPoint(playerid,2030, 1342, 10)<=2)//the same X,Y,Z coords as the ones you put into the timer || the 2 should be your checkpoint radius
  41.     {
  42.         if(SendMsg[playerid] == 1)
  43.         {
  44.             SendMsg[playerid] = 0;
  45.             SendClientMessage(playerid, 0xFFFFFFAA, "You reached a checkpoint.");
  46.         }
  47.     }
  48.         return 1;
  49.     }
  50.     return 1;
  51. }
  52.     public CheckpointCheck()
  53.     {
  54.   for(new i; i<MAX_PLAYERS; i++)// a loop that goes though all players
  55.   {
  56.     if(IsPlayerConnected(i))//checks if the player is connected
  57.     {
  58.         if(GetDistanceToPoint(i, 2096, 1287, 10)<=30) //change 10 to what ever you want the "view distance" to be.
  59.         {
  60.             SetPlayerCheckpoint(i, 2096, 1287, 10, 2);//Change 2 to what ever radius you want (of the checkpoint)  
  61.         }
  62.         else if(GetDistanceToPoint(i, 2030, 1342, 10)<=30)
  63.         {
  64.             SetPlayerCheckpoint(i, 2030, 1342, 10, 2);
  65.         }
  66.         else
  67.         {
  68.           DisablePlayerCheckpoint(i);
  69.         }
  70.   }
  71. }
  72. }
Add Comment
Please, Sign In to add comment