Guest User

Nero_3D / Checkpoint System

a guest
Oct 14th, 2010
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.03 KB | None | 0 0
  1. /*
  2.     Reply Nero_3D
  3.     Checkpoint System (ColdXX)
  4.     forum.sa-mp.com/showthread.php?t=183014
  5. */
  6.  
  7. //Global
  8. new gPlayerCheckpointStatus[MAX_PLAYERS] = {-1, ...}; //a streamer will break this code!
  9.  
  10. enum //Just add checkpoint names here
  11. {
  12.     CP_GOLD,
  13.     CP_WEAPON,
  14.     CP_ARMOUR
  15. }
  16.  
  17. //OnGameModeInit
  18. SetTimer("Checkpoints", (10 * 60 * 1000), true); //To heavy calculation for me :p
  19.  
  20. //Somewhere outside
  21. forward Checkpoints();
  22. public Checkpoints()
  23. {
  24.     SetTreasureCheckpoint(); //will set a random checkpoint, enter an id for specific
  25.     GameTextForAll("~w~A new ~r~checkpoint ~w~~n~has been set!", 5000, 5);
  26. }
  27.  
  28. public OnPlayerEnterCheckpoint(playerid)
  29. {
  30.     switch(gPlayerCheckpointStatus[playerid])
  31.     {
  32.         case CP_GOLD:
  33.         {
  34.             new string[64], money = 2500 + (random(2500) * random(4));
  35.             GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  36.             format(string, sizeof string, "~r~%s ~y~found some gold bars (worth ~r~$%d~y~)", string);
  37.             GivePlayerMoney(playerid, money);
  38.             GameTextForAll(string, 10000, 4);
  39.             DisableCheckpointForAll(); //Disabling all again
  40.         }
  41.         case CP_WEAPON: {}
  42.         case CP_ARMOUR: {}
  43.         default: {} //All other undefined checkpoints
  44.     }
  45.     return 1;
  46. }
  47.  
  48. stock SetTreasureCheckpoint(id = random(3))
  49. {
  50.     switch(id)
  51.     {
  52.         case 0: SetCheckpointForAll(CP_GOLD, -86.0255, 2263.1226, 125.4201, 15.0);
  53.         case 1: SetCheckpointForAll(CP_WEAPON, -940.3776, 2642.0669, 42.3634, 15.0);
  54.         case 2: SetCheckpointForAll(CP_ARMOUR, -822.9805, -658.0743, 127.3115, 15.0);
  55.     }
  56. }
  57.  
  58. stock SetCheckpointForAll(id, Float:cx, Float:cy, Float:cz, Float:csize)
  59. {
  60.     for(new i; i != MAX_PLAYERS; i++)
  61.     {              
  62.         SetPlayerCheckpoint(i, cx, cy, cz, csize);
  63.         gPlayerCheckpointStatus[i] = id;
  64.     }
  65. }
  66.  
  67. stock DisableCheckpointForAll()
  68. {
  69.     for(new i; i != MAX_PLAYERS; i++)
  70.     {              
  71.         DisablePlayerCheckpoint(i);
  72.         gPlayerCheckpointStatus[i] = -1;
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment