Show name!
#1

Hey guys I was trying to learn Login and register system of samp and i was wondering how can I add the user name in the login/register dialog... for example,
Welcome Crackerz! Please login below...


My dialog code :

Код HTML:
public OnPlayerConnect(playerid)
{
	if(fexist(UserPath(playerid)))
	{
		INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Welcome to Pak Gaming Roleplay, Please login below to start wih your account!","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;
}
Reply
#2

Here's an example:
PHP код:
new string[144], name[MAX_PLAYER_NAME 1];
GetPlayerName(playeridnamesizeof(name));
format(stringsizeof(string), "Welcome %s! Please login below..."name);
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",string,"Login","Quit"); 
Reply
#3

where do i add that?
Reply
#4

To your code:
PHP код:
public OnPlayerConnect(playerid)
{
    new 
string[144], name[MAX_PLAYER_NAME 1];
    
GetPlayerName(playeridnamesizeof(name));

    if(
fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);

        
format(stringsizeof(string), ""COL_WHITE"Welcome %s! Please login below..."name);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",string,"Login","Quit");
    }
    else
    {
        
format(stringsizeof(string), ""COL_WHITE"Welcome %s! Please register below..."name);
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",string,"Register","Quit");
    }
    return 
1;

Reply
#5

Код:
public OnPlayerConnect(playerid)
{
	if(fexist(UserPath(playerid)))
        new string[144], name[MAX_PLAYER_NAME + 1]; 
        GetPlayerName(playerid, name, sizeof(name)); 
	{
		INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  		ShowPlayerDialog(playerid, DIALOG_LOGIN,DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Welcome to Pak Gaming Roleplay, Please login below to start wih your account!","Login","Quit");
         format(string, sizeof(string), "Hello %s Please login..", name); 

	}
	else
	{
 		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Regist
	}ering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
	return 1;
}
Try this?
Reply
#6

I can use it globally?
Reply
#7

Quote:
Originally Posted by RedRex
Посмотреть сообщение
Код:
public OnPlayerConnect(playerid)
{
	if(fexist(UserPath(playerid)))
        new string[144], name[MAX_PLAYER_NAME + 1]; 
        GetPlayerName(playerid, name, sizeof(name)); 
	{
		INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  		ShowPlayerDialog(playerid, DIALOG_LOGIN,DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Welcome to Pak Gaming Roleplay, Please login below to start wih your account!","Login","Quit");
         format(string, sizeof(string), "Hello %s Please login..", name); 

	}
	else
	{
 		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Regist
	}ering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
	return 1;
}
Try this?
Oh, god! Don't try this if you want to save yourself some seconds of your life.

Quote:
Originally Posted by Crackerz
Посмотреть сообщение
I can use it globally?
The player's name is being stored in a local variable, you'd have to get the player's name everywhere you want to display it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)