if(dialogid == DIALOG_CHANGENAME) { if (response == 0) { return 1; } if (response == 1) { if (strlen(inputtext)==0) { SendClientMessage(playerid,COLOR_RED,"Enter Your New Name."); ShowChangeNameScreen(playerid); return 1; } udb_RenameUser(PlayerName(playerid),inputtext); SetPlayerName(playerid,inputtext); format(string,sizeof(string),"Changed Name To'%s'",inputtext); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); GivePlayerCash(playerid, -10000000); return true; } return 1; } return 1; }
#include <YSI\y_files>
if(dialogid == DIALOG_CHANGENAME)
{
if (!response) return 1;
if (response == 1)
{
if (!strlen(inputtext))
{
SendClientMessage(playerid,COLOR_RED,"Enter Your New Name.");
ShowChangeNameScreen(playerid);
return 1;
}
new stringr[MAX_PLAYER_NAME],another[MAX_PLAYER_NAME];
format(stringr,MAX_PLAYER_NAME,"Users/%s.ini",PlayerName(playerid)); // You can change " Users " with the dic. where the users save.
format(another,MAX_PLAYER_NAME,"Users/%s.ini",inputtext); // You can change " Users " with the dic. where the users save.
frename(stringr, another);
SetPlayerName(playerid,inputtext);
format(string,sizeof(string),"Changed Name To'%s'",inputtext);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
GivePlayerCash(playerid, -10000000);
return true;
}
return 1;
}
There is a plugin made by ****** named Y_files
download from:https://mars-bots.******code.com/files/y_files.zip and extract plugin in plugins folder ( use .so for linux ) at the top of your gamemode pawn Код:
pawn Код:
|
stock frename(const oldname[], const newname[])
{
if (!fexist(oldname)) return 0;
new
File: oldfile = fopen(oldname, io_read),
File: newfile = fopen(newname, io_write),
line[128];
if (!oldfile || !newfile) return 0;
while (fread(oldfile, line)) fwrite(newfile, line);
fclose(oldfile);
fclose(newfile);
fremove(oldname);
return 1;
}
if (!frename(stringr, another)) return SendClientMessage(playerid, -1, "It couldn't rename the file. Try again!");
stock IsAllowedNamehuh(const string[])
{
new z = 0;
for(new x, y = strlen(string); x != y; x++)
{
if((string[x] >= 48 && string[x] <= 57) || (string[x] >= 65 && string[x] <= 90) || (string[x] >= 97 && string[x] <= 122) || string[x] == '_' || string[x] == ' ')
{
z++;
}
}
if(z == strlen(string)) return true;
else return false;
}
if(!IsAllowedNamehuh(inputtext)) return SendClientMessage(playerid, -1, "Ehm sir you typed Invalid characters edit it i beg you.!");
format(stringr,MAX_PLAYER_NAME,"Users/%s.ini",PlayerName(playerid)); // You can change " Users " with the dic. where the users save.
Changed this to your own?
pawn Код:
|
Password should stay same as old name, nothing in the ini file will get changed
|