Problem in Register & Login system
#1

Howd'y, i just started working on admin script by this page - https://sampwiki.blast.hk/wiki/Creating_...l_admin_script

After i added those i deleted all users files, and came again to server to register In the skin select screen it said 'You must register or login before spawning!' , And the dialog of the register does not shown up, also i clicked on spawn and it spawned me aswell.. (It worked today [The dialog] ).


What it can be?
Reply
#2

Can you show me your pwn?
Reply
#3

Quote:
Originally Posted by axxelac
Посмотреть сообщение
Can you show me your pwn?
I can paste all the Register & Login system :

pawn Код:
enum iDetails { //Enumerating player data
    Pass,
    Cash,
    Score,
    Admin,
    IP,
    Banned
};
new pInfo[MAX_PLAYERS][iDetails]; //Player data variable
new pIP[MAX_PLAYERS][16]; //For autologin
new pLogged[MAX_PLAYERS];
Onplayerconnect
pawn Код:
pLogged[playerid] = 0;
    #if defined AUTOLOGIN
    new tmpIP[16];
    GetPlayerIp(playerid,tmpIP,sizeof(tmpIP)); //Getting IP
    #endif
    if(fexist(PlayerPath(playerid)))
    {
        INI_ParseFile(PlayerPath(playerid), "UserDataLoad_%s", .bExtra = true, .extra = playerid); //Calling loading callback
        #if defined AUTOLOGIN
        if(strcmp(tmpIP,pIP[playerid],true) == 0)//Checking if the IPs match
        {
                    pLogged[playerid] = 1;
                    SetPlayerScore(playerid,pInfo[playerid][Score]);
                    GivePlayerMoney(playerid,pInfo[playerid][Cash]);
                    ShowPlayerDialog(playerid, 997, DIALOG_STYLE_MSGBOX, "Auto login!", "You've been auto-logged in. [IP match]", "OK", "");
        }
        #endif
        if(pLogged[playerid] == 0)
        {
            ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Please enter your password below.","Login","Leave");
        }
    }

Onplayerrequestspawn
pawn Код:
if(pLogged[playerid] == 0) return SendClientMessage(playerid,yellow,"You must register or login before spawning!");
Ondialogrespone
pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
        GetPlayerIp(playerid,pIP[playerid],16);
        if(!response) Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
        new INI:iFile = INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
        INI_SetTag(iFile,"data");
        INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
        #if defined AUTOLOGIN
            INI_WriteString(iFile,"IP",pIP[playerid]);
        #endif
        INI_WriteInt(iFile,"Cash",0);
        INI_WriteInt(iFile,"Score",0);
        INI_Close(iFile);
        pLogged[playerid] = 1;
        new iStr[128];
        format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
        SendClientMessage(playerid,yellow,iStr);
        return 1;
    }

    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) Kick(playerid);
        new iStr[128],gTries;
        if(gTries == 0) gTries = 1;
        if(gTries == 3)
        { // 3 tries = kick
            new pName[30];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pName);
            SendClientMessageToAll(red,iStr);
            return Kick(playerid);
        }
        if(!strlen(inputtext))
    {
            format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",gTries);
            return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Leave");
        }
        if(udb_hash(inputtext) == pInfo[playerid][Pass])
    {
            pLogged[playerid] = 1;
            SendClientMessage(playerid,lime,"You've successfully logged in.");
            SetPlayerScore(playerid,pInfo[playerid][Score]); //Loading player score
            GivePlayerMoney(playerid,pInfo[playerid][Cash]); //Loading player money
        }
    else
    {
            format(iStr,sizeof(iStr),"Incorrect password. Tries: %i/3",gTries);
            ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",iStr,"Login","Leave");
            gTries++;
            return 1;
        }
    }
Onplayerdisconnect
pawn Код:
if(pLogged[playerid] == 1) {
        new INI:iFile = INI_Open(PlayerPath(playerid));
        INI_SetTag(iFile,"data");
        INI_WriteInt(iFile,"Cash",GetPlayerMoney(playerid));
        INI_WriteInt(iFile,"Score",GetPlayerScore(playerid));
        INI_Close(iFile);
    }
        pLogged[playerid] = 0;
Public userdata
pawn Код:
public UserDataLoad_data(playerid,name[],value[]) { //This loads the settings from the INI file
    INI_Int("Pass",pInfo[playerid][Pass]);
    INI_String("IP",pIP[playerid],16);
    INI_Int("Admin",pInfo[playerid][Admin]);
    INI_Int("Cash",pInfo[playerid][Cash]);
    INI_Int("Score",pInfo[playerid][Score]);
    INI_Int("Banned",pInfo[playerid][Banned]);
    return 1;
}
pawn Код:
stock PlayerPath(playerid) { //This will give us faster access to a player's path
    new iStr[256],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(iStr,sizeof(iStr),PATH,name);
    return iStr;
}
*It's without the 'Admin script' because i trough that was the problem but it wasn't.
Reply
#4

Where do you show the register dialog?
Reply
#5

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Where do you show the register dialog?
What do you mean?
Reply
#6

Quote:
Originally Posted by Firo
Посмотреть сообщение
the dialog of the register does not shown up
This is the problem?

I can't see where you show it in code.
Reply
#7

pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
        GetPlayerIp(playerid,pIP[playerid],16);
        if(!response) Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
        new INI:iFile = INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
        INI_SetTag(iFile,"data");
        INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
        #if defined AUTOLOGIN
            INI_WriteString(iFile,"IP",pIP[playerid]);
        #endif
        INI_WriteInt(iFile,"Cash",0);
        INI_WriteInt(iFile,"Score",0);
        INI_Close(iFile);
        pLogged[playerid] = 1;
        new iStr[128];
        format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
        SendClientMessage(playerid,yellow,iStr);
        return 1;
    }
This one?
Reply
#8

Quote:
Originally Posted by Firo
Посмотреть сообщение
pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
        GetPlayerIp(playerid,pIP[playerid],16);
        if(!response) Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
        new INI:iFile = INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
        INI_SetTag(iFile,"data");
        INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
        #if defined AUTOLOGIN
            INI_WriteString(iFile,"IP",pIP[playerid]);
        #endif
        INI_WriteInt(iFile,"Cash",0);
        INI_WriteInt(iFile,"Score",0);
        INI_Close(iFile);
        pLogged[playerid] = 1;
        new iStr[128];
        format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
        SendClientMessage(playerid,yellow,iStr);
        return 1;
    }
This one?
This is the code for when player presses a button on register dialog, but where do you show it?
Reply
#9

Quote:
Originally Posted by Firo
Посмотреть сообщение
pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
        GetPlayerIp(playerid,pIP[playerid],16);
        if(!response) Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
        new INI:iFile = INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
        INI_SetTag(iFile,"data");
        INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
        #if defined AUTOLOGIN
            INI_WriteString(iFile,"IP",pIP[playerid]);
        #endif
        INI_WriteInt(iFile,"Cash",0);
        INI_WriteInt(iFile,"Score",0);
        INI_Close(iFile);
        pLogged[playerid] = 1;
        new iStr[128];
        format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
        SendClientMessage(playerid,yellow,iStr);
        return 1;
    }
This one?
Um, place this one under OnPlayerDialogResponse....should work
Reply
#10

Use this
PHP код:
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Registration""Please input your desired password below""Ok"""); 
then put it here
PHP код:
public OnPlayerConnect(playerid
EDIT: Oh & Don't forget to define the dialog id for the DIALOG_REGISTER
PHP код:
#define DIALOG_REGISTER 4//Your desired dialog id 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)