16.05.2012, 07:18
pawn Код:
command(changename, playerid, params[])
{
new id, NewName[MAX_PLAYER_NAME];
if(sscanf(params, "uz", id, NewName))
{
if(Player[playerid][AdminLevel] >= 4)
{
SendClientMessage(playerid, WHITE, "SYNTAX: /changename [playerid] [new name]");
}
}
else
{
new NameStr[40], CurrentName[MAX_PLAYER_NAME], string[128];
if(Player[playerid][AdminLevel] >= 4)
{
if(Player[id][AdminLevel] >= 1 && Player[playerid][AdminLevel] < 5)
{
SendClientMessage(playerid, WHITE, "You cannot adjust the name of another Administrator unless being Head Admin.");
}
else
{
if(Player[playerid][AdminLevel] >= Player[id][AdminLevel])
{
if(strlen(NewName) >= 3 && strlen(NewName) < MAX_PLAYER_NAME)
{
GetPlayerName(id, CurrentName, sizeof(CurrentName));
//format(string, sizeof(string), "scriptfiles/Accounts/%s.ini", CurrentName);
format(NameStr, sizeof(NameStr), "Accounts/%s.ini", NewName);
if(fexist(NameStr))
{
SendClientMessage(playerid, WHITE, "That account name is already registered.");
}
else
{
format(Player[id][NormalName], MAX_PLAYER_NAME, "%s", NewName);
//file_delete(string);
fremove(NameStr);
CallRemoteFunction("OnPlayerNameChange", "ss", GetPlayerName(id), NewName);
SetPlayerName(id, NewName);
SavePlayerData(id);
format(string, sizeof(string), "WARNING: Server Admin %s has renamed %s to %s.", GetName(playerid), CurrentName, NewName);
AdminActionsLog(string);
NamechangeLog(string);
SendToAdmins(ADMINORANGE, string, 1);
if(Player[id][Business] >= 1 || Player[id][House] >= 1)
{
if(strcmp(Businesses[Player[id][Business]][bOwner], CurrentName, true) == 0)
{
format(Businesses[Player[id][Business]][bOwner], MAX_PLAYER_NAME, "%s", NewName);
}
if(strcmp(Houses[Player[id][House]][hOwner], CurrentName, true) == 0)
{
format(Houses[Player[id][House]][hOwner], 255, "%s", NewName);
}
}
format(string, sizeof(string), "Your name has been changed from %s to %s, by %s.", CurrentName, NewName, Player[playerid][AdminName]);
SendClientMessage(id, WHITE, string);
SendClientMessage(id, GREY, "Don't worry about re-connecting, just don't forget to change your name in the connection client!");
}
}
else
{
format(string, sizeof(string), "Names must be 3 - %d characters in length.", MAX_PLAYER_NAME);
SendClientMessage(playerid, WHITE, string);
}
}
}
}
}
return 1;
}