How to make something like this
#1

Solved
Reply
#2

Assuming you want to just use OnPlayerEnterCheckpoint, you could track a variable which determine what checkpoint number they're at, and in the callback you could perform a loop to see who is at or has passed that checkpoint, then add up a number of players who've passed the checkpoint already, and +1 to that number, then that should be their place?

pawn Код:
#include <a_samp>
#include <foreach>

main() {
}

new
    PlayerRace[MAX_PLAYERS], // so you can have multiple races at once
    PlayerRaceCheckpoint[MAX_PLAYERS];


public OnPlayerEnterCheckpoint(playerid) {
    if(PlayerRace[playerid] > 0) {
        PlayerRaceCheckpoint[playerid]++;
       
       
        new
            iCount;
           
        foreach(Player, i) {
            if(PlayerRaceCheckpoint[i] >= PlayerRaceCheckpoint[playerid])
                iCount++;
        }
       
        // iCount holds the position that they're in.
    }
    return 1;
}

stock initRace(playerid) {
    // do whatever checks you need here.
    PlayerRace[playerid] = 1; // raceid, you might want to fiddle around with this
    PlayerRaceCheckpoint[playerid] = 0;
}
Reply
#3

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
Assuming you want to just use OnPlayerEnterCheckpoint, you could track a variable which determine what checkpoint number they're at, and in the callback you could perform a loop to see who is at or has passed that checkpoint, then add up a number of players who've passed the checkpoint already, and +1 to that number, then that should be their place?

pawn Код:
#include <a_samp>
#include <foreach>

main() {
}

new
    PlayerRace[MAX_PLAYERS], // so you can have multiple races at once
    PlayerRaceCheckpoint[MAX_PLAYERS];


public OnPlayerEnterCheckpoint(playerid) {
    if(PlayerRace[playerid] > 0) {
        PlayerRaceCheckpoint[playerid]++;
       
       
        new
            iCount;
           
        foreach(Player, i) {
            if(PlayerRaceCheckpoint[i] >= PlayerRaceCheckpoint[playerid])
                iCount++;
        }
       
        // iCount holds the position that they're in.
    }
    return 1;
}

stock initRace(playerid) {
    // do whatever checks you need here.
    PlayerRace[playerid] = 1; // raceid, you might want to fiddle around with this
    PlayerRaceCheckpoint[playerid] = 0;
}
Right!!
Reply
#4

I think it should be like that

pawn Код:
//OnPlayerEnterCheckpoint
        new
            iCount;
           
        foreach(Player, i) {
            if(PlayerRaceCheckpoint[i] >= PlayerRaceCheckpoint[playerid])
                iCount++;
        }

        PlayerRaceCheckpoint[playerid]++;
since the players who already had this checkpoint are before him

For a real time update you would need to use an timer with distance checks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)