SA-MP Forums Archive
How to make something like this - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make something like this (/showthread.php?tid=263486)



How to make something like this - Kitten - 22.06.2011

Solved


Re: How to make something like this - Calgon - 22.06.2011

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;
}



Re: How to make something like this - [BP]Tony - 22.06.2011

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!!


AW: How to make something like this - Nero_3D - 22.06.2011

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