SA-MP Forums Archive
Need help plz - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help plz (/showthread.php?tid=549401)



Need help plz - AYOUYOU - 06.12.2014

Hi there, I have a small problem but I do not know how to fix it when the user want Register
The Problem is When player Register if they Don't do the password he can Login


Please +rep For help
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(response)
            {
                     new
                    string[179],pFile[35];

                                format(pFile, 35, Player_File, GetName(playerid));

                         new
                                INI:UserFile = INI_Open(pFile);

                                INI_WriteInt(UserFile, "Password", udb_hash(inputtext));
                                INI_WriteInt(UserFile, "Admin", 0);
                                INI_WriteInt(UserFile, "Money", START_MONEY);
                                INI_WriteInt(UserFile, "Score", 0);
                                INI_WriteInt(UserFile,"Skin",0);
                                INI_WriteInt(UserFile, "Warn", 0);
                                INI_WriteInt(UserFile, "VIP", 0);
                                INI_WriteInt(UserFile,"NewReg",0);

                                INI_Close(UserFile);

                                SetPVarInt(playerid, "Registered", 1);
                                SetPVarInt(playerid, "Logged", 1);
                                P_Data[playerid][NewReg] = 1;
                                SpawnPlayer(playerid);

                    format(string, 125, ""COL_YELLOW"Name: "COL_WHITE"%s "COL_YELLOW"Password: "COL_WHITE"%s "COL_YELLOW"succesfuly registerd", GetName(playerid), inputtext);
                    SCM(playerid, 0x007C381F, string);
                    SCM(playerid, 0x22B998AA,"You are now registered and have been automaticaly logged in!");
                    SpawnPlayer(playerid);
            }
            else Kick(playerid);
        }

        case DIALOG_LOGIN:
        {
            if(response)
            {
                        new
                    pFile[35],dialog[128];

                                format(pFile, 35, Player_File, GetName(playerid));

                                INI_ParseFile(pFile, "LoadPlayerData", .bExtra = true, .extra = playerid);


                                if(udb_hash(inputtext) == P_Data[playerid][pPassword])
                                {
                                SetPVarInt(playerid, "Logged", 1);
                                SCM(playerid,0x00926F38,"Succesfuly login!");
                                }
                                        else
                                {
                                format(dialog, sizeof(dialog),"{B9C9BF}Welcome back to X1treme Stunting!\n\n{EBFFC9}Account:   {FFFFFF}%s\n\n{FFFFFF}Please enter your password below", GetName(playerid));
                                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{FF4444}Login -X1treme-Stunting",dialog, "Login", "");
                                }
                }
            else Kick(playerid);
        }
        case DIALOG_CLICK:
        {
                if(!response) return SCM(playerid,-1,"Dialog is closed");
                new
                    text[128];
                switch(listitem)
                {
                                case 0: {
                                Kick(GetPVarInt(playerid,"pplayerid"));
                                SetPVarInt(playerid,"pplayerid",999);
                                format(text,sizeof(text),"Admin %s is kick you from server!",GetName(playerid));
                                SCM(GetPVarInt(playerid,"pplayerid"),-1,text);}
                                case 1: {
                                Ban(GetPVarInt(playerid,"pplayerid"));
                                SetPVarInt(playerid,"pplayerid",999);
                                format(text,sizeof(text),"Admin %s is ban you from server!",GetName(playerid));
                                SCM(GetPVarInt(playerid,"pplayerid"),-1,text);                          }
                                case 2: {
                                ShowPlayerDialog(playerid,DIALOG_ADMIN,DIALOG_STYLE_INPUT,"Admin Control Panel","Type admin level [1-5]","Make","Лxit");
                                }
                        }
             }
                        case DIALOG_ADMIN:
                {
            if(!response) return SCM(playerid,-1,"Dialog is closed");
                        new
                                string[128];
            P_Data[GetPVarInt(playerid,"pplayerid")][pAdmin] = strval(inputtext);
                        format(string,sizeof(string),"Now you are admin level %d",strval(inputtext));
                        SCM(GetPVarInt(playerid,"pplayerid"),-1,string);
                        format(string,sizeof(string),"Player %s is now admin level %d",GetName(GetPVarInt(playerid,"pplayerid")),strval(inputtext));
                        SCM(playerid,-1,string);
                        SetPVarInt(playerid,"pplayerid",999);
                }
                        case RCON_DIALOG:
                {
            if(!response) return SCM(playerid,-1,"Dialog is closed");
                        new
                                string[128];
                                switch(listitem)
                                {
                                case 0: {//Server name
                ShowPlayerDialog(playerid,RCON_DIALOG+1,DIALOG_STYLE_INPUT,"Server name","Type new server name","Insert","Exit");
                                }
                                case 1: {//Map name
                ShowPlayerDialog(playerid,RCON_DIALOG+2,DIALOG_STYLE_INPUT,"Map name","Type new map name","Insert","Exit");
                                }
                                case 2: {//Web adress
                ShowPlayerDialog(playerid,RCON_DIALOG+3,DIALOG_STYLE_INPUT,"Web adress","Type new web adress","Insert","Exit");
                                }
                                case 3: {//Unlock
                                SendRconCommand("password 0");
                                }
                                case 4: {//lock
                                ShowPlayerDialog(playerid,RCON_DIALOG+4,DIALOG_STYLE_INPUT,"LOCK server","Type password for server","Insert","Exit");
                                }
                                case 5: {//GMX
                                format(string,sizeof(string),"Admin %s has restart server",GetName(playerid));
                                SCMToAll(-1,string);
                                SendRconCommand("gmx");
                                }
                                case 6: {//Password
                                ShowPlayerDialog(playerid,RCON_DIALOG+5,DIALOG_STYLE_INPUT,"Change password","Type new RCON password","Insert","Exit");
                                }
                                case 7: {//Turn Off
                                format(string,sizeof(string),"Admin %s has shutted down server",GetName(playerid));
                                SCMToAll(-1,string);
                                SendRconCommand("exit");
                                }
                                }
                        }
                case RCON_DIALOG+1:
                        {
                        new string[32];
                        //format(string, 16, "hostname %s",inputtext);
                        SendRconCommand(string);
                        }
                case RCON_DIALOG+2:
                        {
                        new string[32];
                        format(string, 16, "mapname %s",inputtext);
                        SendRconCommand(string);
                        }
                case RCON_DIALOG+3:
                        {
                        new string[32];
                        format(string, 16, "weburl %s",inputtext);
                        SendRconCommand(string);
                        }
                case RCON_DIALOG+4:
                        {
                        new string[32];
                        format(string, 16, "password %s",inputtext);
                        SendRconCommand(string);
                        }
                case RCON_DIALOG+5:
                        {
                        new string[32];
                        format(string, 16, "rcon_password %s",inputtext);
                        SendRconCommand(string);
                         }
                        }



