SA-MP Forums Archive
If playerid = 0, setplayerpos? READ! - 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: If playerid = 0, setplayerpos? READ! (/showthread.php?tid=175228)



If playerid = 0, setplayerpos? READ! - thomas.. - 08.09.2010

Ok, so say a race started. Player id 0 would get teleported to 1 place and id 1 the next and id 2 another place ect. My friend made one but it gave errors so i deleted it. Example thx?


Re: If playerid = 0, setplayerpos? READ! - Conroy - 08.09.2010

This will choose as many players as the array size starting from ID 0 upwards.

pawn Код:
new StartingPositions[10]; //10 positions (change to match your needs...)
new PlayerStartingPosID[MAX_PLAYERS];
for(new i; i <= MAX_PLAYERS; i++)
{
    PlayerStartingPosID[i] = -1;
    if(IsPlayerConnected(i)) {
        if(PlayerStartingPosID[i] == -1) {
            for(new startingpos; startingpos <= sizeof(StartingPositions)) {
                if(!StartingPositions[startingpos] && PlayerStartingPosID[i] == -1) StartingPositions[startingpos]++, PlayerStartingPosID[i] = startingpos;
            }
        }
    }
}

//Then simply... (in another function, otherwise change i to something else)
for(new i; i <= MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i)) {
        if(PlayerStartingPosID[i] != -1) {
//SetPlayerPos(...) Use PlayerStartingPosID[i] to get the starting ID then assign the player to the coordinates.
        }
    }
}