SA-MP Forums Archive
[Help] - SetPlayerMarkerForPlayer - 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)
+--- Thread: [Help] - SetPlayerMarkerForPlayer (/showthread.php?tid=339107)



[Solved] - SetPlayerMarkerForPlayer - Ritz - 02.05.2012

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?


Re: [Help] - SetPlayerMarkerForPlayer - Face9000 - 02.05.2012

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


Re: [Help] - SetPlayerMarkerForPlayer - MadeMan - 02.05.2012

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.


Re: [Help] - SetPlayerMarkerForPlayer - Ritz - 02.05.2012

Thanks MadeMan, that works just fine

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