SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/07/2017, 09:16 PM   #1
Crackerz
Little Clucker
 
Join Date: Jun 2017
Posts: 35
Reputation: 0
Default Show name!

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 Code:
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;
}
Crackerz is offline   Reply With Quote
Old 17/07/2017, 09:20 PM   #2
Paulice
Big Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 181
Reputation: 26
Default Re: Show name!

Here's an example:
PHP Code:
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"); 
Paulice is offline   Reply With Quote
Old 17/07/2017, 09:21 PM   #3
Crackerz
Little Clucker
 
Join Date: Jun 2017
Posts: 35
Reputation: 0
Default Re: Show name!

where do i add that?
Crackerz is offline   Reply With Quote
Old 17/07/2017, 09:26 PM   #4
Paulice
Big Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 181
Reputation: 26
Default Re: Show name!

To your code:
PHP Code:
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;

Paulice is offline   Reply With Quote
Old 17/07/2017, 09:26 PM   #5
RedRex
Huge Clucker
 
RedRex's Avatar
 
Join Date: Jan 2016
Posts: 386
Reputation: 22
Default Re: Show name!

Code:
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?
RedRex is offline   Reply With Quote
Old 17/07/2017, 09:29 PM   #6
Crackerz
Little Clucker
 
Join Date: Jun 2017
Posts: 35
Reputation: 0
Default Re: Show name!

I can use it globally?
Crackerz is offline   Reply With Quote
Old 17/07/2017, 10:22 PM   #7
Paulice
Big Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 181
Reputation: 26
Default Re: Show name!

Quote:
Originally Posted by RedRex View Post
Code:
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 View Post
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.
Paulice is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show textdraw[MAX_PLAYERS] show for a player? Maheerali Scripting Help 2 14/08/2016 02:17 PM
simple show player money with textdraw will show player money to all !!!!LOL dash5487 Scripting Help 10 15/04/2015 08:43 PM
Textdraw doesn't show on spawn sometimes it even doesn't show Immortal_LTU Scripting Help 10 24/10/2013 07:52 AM
Key show on 3D Qur Scripting Help 18 25/11/2011 03:59 PM
/show | /show ID Milf Help Archive 0 20/08/2011 02:25 AM


All times are GMT. The time now is 02:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.