[Help] - SetPlayerMarkerForPlayer
#1

Hello, so I got this code:

pawn Код:
public OnPlayerSpawn(playerid)
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if(team[playerid] == team[i])
            {
                SetPlayerMarkerForPlayer( playerid, i, GetPlayerColor(i) );
                SetPlayerMarkerForPlayer( i, playerid, GetPlayerColor(playerid) );
            }
            else
            {
                SetPlayerMarkerForPlayer( playerid, i, ( GetPlayerColor( i ) & 0xFFFFFF00 ) );
                SetPlayerMarkerForPlayer( i, playerid, ( GetPlayerColor( playerid ) & 0xFFFFFF00 ) );
            }
        }
    }
    return 1;
}
And it should work like this:
When a player spawns, it loops through all connected players and checks if they are on the same team or in different teams.
If they are on the same team, it sets the player markers to show normally for each other. If they are on different teams, it sets the markers invisible for each other (got that code from here).

However this is working weirdly, when a player spawns he usually can see everyone (even from the opposite team), then when a player dies and respawns he can't see the enemy team any more but everyone on the enemy team can see him, then if he kills someone he can only see that person.

Can anyone help me and tell me what am I doing wrong here?
Reply
#2

Why u're using "playerid" in SetPlayerMarkerForPlayer when u're using a loop?
Reply
#3

AFAIK SetPlayerMarkerForPlayer doesn't work in OnPlayerSpawn, but you can use a timer

pawn Код:
public ShowTeamMarkers(playerid)
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if(team[playerid] == team[i])
            {
                SetPlayerMarkerForPlayer( playerid, i, GetPlayerColor(i) );
                SetPlayerMarkerForPlayer( i, playerid, GetPlayerColor(playerid) );
            }
            else
            {
                SetPlayerMarkerForPlayer( playerid, i, ( GetPlayerColor( i ) & 0xFFFFFF00 ) );
                SetPlayerMarkerForPlayer( i, playerid, ( GetPlayerColor( playerid ) & 0xFFFFFF00 ) );
            }
        }
    }
}
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("ShowTeamMarkers", 1000, false, "d", playerid);
    return 1;
}
Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Why u're using "playerid" in SetPlayerMarkerForPlayer when u're using a loop?
It's used correctly.
Reply
#4

Thanks MadeMan, that works just fine

Just had no idea that it doesn't work in OnPlayerSpawn.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)