SetPlayerPos for all player
#1

hi,

After a round has ended the spawnpoints of the player chage (map chages).
I pasted my code.
The problem is that only one player is teleported.
But every single player in the server should be teleported to the new maps position.

pawn Код:
public Restart(playerid,classid) //this is a timer wich is set after a round has endet
{

{
        switch (CurrentMode) //defines wich map is wich case
    {
        case 0: //map1
        {
    {
          switch (gTeam[playerid])
    {
        case 1: //new spawnpoints of team1
        {
        new Spawn = random(sizeof(ModeTwoSpawnsPolice));//ForestCombat Spawnpoints
        SetPlayerPos(playerid,ModeTwoSpawnsPolice[Spawn][0],ModeTwoSpawnsPolice[Spawn][1],ModeTwoSpawnsPolice[Spawn][2]);
        SetPlayerFacingAngle(playerid,ModeTwoSpawnsPolice[Spawn][4]);
        Streamer_UpdateEx(playerid, ModeTwoSpawnsPolice[Spawn][0],ModeTwoSpawnsPolice[Spawn][1],ModeTwoSpawnsPolice[Spawn][2]);
        }

        case 2: //new spawnpoints of team2
        {
        new Spawn = random(sizeof(ModeTwoSpawnsBurner));
        SetPlayerPos(playerid,ModeTwoSpawnsBurner[Spawn][0],ModeTwoSpawnsBurner[Spawn][1],ModeTwoSpawnsBurner[Spawn][2]);
        SetPlayerFacingAngle(playerid,ModeTwoSpawnsBurner[Spawn][4]);
        Streamer_UpdateEx(playerid, ModeTwoSpawnsBurner[Spawn][0],ModeTwoSpawnsBurner[Spawn][1],ModeTwoSpawnsBurner[Spawn][2]);
        }
    }


}
I hope u can help me once again

regards.
Reply
#2

Make a loop through all players, then SetPlayerPos(i,x,y,z);
Reply
#3

could u show me how to do such a loop please
Reply
#4

pawn Код:
for(new i; i < MAX_PLAYERS; i++)
SetPlayerPos.
Reply
#5

thx for ur answer.
mhh, i know that i have to start a loop like this but i dontknow where to set it into my code

and i forgot, now the code is complete:

pawn Код:
//map1/////////////////////////////////////////////////////////////////////////////////
new Float:ModeTwoSpawnsPolice[6][5] = //team1 spawnpoints linked to the first code i posted
{
    {609.7040,-586.5684,17.2266,256.8267},
    {610.3588,-590.8182,17.2266,263.0453},
    {616.1186,-591.2390,17.2330,268.1367},
    {619.4320,-586.6706,17.2330,261.1437},
    {614.9709,-610.6100,17.2266,355.6629},
    {610.4255,-607.5670,17.2266,330.0057}

};

new Float:ModeTwoSpawnsBurner[6][5] = //team2 spawnpoints linked to the first code i posted
{
    {804.0115,-612.1152,16.3432,47.2465},
    {812.3744,-612.2579,16.3359,40.3489},
    {824.7153,-612.1229,16.3359,23.1518},
    {834.3637,-602.8866,16.3359,45.8388},
    {811.1272,-608.6595,16.3359,52.8724},
    {781.4649,-620.4591,16.3359,355.2838}

};
Reply
#6

Use
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
//ur codes here.
}
Reply
#7

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    Restart(i, classid)
}
Reply
#8

thanks
Stupid question:

1.Do i have to write that If is Player connected thing?
Wouldnt it also work without this code?

2.And do i have to destroy textdraws in OnGameModeExit?

regards.
Reply
#9

Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
thanks
Stupid question:

1.Do i have to write that If is Player connected thing?
Wouldnt it also work without this code?

2.And do i have to destroy textdraws in OnGameModeExit?

regards.
Yes, loop needs something to check, IsPlayerConnected will send a msg to all connected players, IsPlayerInRangeOfPoint(for example) will shend a msg only to ones who are in the radius
Reply
#10

could someone show me where exactly i have to write this loop into my code pls.
Cause ive tried it for so long and i just cant get it done
Ive posted my code, so id be very happy if u could show me how to do that.
Only 1 player gets teleported.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)