change 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: change name (
/showthread.php?tid=584309)
change name -
suni - 03.08.2015
hey I have an change name command it work find but then I realized that when a player changed their name, the old account does not delete. it just create a new account anytime you change your name. I need this to delete the old account and check and see if a name is already in use.
Код:
CMD:changename(playerid, params[])
{
new str[128], id;
if(PlayerinMMDM[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"You are in a DM. Type /kill to exit.");
if(PlayerAcc[playerid][Log] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in!");
{
if(sscanf(params, "s[24]", id, params)) return SendClientMessage(playerid, COLOR_YELLOW, "/Changename (/cn) (new-name)");
if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
if(strlen(params) < 1 || strlen(params) > 24) return SendClientMessage(playerid, COLOR_RED, "Maxium Name Length (Left): 1 - (Right): 24");
if(strcmp(params, GetName(playerid), true) == 0) return SendClientMessage(playerid, COLOR_GREY, "The new name you put was your name, Put another one!");
SetPlayerName(playerid, params);
frenametextfile(GetName(playerid), params);
}
return 1;
}
Re: change name -
sw3das - 03.08.2015
I've found some errors in your code, some critical ones... This should word, haven't tested though...
PHP код:
CMD:changename(playerid, params[])
{
new id[24]; // you forgot the '[24]' and why do you create a variable ( str[128] ) if you don't use it ????
if(PlayerinMMDM[playerid] == 1)
return SendClientMessage(playerid,COLOR_RED,"You are in a DM. Type /kill to exit.");
if(PlayerAcc[playerid][Log] == 0)
return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in!");
if(sscanf(params, "s[24]", id))
return SendClientMessage(playerid, COLOR_YELLOW, "/Changename (/cn) (new-name)");
if(id == INVALID_PLAYER_ID)
return ErrorMessages(playerid, 2);
if(strlen(params) < 1 || strlen(params) > 24)
return SendClientMessage(playerid, COLOR_RED, "Maxium Name Length (Left): 1 - (Right): 24");
if(strcmp(params, GetName(playerid), true) == 0)
return SendClientMessage(playerid, COLOR_GREY, "The new name you put was your name, Put another one!");
if( fexist( <path to current player file> )) // enter path without < >
return SendClientMessage(playerid, COLOR_RED, "There is already a player with the name! Choose another one");
fremove( <path to player's current file > ); // enter path without < >
SetPlayerName(playerid, params);
frenametextfile(GetName(playerid), params); // I believe this one creates new file, right ?
return 1;
}