30.04.2010, 20:05
Don't know if you use logged...
pawn Код:
if(!strcmp(cmd, "/changename", true))
{
if(!logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In"); // delete if you don't use
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changename [newname]");
GetPlayerName(playerid, playername, sizeof(playername));
new playerfile[30], newfile[30], newname;
newname = strval(tmp);
format(playerfile, sizeof(playerfile), "%s.dudb, playername);
format(newfile, sizeof(newfile), %s.dudb, newname);
if(fexist(playerfile)) {
if(!fexist(newfile)) {
SetPlayerName(playerid, tmp);
frename(playerfile,newfile);
format(string, sizeof(string), "%s has changed his/her name to %s.",playername, tmp);
SendClientMessageToAll(COLOR_YELLOW, string);
format(string, sizeof(string), "You have succesfully changed your name to %s.", tmp);
SendClientMessage(playerid, COLOR_GREEN, string);
}else SendClientMessage(playerid, COLOR_GREEN, "This name is already in use");
}//else SendClientMessage(playerid, COLOR_GREEN, "You dont have account");
return 1;
}