12.05.2014, 11:44
i am making a system that changes the player's name to another name when he /aduty,and when he /aduty again it sets his name back,how can i save his name,the real one?
new PlayerName[MAX_PLAYER_NAME+1]; // global?
// Duty is on
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
SetPVarString(playerid, "oldNick", PlayerName);
SetPlayerName(playerid, "Whatevernick"); // this is the new nick you have set
// After the duty is off
GetPVarString(playerid, "oldNick", PlayerName);
SetPlayerName(playerid, PlayerName);
CMD:aduty(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return 0;
if(PlayerInfo[playerid][pADuty] == 0)
{
format(PlayerInfo[playerid][pNormalName], 128, "%s", GetName(playerid));
PlayerInfo[playerid][pADuty] = 1;
SetPlayerName(playerid, PlayerInfo[playerid][pAName]);
SendClientMessage(playerid, -1, "You are now on a-duty.");
}
else
{
PlayerInfo[playerid][pADuty] = 0;
SendClientMessage(playerid, -1, "You have gone off a-duty.");
SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
}
return 1;
}
CMD:setaname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return 0;
if(isnull(params)) return SendClientMessage(playerid, -1, "SYNTAX: /setaname [name]");
format(PlayerInfo[playerid][pAdminName], 128, "%s", params);
new string[128];
format(string, sizeof(string), "You have set your admin name to %s.", params);
SendClientMessage(playerid,-1,string);
return 1;
}