How To Make A Rename Account Command
#1

Hey guys how can I make a /renameaccount command that renames the offline/online user's name, I use YINI.

Is it possible

EDIT:

For people looking on how to make it, check this tutorial: https://sampforum.blast.hk/showthread.php?tid=397180
Reply
#2

Post your Y_ini account script.
You may get help then.
Reply
#3

I guess this is what you need?

Код:
enum pInfo
{
	pPass,
	pBanned,
	pCash,
	pAdmin,
	pVip,
	pKills,
	pScore,
	pIp,
	pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward
LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password",PlayerInfo[playerid][pPass]);
	INI_Int("Banned", PlayerInfo[playerid][pBanned]);
	INI_Int("Cash",PlayerInfo[playerid][pCash]);
	INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
	INI_Int("Vip",PlayerInfo[playerid][pVip]);
	INI_Int("Kills",PlayerInfo[playerid][pKills]);
	INI_Int("Score", PlayerInfo[playerid][pScore]);
	INI_Int("Ip", PlayerInfo[playerid][pIp]);
	INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
	return 1;
}

stock UserPath(playerid)
{
	new string[128],playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid,playername,sizeof(playername));
	format(string,sizeof(string),PATH,playername);
	return string;
}
Код:
public OnPlayerConnect(playerid)
{
	if(fexist(UserPath(playerid)))
	{
		new IP[59];
		GetPlayerIp(playerid, IP, sizeof(IP));
		new INI:File = INI_Open(UserPath(playerid));
		INI_SetTag(File, "data");
		INI_WriteString(File, "Ip", IP);
		INI_Close(File);
	    if(!strcmp(IP, PlayerInfo[playerid][pIp], true))
		{
		    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true , .extra = playerid);
		    switch(PlayerInfo[playerid][pAdmin])
			{
			    case 2:
			    {
			        new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Trial Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
			    }

			    case 3:
			    {
			        new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Trial Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
			    }

			    case 4:
			    {
			        new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Moderator, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
			    }

			    case 5:
			    {
			        new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Moderator, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
			    }

			    case 6:
			    {
			        new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Deputy Head Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
			    }

			    case 7:
			    {
			        new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Head Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
			    }

			    case 8:
			    {
			        new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Head Admin, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
			    }

				case 9:
				{
				    new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), "Name: %s, "blue"Co-Owner, VIP level: %i"yellow", Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
				}

				case 10:
				{
				    new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), ""yellow"Name: %s, "blue"Main Owner"yellow", VIP level: %i, Score: %i, Deaths: %i, Kills: %i", name, PlayerInfo[playerid][pVip], PlayerInfo[playerid][pScore],PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
				}

				default:
				{
				    new string[159], name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string), ""yellow"Name %s: Score: %i, Deaths: %i, Kills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
					SendClientMessage(playerid, Limegreen, string);
					SendClientMessage(playerid, Yellow, ""COL_GREEN"You have been "COL_LIGHTBLUE"auto logged in via "COL_RED"IP");
				}
  			 }
   		 	GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
			SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
			loggedin[playerid]=1;
		}
		else
		{
	    	INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true , .extra = playerid);
	    	ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login", "Login", "Quit");
		}
	}
	else
	{
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
	}
	return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
	new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File,"data");
	INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
	INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
	INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
	INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
	INI_WriteInt(File, "Score", PlayerInfo[playerid][pScore]);
	INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
	INI_Close(File);
