Register / Login System with Y_ini
#1

Well , I am making a Register system with Y_INI and it works fine - But the problem that once the player Register it will give him that you have to relog to save your Stats - then when you relog you login everything works fine - But i don't want that , i want that once the player Register it pops up a login dialog then he spawn , Here is the Codes :

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch( 
dialogid )
     {
         case 
DIALOG_REGISTER:
     {
         if (!
response) return Kick(playerid);
         if(
response)
     {
         if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_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_Close(File);
         
SetSpawnInfo(playerid001958.331343.1215.36269.15000000);
         
SpawnPlayer(playerid);
           
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","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(playeridPlayerInfo[playerid][pCash]);
          
ShowPlayerDialog(playeridDIALOG_SUCCESS_2DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
     }
         else
     {
         
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_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;
 } 
Reply
#2

what is the problem with this ?
Reply
#3

Read what i said at the Top...
Reply
#4

Код:
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_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_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"); 
         } 
     } 
         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]); 
          ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","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 1; 
 }
try this REPUTATION + IF WORKED OHK ?
Reply
#5

Well...Did that but like this after i register it show me Login Dialog saying wrong password and even when i re-enter it with the right one it keep saying wrong pass
Reply
#6

i will try ... wait
Reply
#7

Well, I confused a bit with it.
But why, it needs to relog to save the stats. If you remove the dialog after ?
pawn Код:
SpawnPlayer(playerid);
Reply
#8

Код:
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_Close(File);
         SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
         SpawnPlayer(playerid);
         }
     }
         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]);
          ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","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 1;
 }
public OnPlayerSpawn(playerid)
{
		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;
Reply
#9

Quote:
Originally Posted by trickter
Посмотреть сообщение
Код:
...
public OnPlayerSpawn(playerid)
{
		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;
What is this. He told us that he doesn't want the relog. Since a player spawns, it requares to login.
Reply
#10

remove
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
from case DIALOG_REGISTER:
and work perfect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)