Hello, when i /spec off and i am on admin duty or PD duty i lose the stat i had.
Ex. I'm on admin duty and spec someone, i /spec off then i lose my admin duty color and 3d text label on my head (same with pd duty, i lose my PD duty color).
pawn Код:
CMD:spec(playerid, params[])
{
new playerb, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!strcmp(params, "off", true))
{
if(!Spec[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You aren't spectating anybody.");
Spec[playerid] = 0;
TogglePlayerSpectating(playerid, 0);
GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
SetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
SendClientMessage(playerid, COLOR_WHITE, " You have stopped spectating players.");
if(PlayerInfo[Specid[playerid]][pAdmin] >= PlayerInfo[playerid][pAdmin])
{
format(string, sizeof(string), "SpecWarn: %s has stopped spectating you.", RPN(playerid));
SendClientMessage(Specid[playerid], COLOR_DARKRED, string);
}
Specid[playerid] = -1;
return 1;
}
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [playerid]");
if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't spectate yourself.");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(Spec[playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is spectating someone.");
PlayerInfo[playerid][pModel] = GetPlayerSkin(playerid);
if(Specid[playerid] != -1 && PlayerInfo[Specid[playerid]][pAdmin] > PlayerInfo[playerid][pAdmin])
{
format(string, sizeof(string), "SpecWarn: %s has stopped spectating you.", RPN(playerid));
SendClientMessage(Specid[playerid], COLOR_DARKRED, string);
}
if(!Spec[playerid])
{
PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
GetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
}
Specid[playerid] = playerb;
TogglePlayerSpectating(playerid, 1);
Spec[playerid] = 1;
SetPlayerInterior(playerid, GetPlayerInterior(playerb));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
format(string, sizeof(string), " Currently spectating %s", RPN(playerb));
SendClientMessage(playerid, COLOR_WHITE, string);
if(IsPlayerInAnyVehicle(playerb))
{
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(playerb));
}
else
{
PlayerSpectatePlayer(playerid, playerb);
}
if(PlayerInfo[playerb][pAdmin] >= PlayerInfo[playerid][pAdmin])
{
format(string, sizeof(string), "SpecWarn: %s is currently spectating you.", RPN(playerid));
SendClientMessage(playerb, COLOR_DARKRED, string);
}
return 1;
}
As far as I know, after you stop spectating someone, you're spawning again. So, in OnPlayerSpawn, set the duty's color and the 3D text label again.
When he starts spectating get his duty's color and the 3D text label and retreive them to the player when stopped with spectating