help with small code
#1

Just because I'm awful at finding small errors, can anyone tell me what's wrong with the following code..
pawn Код:
new pTeam = GetPlayerTeam(playerid);
    foreach(Player, i)
    {
        if(GetPlayerTeam(i) != pTeam)
        {
            SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
            SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));
        }
        else
        {
            SetPlayerMarkerForPlayer(playerid, i, GetPlayerColor(playerid));
            SetPlayerMarkerForPlayer(i, playerid, GetPlayerColor(i));
        }
    }
I don't get any errors or anything but the purpose of the code is failing. It's supposed to show players in the radar only if they're in the same team.

Thanks in advance.
Reply
#2

Make it a stock.
Reply
#3

I am not sure what's wrong but try this:
pawn Код:
new pTeam = GetPlayerTeam(playerid);
    for(new i =0; i < MAX_PLAYERS;i++)
   {
   if(IsPlayerConnected(i))
    {
        if(GetPlayerTeam(i) == pTeam)
        {
            SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
            SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));
        }
        else
        {
            SetPlayerMarkerForPlayer(playerid, i, GetPlayerColor(playerid));
            SetPlayerMarkerForPlayer(i, playerid, GetPlayerColor(i));
        }
    }
}
Reply
#4

pawn Код:
foreach(Player, i)
    {
        if(GetPlayerTeam(i) != pTeam)
        {
          SetPlayerMarkerForPlayer(playerid, i, GetPlayerColor(playerid));
            SetPlayerMarkerForPlayer(i, playerid, GetPlayerColor(i));
        }
        else
        {
             SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
            SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));
        }
    }
Try this.
Reply
#5

Quote:
Originally Posted by MD5
Посмотреть сообщение
Make it a stock.
I don't see how that would fix the code
I'm using it OnPlayerSpawn.
Quote:
Originally Posted by Eth
Посмотреть сообщение
I am not sure what's wrong but try this:
pawn Код:
new pTeam = GetPlayerTeam(playerid);
    for(new i =0; i < MAX_PLAYERS;i++)
   {
   if(IsPlayerConnected(i))
    {
        if(GetPlayerTeam(i) == pTeam)
        {
            SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
            SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));
        }
        else
        {
            SetPlayerMarkerForPlayer(playerid, i, GetPlayerColor(playerid));
            SetPlayerMarkerForPlayer(i, playerid, GetPlayerColor(i));
        }
    }
}
I don't think foreach is the problem and this "if(GetPlayerTeam(i) == pTeam)" is wrong because that would make players in the same team invisible in the radar, won't it?
Quote:
Originally Posted by Abagail
Посмотреть сообщение
pawn Код:
foreach(Player, i)
    {
        if(GetPlayerTeam(i) != pTeam)
        {
          SetPlayerMarkerForPlayer(playerid, i, GetPlayerColor(playerid));
            SetPlayerMarkerForPlayer(i, playerid, GetPlayerColor(i));
        }
        else
        {
             SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
            SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));
        }
    }
That would make the enemy visible in the radar

Just to clear up, what I want is for only players in the same team to be visible in the radar. Enemies will be invisible.

But thanks all for trying to help, really appreciate it
Reply
#6

try this:
pawn Код:
foreach(Player, i)
    {
        if(GetPlayerTeam(i) == pTeam)
        {
          SetPlayerMarkerForPlayer(playerid, i, GetPlayerColor(playerid));
            SetPlayerMarkerForPlayer(i, playerid, GetPlayerColor(i));
        }
        else
        {
             SetPlayerMarkerForPlayer(playerid, i,0xFFFFFF00);
             SetPlayerMarkerForPlayer(i, playerid,0xFFFFFF00);
        }
    }
I never give up!
also it should be == pTeam not !+ pteam because at the else it will set the color of the player to 0xFFFFFF00 which is invisible try it and tell me if it worked

Second Edit: just for Curiosity What is the GM you are making now??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)