Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Reply Nero_3D
- Checkpoint System (ColdXX)
- forum.sa-mp.com/showthread.php?t=183014
- */
- //Global
- new gPlayerCheckpointStatus[MAX_PLAYERS] = {-1, ...}; //a streamer will break this code!
- enum //Just add checkpoint names here
- {
- CP_GOLD,
- CP_WEAPON,
- CP_ARMOUR
- }
- //OnGameModeInit
- SetTimer("Checkpoints", (10 * 60 * 1000), true); //To heavy calculation for me :p
- //Somewhere outside
- forward Checkpoints();
- public Checkpoints()
- {
- SetTreasureCheckpoint(); //will set a random checkpoint, enter an id for specific
- GameTextForAll("~w~A new ~r~checkpoint ~w~~n~has been set!", 5000, 5);
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- switch(gPlayerCheckpointStatus[playerid])
- {
- case CP_GOLD:
- {
- new string[64], money = 2500 + (random(2500) * random(4));
- GetPlayerName(playerid, string, MAX_PLAYER_NAME);
- format(string, sizeof string, "~r~%s ~y~found some gold bars (worth ~r~$%d~y~)", string);
- GivePlayerMoney(playerid, money);
- GameTextForAll(string, 10000, 4);
- DisableCheckpointForAll(); //Disabling all again
- }
- case CP_WEAPON: {}
- case CP_ARMOUR: {}
- default: {} //All other undefined checkpoints
- }
- return 1;
- }
- stock SetTreasureCheckpoint(id = random(3))
- {
- switch(id)
- {
- case 0: SetCheckpointForAll(CP_GOLD, -86.0255, 2263.1226, 125.4201, 15.0);
- case 1: SetCheckpointForAll(CP_WEAPON, -940.3776, 2642.0669, 42.3634, 15.0);
- case 2: SetCheckpointForAll(CP_ARMOUR, -822.9805, -658.0743, 127.3115, 15.0);
- }
- }
- stock SetCheckpointForAll(id, Float:cx, Float:cy, Float:cz, Float:csize)
- {
- for(new i; i != MAX_PLAYERS; i++)
- {
- SetPlayerCheckpoint(i, cx, cy, cz, csize);
- gPlayerCheckpointStatus[i] = id;
- }
- }
- stock DisableCheckpointForAll()
- {
- for(new i; i != MAX_PLAYERS; i++)
- {
- DisablePlayerCheckpoint(i);
- gPlayerCheckpointStatus[i] = -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment