PHP код:
CMD:changename(playerid,params[])
{
if(PlayerInfo[playerid][Admin] >= 1 && PlayerInfo[playerid][Admin] <= 91) return SendClientMessage(playerid, Red, "ERROR: Disable command for low level admins!"),SendClientMessage(playerid, Red, "* If you want change your name, you say with owner of server.");
if(PlayerInfo[playerid][LoggedIn] == 1)
{
if(GetPlayerScore(playerid)>19)
{
if(NoName[playerid] == 1)
{
if(isnull(params))
return SendClientMessage(playerid, Red, "* Usage: /changename [new name]");
if (strlen(params) < 3 || strlen(params) > 20)
return SendClientMessage(playerid,Red,"ERROR: The name must be between 3 and 20 characters");
if(!IsValidName(params))
return SendClientMessage(playerid, Red, "* The name have invalid characters.");
new name[MAX_PLAYER_NAME], string[128], sname[150];
if(udb_Exists(params))
return SendClientMessage(playerid, Red, "This name already exists, choose another");
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string),"* %s (ID: %d) was changed the name to: \"%s\" .",name,playerid,params);
SendClientMessageToAll(0xFFFF00FF,string);
format(sname,sizeof(sname),"* %s (ID: %d) was changed the name to: \"%s\" .",name,playerid,params);
new year,month,day; getdate(year, month, day);
new hour,minute,second; gettime(hour,minute,second);
new wea[500];
format(wea,sizeof(wea),"{FFFFFF} Hi %s!, You changed your nick!\
\n\n{FFFFFF}Your old nick is: %s\
\n{FFFFFF}Your new nick is: %s\
\n{FFFFFF}Date: %i/%i/%i Time: %i:%i :%i\
\n\n{FFFFFF}Remember that when you leave the server and then re-enter\
\n{FFFFFF}you must put your new nick %s in your SA-MP to re-enter your new nick\
\n\n{FFFFFF}We recommend you take a picture by pressing F8 so do not waste your nick.",name,name,params,day,month,year, hour, minute, second,params);
ShowPlayerDialog(playerid, 8000, DIALOG_STYLE_MSGBOX, "You've changed your nickname!", wea, "OK", "");
NoName[playerid] = 0;
udb_RenameUser(name, params);
SetPlayerName(playerid, params);
}
else return SendClientMessage(playerid,Red,"* You can only use this command once.");
}
else return SendClientMessage(playerid,Red,"* You need 20 score for change your name.");
}
else return SendClientMessage(playerid,Red,"* You need to log (/login) To use this command");
return 1;
}