Register system
#1

I have a register system made by Y_INI The problem when the player join the server the dialog apear and all things went good but if the player click close the server kick him and the problem is the player file saves in the scriptfiles so when the player connect again it show to him the login dialog and the player didn't register.
Please help !!
Reply
#2

Show Us You Code
Reply
#3

PHP код:
public OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 
1;

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"Register",COL_RED"Invalid Password","Register","Close");
            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);
            
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,""COL_WHITE"Success",""COL_GREEN"El hamd ll allah :D","Kois !","");
         }
       }
       
       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"El hamd ll allah :D","Kois !","");
              }
              else
              {
                 
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login"COL_RED"Invalid Paswword","Login","Close");
              }
              return 
1;
              }
    }
}
    return 
1;

And other but this is the important !!
Reply
#4

Please help [REP++]
Reply
#5

Remove the file under if(!response) after the player is kicked.
Reply
#6

if(!response) return Kick(playerid);

Where is the code ??
Reply
#7

pawn Код:
if(!response) return Kick(playerid);
Change that to:

pawn Код:
if(!response)
{
    if(fexist(UserPath(playerid)))
    {
        Kick(playerid);
        return fremove(UserPath(playerid));
    }
}
Reply
#8

lol when the player click close the dialog close and the player spawn doesn't close the connection and also the file created
Please Helppp [REP++]
Reply
#9

EDIT
You have to create a variable that checks if the player is logged in or if the player is registering.
Like so:


This is our variable. It should only return 0 or 1 (False or true) and therefor it's a boolean.
pawn Код:
new bool:gRegistering[MAX_PLAYERS];

We assign a value to the variable. If the player is already registered then we say that gRegistering[playerid] = false.
If the player is not registered yet we assign it to a true value.
pawn Код:
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"Type your password below to login.","Login","Quit");
        gRegistering[playerid] = false;
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
        gRegistering[playerid] = true;
    }
    return 1;
}

When the player disconnects (by a kick or by a manual /q) we check if the player is registered. If not: We don't save his data. Thus, we avoid having a file created.
pawn Код:
public OnPlayerDisconnect(playerid)
{
    if(!gRegistering[playerid])
    {
        //Save the user's data.
    }
    return 1;
}
When the player registers, we reset the gRegistering variable to false. Otherwise his data will not save upon disconnect.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if(!response)
            {
                if(fexist(UserPath(playerid)))
                {
                    fremove(UserPath(playerid));
                    return SetTimerEx("KickDelay", 100, false, "i", playerid);
                }
            }
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Register",COL_RED"Invalid Password","Register","Close");
                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);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success",""COL_GREEN"El hamd ll allah :D","Kois !","");
                gRegistering[playerid] = false;
            }
        }
        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"El hamd ll allah :D","Kois !","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login"COL_RED"Invalid Paswword","Login","Close");
                }
            }
        }
    }
    return 0;
}
Our delayed kick.
pawn Код:
forward KickDelay(playerid);
public KickDelay(playerid)
{
    Kick(playerid);
}
Reply
#10

Ok...it works but doesn't kick the player it let him to spawn ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)