Advertisement
Guest User

Checkpoint Streamer V0.2

a guest
Aug 19th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.15 KB | None | 0 0
  1. // === Checkpoint Streamer V0.2 === //
  2. // === Released on SA-MP forum only: === //
  3. // === http://forum.sa-mp.com/showthread.php?t=354636 === //
  4. // === Credits to Oplosthee, SKAzini & [HiC]TheKiller === //
  5. #define FILTERSCRIPT
  6. #include <a_samp>
  7.  
  8. new SendMsg[MAX_PLAYERS];
  9. forward CheckpointCheck();
  10.  
  11. stock Float:GetDistanceToPoint(playerid, Float:X2, Float:Y2, Float:Z2)
  12. {
  13.     new Float:X, Float:Y, Float:Z;
  14.     GetPlayerPos(playerid, X, Y, Z);
  15.     return floatsqroot ( floatpower ( floatabs ( floatsub ( X , X2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Y , Y2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Z , Z2 ) ) , 2 ) );
  16. }
  17. public OnFilterScriptInit()
  18. {
  19.     printf("\nSKAzini/Oplosthee's CP Streamer has been loaded. Version: 0.2.\n");
  20.     SetTimer("CheckpointCheck", 500, 1);
  21.     return 1;
  22. }
  23. public OnPlayerConnect(playerid)
  24. {
  25.     SendMsg[playerid] = 1;
  26.     return 1;
  27. }
  28. public OnPlayerEnterCheckpoint(playerid)
  29. {
  30.     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
  31.     {
  32.         if(SendMsg[playerid] == 1)
  33.         {
  34.             SendMsg[playerid] = 0;
  35.             SendClientMessage(playerid, 0xFFFFFFAA, "You reached a checkpoint.");//message when standing in a checkpoint
  36.         }
  37.     }
  38.     if(GetDistanceToPoint(playerid, 2030, 1342, 10)<=2)
  39.     {
  40.         if(SendMsg[playerid] == 1)
  41.         {
  42.             SendMsg[playerid] = 0;
  43.             SendClientMessage(playerid, 0xFFFFFFAA, "You reached a checkpoint.");
  44.         }
  45.     }
  46.     return 1;
  47. }
  48. public CheckpointCheck()
  49. {
  50.     for(new i; i<MAX_PLAYERS; i++)// a loop that goes though all players
  51.     {
  52.         if(IsPlayerConnected(i))//checks if the player is connected
  53.         {
  54.             if(GetDistanceToPoint(i, 2096, 1287, 10) <= 30) //change 10 to what ever you want the "view distance" to be.
  55.             {
  56.                 SetPlayerCheckpoint(i, 2096, 1287, 10, 2);//Change 2 to what ever radius you want (of the checkpoint)
  57.             }
  58.             else if(GetDistanceToPoint(i, 2030, 1342, 10) <= 30)
  59.             {
  60.                 SetPlayerCheckpoint(i, 2030, 1342, 10, 2);
  61.             }
  62.             else
  63.             {
  64.                 DisablePlayerCheckpoint(i);
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement