PDA

View Full Version : Help - Login/Register system.


JhnzRep
07/04/2012, 03:11 PM
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
if(PlayerInfo[playerid][pBan] == 1)
{
Kick(playerid);
SCM(playerid, RED, "You are banned.");
}
else
{
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;
}

Do you see anything wrong with this? It compiles, but when I go in game neither register or login dialog shows up.

kikito
07/04/2012, 03:12 PM
Because you forgot the OnDialogResponse :rolleyes:

Catalyst-
07/04/2012, 03:13 PM
Try it under OnPlayerRequestClass instead.

JhnzRep
07/04/2012, 03:14 PM
Because you forgot the OnDialogResponse :rolleyes:


*Facepalm* The dialog doesn't show up...Oh my god..Read please.

JJB562
07/04/2012, 03:50 PM
*Facepalm* The dialog doesn't show up...Oh my god..Read please.

Exactly why he said it... You need to script what the dialog will do also. I believe you are following this tutorial:

http://forum.sa-mp.com/showthread.php?t=273088

So just following everything on the tutorial, and it should work out perfectly.

JhnzRep
07/04/2012, 03:51 PM
*Facepalm* I have a dialog response...

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
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));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Faction",0);
INI_WriteInt(File,"Frank",0);
INI_WriteInt(File,"LeaderFlag",0);
INI_WriteFloat(File,"Health",100);
INI_WriteFloat(File,"Armor",0);
INI_WriteFloat(File,"X",0);
INI_WriteFloat(File,"Y",0);
INI_WriteFloat(File,"Z",0);
INI_WriteInt(File,"VW",0);
INI_WriteInt(File,"Interior",0);
INI_WriteInt(File,"Skin", 7);
INI_Close(File);
pLogged[playerid] = 1;
SetSpawnInfo(playerid, 0, 7, 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_GREEN"Success!",""COL_RED"You are now registered on our server, welcome.","Ok","");
}
}

case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
pLogged[playerid] = 1;
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ], 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
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 1;
}

TzAkS.
07/04/2012, 04:08 PM
Exactly why he said it... You need to script what the dialog will do also. I believe you are following this tutorial:

http://forum.sa-mp.com/showthread.php?t=273088

So just following everything on the tutorial, and it should work out perfectly.

Wrong,you can put a dialog with nothing to OnDialogResponse,but when you select something nothing happen but the dialog appaer.
I thing that your problem is becouse you didn`t put the dialog to show on he`s place.
Try to put it on OnPlayerRequescClass

emokidx
07/04/2012, 04:10 PM
check your dialog's ids again? make sure it's not colliding with any other.

Catalyst-
07/04/2012, 04:12 PM
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
if(PlayerInfo[playerid][pBan] == 1)
{
Kick(playerid);
SCM(playerid, RED, "You are banned.");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{FFFFFF}Login", "{FFFFFF}Type your password below to login.", "Login", "Quit");
}
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{FFFFFF}Registering...", "{FFFFFF}Type your password below to register a new account.", "Register", "Quit");
}
return 1;
}