admin name - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: admin name (
/showthread.php?tid=512729)
admin name -
iBots - 12.05.2014
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?
Re: admin name -
iZN - 12.05.2014
You can use normal variables instead of PVars but in the example, I've used PVar.
pawn Код:
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);
Re: admin name -
Abagail - 12.05.2014
To save it for next time,
pawn Код:
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;
}