28.02.2014, 19:16
Hello. I have a problem showing markers. Everything works fine, but sometimes all player markers become the same (same color). So maybe anyone knows what is the problem. Here is the code
Function UpdateMarkes is called every 1 second with timer. There is no other code which uses marker command
pawn Код:
public OnPlayerStreamIn(playerid, forplayerid)
{
if(SI[Started] > 0)
{
if(PI[InRound][playerid] == 1)
{
if(GetPlayerTeam(forplayerid) == TEAM_C)
{
if(IsPaused[playerid] == 0)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,false));
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
}
else
{
if(GetPlayerTeam(forplayerid) == GetPlayerTeam(playerid))
{
if(UsedSpotted[playerid] == 0)
{
if(IsPaused[playerid] == 0)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,false));
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
}
else
{
if(IsPaused[playerid] == 0)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_WHITE );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
}
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
else
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK & 0xFFFFFF00 );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,true) );
}
new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
GetPlayerPos(forplayerid,PX,PY,PZ);
GetPlayerPos(playerid, X,Y,Z);
new Float:Distance;
Distance = floatsqroot((PX-X)*(PX-X)+(PY-Y)*(PY-Y)+(PZ-Z)*(PZ-Z));
if(Distance < 40)
{
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
else
{
ShowPlayerNameTagForPlayer(forplayerid,playerid,0);
}
}
}
}
else
{
if(PI[InDM][playerid] == 0)
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_LOBBY );
}
}
else
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_WHITE );
}
}
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
}
else
{
if(PI[InDM][playerid] == 0)
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,false) );
}
}
else
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_WHITE );
}
}
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
return 1;
}
function UpdateMarkers()
{
ForEach(forplayerid,MAX_SLOTS)
{
if(PI[InRound][forplayerid] == 1)
{
SetPlayerVirtualWorld(forplayerid,10);
}
ForEach(playerid,MAX_SLOTS)
{
if(SI[Started] > 0)
{
if(PI[InRound][playerid] == 1)
{
if(GetPlayerTeam(forplayerid) == TEAM_C)
{
if(IsPaused[playerid] == 0)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,false));
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
}
else
{
if(GetPlayerTeam(forplayerid) == GetPlayerTeam(playerid))
{
if(UsedSpotted[playerid] == 0)
{
if(IsPaused[playerid] == 0)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,false));
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
}
else
{
if(IsPaused[playerid] == 0)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_WHITE );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
}
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
else
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK & 0xFFFFFF00 );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,true) );
}
new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
GetPlayerPos(forplayerid,PX,PY,PZ);
GetPlayerPos(playerid, X,Y,Z);
new Float:Distance;
Distance = floatsqroot((PX-X)*(PX-X)+(PY-Y)*(PY-Y)+(PZ-Z)*(PZ-Z));
if(Distance < 40)
{
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
else
{
ShowPlayerNameTagForPlayer(forplayerid,playerid,0);
}
}
}
}
else
{
if(PI[InDM][playerid] == 0)
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_LOBBY );
}
}
else
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_WHITE );
}
}
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
}
else
{
if(PI[InDM][playerid] == 0)
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, GetTeamColor(playerid,false) );
}
}
else
{
if(IsPaused[playerid] == 1)
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_AFK );
}
else
{
SetPlayerMarkerForPlayer( forplayerid, playerid, COLOR_WHITE );
}
}
ShowPlayerNameTagForPlayer(forplayerid,playerid,1);
}
}
}
return 1;
}
function GetTeamColor(playerid,bool:alpha)
{
if(alpha == false)
{
switch (GetPlayerTeam(playerid))
{
case TEAM_A:
{
return COLOR_A;
}
case TEAM_B:
{
return COLOR_B;
}
case TEAM_C:
{
return COLOR_C;
}
}
}
else
{
switch (GetPlayerTeam(playerid))
{
case TEAM_A:
{
return 0xEE292900;
}
case TEAM_B:
{
return 0x0055FF00;
}
case TEAM_C:
{
return 10027263;
}
}
}
return COLOR_LOBBY;
}