Re: Need help plz - M4D - 06.12.2014

Ondialogresponse:

if(strlen(inputtext) < 3) return showplayerdialog…. (Your register dialog)


Re : Need help plz - ManuelNeuer - 06.12.2014

pawn Код:
if(!response) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"");



Re : Need help plz - AYOUYOU - 06.12.2014

More explain plz


Re: Re : Need help plz - M4D - 06.12.2014

Quote:
Originally Posted by ManuelNeuer
Посмотреть сообщение
pawn Код:
if(!response) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"");
No !
He said they don't enter any password and press register and register with null password !

To avoid this i told above

Before writing player file use strlen function to get inputtext (the password that player entered) length and then if it wasn't more 3 character , reshow register dialog


Re: Need help plz - Raweresh - 06.12.2014

Change it:
Код:
if(udb_hash(inputtext) == P_Data[playerid][pPassword])
To:
Код:
if(string[0] && udb_hash(inputtext) == P_Data[playerid][pPassword])
And add this in register dialog:
Код:
if(string[0])
{
//Register player code
}
else
{
//Error, no password entered.
}



Re : Need help plz - MariemAyedi1997 - 06.12.2014

Find
forward UserDataLoad_user(playerid, name[], value[]);
public UserDataLoad_user(playerid, name[], value[])
Change to
forward UserDataLoad_data(playerid, name[], value[]);
public UserDataLoad_data(playerid, name[], value[])


Re: Need help plz - Sawalha - 06.12.2014

pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"");



Re : Re: Need help plz - AYOUYOU - 06.12.2014

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"");
pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"");
Код:
C:\Documents and Settings\Administrateur\Bureau\Nouveau dossier (3)\gamemodes\xD.pwn(1196) : error 017: undefined symbol "inputtext"
C:\Documents and Settings\Administrateur\Bureau\Nouveau dossier (3)\gamemodes\xD.pwn(1196) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Administrateur\Bureau\Nouveau dossier (3)\gamemodes\xD.pwn(1196) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Administrateur\Bureau\Nouveau dossier (3)\gamemodes\xD.pwn(1196) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: Need help plz - Sawalha - 06.12.2014

oh, i didn't know that dialog code is broken, just replace it with your own register dialog..
P.S: where did you put it? put it under the DIALOG_REGISTER statement ("case DIALOG_REGISTER:" ) Under it.