18.02.2018, 03:56
There you code wrote more cleanly
PHP код:
CMD:pl(playerid, params[])
{
new ofplayerid;
if(sscanf(params, "u", ofplayerid))
return SendClientMessage(playerid,COLOR_RED,"[Error] Player Not Connected");
if(!IsPlayerConnected(ofplayerid))
return SendClientMessage(playerid,COLOR_RED,"[Error] Not an valid player");
if(ofplayerid == playerid)
{
if(g_LABEL_MODE[playerid] == MODE_DISABLED)//enable labels
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerConnected(i))
{
if(i != ofplayerid)
{
CreatePlayerLabel(playerid, i);
}
}
}
g_LABEL_MODE[playerid] = MODE_ENABLED;
}
else//disable labels
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
DestroyPlayerLabel(playerid, i);
}
g_LABEL_MODE[playerid] = MODE_DISABLED;
}
}
else
{
//destroy all labels first
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
DestroyPlayerLabel(playerid, i);
}
CreatePlayerLabel(playerid, ofplayerid);
g_LABEL_MODE[playerid] = MODE_SINGLE_PLAYER;//enable labels
}
return 1;
}