Change name
#1

Hi All I Make Change Name System In Dialog But Not Save New Name Whith Password And Cant Delet
Previous names
My Register System whith Dini
This Is my Change name System on Dialog : I Realy Need It + Rep TnX
Код:
 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;
}
Reply
#2

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 Код:
#include <YSI\y_files>
then replace your code with
pawn Код:
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;
    }
Reply
#3

Quote:
Originally Posted by XO
Посмотреть сообщение
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 Код:
#include <YSI\y_files>
then replace your code with
pawn Код:
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;
    }
++

it works !!!
check out some admin scripts bro!
Reply
#4

No need for a plugin to rename it.

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;
}
and (from the above example):
pawn Код:
if (!frename(stringr, another)) return SendClientMessage(playerid, -1, "It couldn't rename the file. Try again!");
Reply
#5

Also a user may rename to a name with [TAG] and i don't think you would like that, and yet i like Y_Files plugin works smoothly and avoid many things as i assume such crashes and etc.

you can check if the name doesn't have [TAG] using this stock

pawn Код:
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;
        }
and use
pawn Код:
if(!IsAllowedNamehuh(inputtext)) return SendClientMessage(playerid, -1, "Ehm sir you typed Invalid characters edit it i beg you.!");
Reply
#6

I Use Xo Script For Change name And Change Name in Game But On Disconect From Server And Reconect To Server whith new nick Open For Me Register Dialog And SAy This Id Is Not Make
Reply
#7

Changed this to your own?
pawn Код:
format(stringr,MAX_PLAYER_NAME,"Users/%s.ini",PlayerName(playerid)); // You can change " Users " with the dic. where the users save.
Users/%s.ini"?? Change Users folder to yours.
Reply
#8

Quote:
Originally Posted by XO
Посмотреть сообщение
Changed this to your own?
pawn Код:
format(stringr,MAX_PLAYER_NAME,"Users/%s.ini",PlayerName(playerid)); // You can change " Users " with the dic. where the users save.
Users/%s.ini"?? Change Users folder to yours.
Its Worked But Not Save Password For Rename Acount?
How to Set Password
Reply
#9

Password should stay same as old name, nothing in the ini file will get changed
Reply
#10

Quote:
Originally Posted by XO
Посмотреть сообщение
Password should stay same as old name, nothing in the ini file will get changed
GIved To Me Password Error!!!!!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)