11.02.2010, 23:57
Dear senior scripter.
i want to request a script to make /changename possible without losing status.
thanks.
i want to request a script to make /changename possible without losing status.
thanks.
SetPlayerName(playerid, "newname");
stock frename(oldname[], newname[])
{
if (!fexist(oldname)) return 0;
new File:oldfile = fopen(oldname, io_read);
new File:newfile = fopen(newname, io_write);
new line[256];
while (fread(oldfile, line))
{
fwrite(newfile, line);
}
fclose(oldfile);
fclose(newfile);
fremove(oldname);
return 1;
}
Originally Posted by ДitisOnHuora
Is it possible that it Deletes the old account after it makes the "copy" ? Its annoying to go FTP and delete it manually...
|
Originally Posted by LUCAGRABACR
thx for the help everyone but is this work with database?
|
if(strcmp(cmd, "/changename", true) == 0)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new tmpp[256];
tmpp = strtok(cmdtext, idx);
if(!strlen(tmpp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /changename [playerid] [new_nick]");
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: Remember to ban/delete old Firstname_Lastname from 'accounts' folder!!");
return 1;
}
giveplayerid = strval(tmpp);
tmp = strtok(cmdtext, idx);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
if(IsPlayerConnected(giveplayerid))
{
SetPlayerName(giveplayerid, tmp);
format(string, sizeof(string), "[SERVER]: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
SendClientMessage(giveplayerid, COLOR_GREEN, string);
format(string, sizeof(string), "[SERVER]: You have changed ID %i's name to %s", giveplayerid, tmp);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "[SERVER]: Remember to ban/delete %s's old Firstname_Lastname!", tmp);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
format(string, 256, "[SERVER]: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
ABroadCast(COLOR_RED,string,1);
}
else
{
format(string, sizeof(string), "%d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_GREY, string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You do not have permission to use that command!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You Must be logged in to use this command!");
}
return 1;
}