Guest User

Checkpoint Streamer V0.3

a guest
Sep 22nd, 2012
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.08 KB | None | 0 0
  1. // === Checkpoint Streamer V0.3 === //
  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.  
  6. #define FILTERSCRIPT
  7. #include <a_samp>
  8.  
  9. new bool:CPMsg[MAX_PLAYERS];
  10. forward CPCheck();
  11.  
  12. stock Float:GetDistanceToPoint(playerid, Float:X2, Float:Y2, Float:Z2) {
  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.     printf("\nSKAzini/Oplosthee's CP Streamer has been loaded. Version: 0.3.\n");
  19.     SetTimer("CPCheck", 500, 1);
  20.     return 1;
  21. }
  22. public OnPlayerConnect(playerid) {
  23.     CPMsg[playerid] = true;
  24.     return 1;
  25. }
  26. public OnPlayerEnterCheckpoint(playerid) {
  27.     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
  28.         if(CPMsg[playerid] == true) {
  29.             CPMsg[playerid] = false;
  30.             SendClientMessage(playerid, 0xFFFFFFAA, "You reached a checkpoint.");//message when standing in a checkpoint
  31.         }
  32.     }
  33.     if(GetDistanceToPoint(playerid, 2030, 1342, 10)<=2) {
  34.         if(CPMsg[playerid] == true) {
  35.             CPMsg[playerid] = false;
  36.             SendClientMessage(playerid, 0xFFFFFFAA, "You reached a checkpoint.");
  37.         }
  38.     }
  39.     return 1;
  40. }
  41. public CPCheck() {
  42.     for(new i; i < MAX_PLAYERS; i++) {// a loop that goes through all player
  43.         if(IsPlayerConnected(i)) {//checks if the player is connected
  44.             if(GetDistanceToPoint(i, 2096, 1287, 10) <= 30) {//change 10 to whatever you want the "view distance" to be.
  45.                 SetPlayerCheckpoint(i, 2096, 1287, 10, 2);//Change 2 to whatever radius you want (of the checkpoint)
  46.             }
  47.             else if(GetDistanceToPoint(i, 2030, 1342, 10) <= 30) {
  48.                 SetPlayerCheckpoint(i, 2030, 1342, 10, 2);
  49.             }
  50.             else {
  51.                 DisablePlayerCheckpoint(i);
  52.             }
  53.         }
  54.     }
  55. }
Add Comment
Please, Sign In to add comment