CMD:pl(playerid, params[])
{
new ofplayerid;
if(IsNumeric1(params))
{
ofplayerid = strval(params);
if(!IsPlayerConnected(ofplayerid)) return SendClientMessage(playerid,COLOR_RED,"[Error] Player Not Connected");
}
else
{
ofplayerid = INVALID_PLAYER_ID;
SendClientMessage(playerid,COLOR_RED,"[Error] Not an valid player");
}
if( IsPlayerConnected(ofplayerid) && ofplayerid != playerid)
{
//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
}
else
{
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;
}
}
return 1;
}
CMDl(playerid, params[]) { new targetid = playerid; if(!sscanf(params, "u", targetid)) { if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"Player is not connected."); if(IsPlayerConnected(targetid) && targetid != playerid) { for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) { DestroyPlayerLabel(playerid, i); } CreatePlayerLabel(playerid, targetid); g_LABEL_MODE[playerid] = MODE_SINGLE_PLAYER; } } else { SendClientMessage(playerid, COLOR_BLUE, "* /pl [ID] to view another player's pl."); targetid = playerid; if(g_LABEL_MODE[playerid] == MODE_DISABLED) { CreatePlayerLabel(playerid, targetid); g_LABEL_MODE[playerid] = MODE_ENABLED; } else { for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) { DestroyPlayerLabel(playerid, i); } g_LABEL_MODE[playerid] = MODE_DISABLED; } } return 1; } |
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;
}
Just a couple of things Dayrion, IsPlayerConnected(); is useless since it checks players connected.
|