Checkpoints
#8

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
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
Ok, thank you
Reply


Messages In This Thread
Checkpoints - by sim_sima - 16.05.2011, 14:36
Re: Checkpoints - by sim_sima - 16.05.2011, 15:02
Re: Checkpoints - by sim_sima - 16.05.2011, 15:15
Re: Checkpoints - by Cjgogo - 16.05.2011, 15:20
Re: Checkpoints - by sim_sima - 16.05.2011, 15:21
Re: Checkpoints - by sim_sima - 16.05.2011, 15:25
AW: Checkpoints - by Nero_3D - 16.05.2011, 15:37
Re: AW: Checkpoints - by sim_sima - 16.05.2011, 15:41

Forum Jump:


Users browsing this thread: 2 Guest(s)