07.08.2013, 06:41
I'll go straight to the point. I have an admin command for going on-duty (/adminduty) which changes the admin's name to a single name stored on Player[playerid][pAdminName], it works fine and all that. But I've noticed that when an admin goes on-duty for like 3 minutes or more and goes off-duty, their name doesn't go back to the role-play name.
Here's my code:
I tried to do some tweaks by formatting and storing the role-play name once again before changing it but still didn't work. I'd appreciate any help or suggestion. Thanks!
Here's my code:
pawn Код:
command(adminduty, playerid, params[])
{
if(IsConnected(playerid) && Player[playerid][pAdminLevel] >= 1)
{
if(!Player[playerid][pAdminDuty])
{
if(!Player[playerid][pAdminName]) return SCM(playerid, DARKGREY, "Your admin name hasn't been set yet.");
Player[playerid][pAdminDuty] = 1;
strmid(Player[playerid][pName], GetName(playerid), 0, strlen(GetName(playerid)), 24);
SetPlayerName(playerid, Player[playerid][pAdminName]);
format(cmdstring, sizeof(cmdstring), "You're now ON duty as a level %d administrator.", Player[playerid][pAdminLevel]);
SCM(playerid, YELLOW, cmdstring);
}
else
{
new name[24];
format(name, sizeof(name), "%s", Player[playerid][pName]);
Player[playerid][pAdminDuty] = 0;
SetPlayerName(playerid, name);
SCM(playerid, 0xCCCCCCFF, "You're no longer on duty as an administrator.");
}
}
return 1;
}