Advertisement
AshBFunky

Checkpoint Management (v2)

Dec 24th, 2011
1,427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.94 KB | None | 0 0
  1. #if defined CP_INCLUDED__
  2.     #error You have already included the CP Managment system elsewhere in this script.
  3. #endif
  4. #define CP_INCLUDED__
  5.  
  6. stock __SetPlayerCheckpoint(playerid, Float:cx, Float:cy, Float:cz, Float:size) //Creates the checkpoint
  7. {
  8.     SetPVarFloat(playerid, "CP_x", cx); SetPVarFloat(playerid, "CP_y", cy); SetPVarFloat(playerid, "CP_z", cz); SetPVarFloat(playerid, "CP_size", size);
  9.     SetPVarInt(playerid, "CP_en", 1);
  10.     SetPlayerCheckpoint(playerid, cx, cy, cz, size);
  11.     return 1;
  12. }
  13.  
  14. stock __DisablePlayerCheckpoint(playerid) //Disables the checkpoint
  15. {
  16.     if(GetPVarInt(playerid, "CP_en") != 1) return 0;
  17.     DeletePVar(playerid, "CP_x"); DeletePVar(playerid, "CP_y"); DeletePVar(playerid, "CP_z"); DeletePVar(playerid, "CP_size");
  18.     DisablePlayerCheckpoint(playerid);
  19.     SetPVarInt(playerid, "CP_en", 0);
  20.     return 1;
  21. }
  22.  
  23. #define SetPlayerCheckpoint __SetPlayerCheckpoint
  24. #define DisablePlayerCheckpoint __DisablePlayerCheckpoint
  25.  
  26. stock GetPlayerCheckpointPos(playerid, &Float:__x, &Float:__y, &Float:__z) //Return the checkpoint co-ordinates
  27. {
  28.     if(GetPVarInt(playerid, "CP_en") != 1) return 0;
  29.     __x = GetPVarFloat(playerid, "CP_x");
  30.     __y = GetPVarFloat(playerid, "CP_y");
  31.     __z = GetPVarFloat(playerid, "CP_z");
  32.     return 1;
  33. }
  34.  
  35. stock GetPlayerCheckpointSize(playerid, &Float:__size) //Return the checkpoint size
  36. {
  37.     if(GetPVarInt(playerid, "CP_en") != 1) return 0;
  38.     __size = GetPVarFloat(playerid, "CP_size");
  39.     return 1;
  40. }
  41.  
  42. stock IsPlayerInRangeOfCheckpoint(playerid, Float:range) //Are they in range of the checkpoint?
  43. {
  44.     if(GetPVarInt(playerid, "CP_en") != 1) return -1;
  45.     if(IsPlayerInRangeOfPoint(playerid, range, GetPVarFloat(playerid, "CP_x"), GetPVarFloat(playerid, "CP_y"), GetPVarFloat(playerid, "CP_z")) return 1;
  46.     return 0;
  47. }
  48.  
  49. stock IsPlayerInOthersCheckpoint(playerid, playerid2) //Are they in another players checkpoint (Cheeky little player)
  50. {
  51.     if(GetPVarInt(playerid2, "CP_en") != 1) return -1;
  52.     if(IsPlayerInRangeOfPoint(playerid, GetPVarFloat(playerid2, "CP_size"), GetPVarFloat(playerid2, "CP_x"), GetPVarFloat(playerid2, "CP_y"), GetPVarFloat("CP_z")) return 1;
  53.     return 0;
  54. }
  55.  
  56. stock SetPlayerCPAsPlayerCP(playerid, setplayerid) //Change a players checkpoint to another players
  57. {
  58.     if(GetPVarInt(playerid, "CP_en") != 1) return -1;
  59.     SetPlayerCheckpoint(setplayerid, GetPVarFloat(playerid, "CP_x"), GetPVarFloat(playerid, "CP_y"), GetPVarFloat(playerid, "CP_z"), GetPVarFloat(playerid, "CP_size"));
  60.     return 1;
  61. }
  62.  
  63. stock Float:GetDistanceToPlayerCheckpoint(playerid) //Get a distance to the checkpoint
  64. {
  65.     if(GetPVarInt(playerid, "CP_en") != 1) return -1.0;
  66.     return GetPlayerDistanceFromPoint(playerid, GetPVarFloat(playerid, "CP_x"), GetPVarFloat(playerid, "CP_y"), GetPVarFloat(playerid, "CP_z"));
  67. }
  68.  
  69. stock CreateCheckpointHere(playerid, Float:size) //Not sure what this'd be used for though
  70. {
  71.     new Float:x_, Float:y_, Float:z_;
  72.     GetPlayerPos(playerid, x_, y_, z_);
  73.     SetPlayerCheckpoint(playerid, x_, y_, z_, size);
  74.     return 1;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement