At first lets define some checkpoints
pawn Код:
enum {
CP_SPAWN,
CP_COMMAND
}
Than we create our own SetPlayerCheckpoint function with ids
pawn Код:
stock SetPlayerCheckpointEx(playerid, checkpointid, Float: x, Float: y, Float: z, Float: size)
{
if(SetPlayerCheckpoint(playerid, x, y, z, size)) {
SetPVarInt(playerid, "checkpointid", checkpointid);
return true;
}
return false;
}
stock DisablePlayerCheckpointEx(playerid)
{
if(GetPVarInt(playerid, "checkpointid") && DisablePlayerCheckpoint(playerid)) {
DeletePVar(playerid, "checkpointid");
return true;
}
return false;
}
// \/ Tells the compiler that DisablePlayerCheckpoint will be replaced with DisablePlayerCheckpointEx
#define DisablePlayerCheckpoint DisablePlayerCheckpointEx
pawn Код:
//OnPlayerSpawn as example
SetPlayerCheckpointEx(playerid, CP_SPAWN, 0.0, 0.0, 0.0, 5.0);
//in some command
SetPlayerCheckpointEx(playerid, CP_COMMAND, 0.0, 0.0, 0.0, 5.0);
And now at the end we can check what checkpoint the player is in
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
switch(GetPVarInt(playerid, "checkpointid")) {
case CP_SPAWN: {
}
case CP_COMMAND: {
}
}
return true;
}
A streamer does actually the same it just saves the checkpoint data and shows always the nearest