16.05.2011, 15:37
At first lets define some checkpoints
Than we create our own SetPlayerCheckpoint function with ids
And now at the end we can check what checkpoint the player is in
A streamer does actually the same it just saves the checkpoint data and shows always the nearest
pawn Код:
enum {
CP_SPAWN,
CP_COMMAND
}
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);
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
switch(GetPVarInt(playerid, "checkpointid")) {
case CP_SPAWN: {
}
case CP_COMMAND: {
}
}
return true;
}