Код:
switch( dialogid )
	{
		case DIALOG_REGISTER:
		{
			if (!response) return Kick(playerid);
			if(response)
			{
				if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
				new INI:File = INI_Open(UserPath(playerid));
				new IP[50], string[50];
				GetPlayerIp(playerid, IP, sizeof(IP));
				format(string, sizeof(string),"%s", IP);
				INI_SetTag(File,"data");
				INI_WriteInt(File,"Password",udb_hash(inputtext));
				INI_WriteString(File,"Real Password", inputtext);
				INI_WriteInt(File, "Banned", 0);
				INI_WriteInt(File,"Cash",0);
				INI_WriteInt(File,"Admin",0);
				INI_WriteInt(File, "Vip", 0);
				INI_WriteInt(File,"Kills",0);
				INI_WriteInt(File, "Score",0);
				INI_WriteString(File, "Ip", IP);
				INI_WriteInt(File,"Deaths",0);
				INI_Close(File);
				SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
				SpawnPlayer(playerid);
				ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
				}
			}
		case DIALOG_LOGIN:
		{
		    ShowPlayerDialog(playerid, -1, 2, "lol", "lol", "l","h");
		    if(PlayerInfo[playerid][pBanned] == 1)
    		{
	        Ban(playerid);
	    	}
		    if(loggedin[playerid] == 1) return 0;
		    else
		    {
				if ( !response ) return Kick ( playerid );
			}
			if( response )
			{
   				if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
				{
				    loggedin[playerid]=1;
					INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
					GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
					SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
					switch(PlayerInfo[playerid][pAdmin])
					{
			    		case 2:
			    		{
			        		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nTrial Admin\nScore: %i\nDeaths: %i\nKills: %i\nPassword: %s",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills], inputtext);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

			    		case 3:
			    		{
			        		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nTrial Admin\nScore: %i\nDeaths: %i\nKills: %i\nPassword: %s",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills], inputtext);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

			    		case 4:
			   	 		{
			        		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nModerator\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

			    		case 5:
			    		{
			        		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nModerator\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

			    		case 6:
			    		{
			        		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nDeputy Head Admin\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

			    		case 7:
			    		{
			        		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nHead Admin\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

			    		case 8:
			    		{
			        		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nHead Admin\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}
						case 9:
						{
				    		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nCo-Owner\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

						case 10:
						{
				    		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
							format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nMain Owner\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
                        	ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}

						default:
						{
				    		new string[159], name[MAX_PLAYER_NAME];
			        		GetPlayerName(playerid, name, sizeof(name));
                        	format(string, sizeof(string),""green"You have successfully logged in!\nName %s\nScore: %i\nDeaths: %i\nKills: %i",name, PlayerInfo[playerid][pScore], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pKills]);
							ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",string,"Ok","");
						}
					}
				}
				else
				{
				    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
				}
			}
			return 1;
		}
	}
	return 0;
}
Reply
#4

Sorry for the late bumb but I really need it, thanks.
Reply
#5

You must have a player name in your .ini file so

Name = &&&&&&&&&&& // The name
pawn Код:
CMD:changename(playerid,params[])
{
    if(PlayerInfo[playerid][pCredits] >=1)
    {
     PlayerInfo[playerid][pCredits] -1;
     ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Change Your Name", "Enter Your New Name Below",    "Next", "Cancel");

    }
    else{
    SendClientMessage(playerid,-1,"You Do Not Have The Correct Amount Of Credits 5©");
    }
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) // If they clicked 'Cancel' or pressed esc
        {
            SendClientMessage(playerid, COLOR_RED, "You Canceled Your Name Change");
        }
        else // Pressed ENTER or clicked 'Login' button
        {
            if(CheckPassword(playerid, inputtext))
            {
                            ShowPlayerDialog(playerid, DIALOG_WELCOME, DIALOG_STYLE_MSGBOX, "Notice", "You connected to the server", "Close", "");
            }
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
    if(dialogid == DIALOG_WELCOME)
    {
        if(response) // If they clicked 'Yes' or pressed enter
        {
          PlayerInfo[playerid][Name] == inputtext;
        }
        else // Pressed ESC or clicked cancel
        {
            SendClientMessage(playerid, COLOR_RED, "You Canceled Your Name Change");
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
 
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Reply
#6

Thanks but I want this command to be for Admin's to use and you can rename the offline user's name, get it ?
Reply
#7

well do that your self.

If you want to request one unse the request script thread

(( CLOSE THIS TOPIC ))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)