sscanf2/cmd crash login dialogs
#1

Hello!

im using the login from the tutorial https://sampforum.blast.hk/showthread.php?tid=269361

When i include only #include <sscanf2> you can register and login.
Looks like this.


with the /settadmin command in the GM it looks like this.


And if you try to spawn it looks like this.


Here is the code i use when you cant login or spawn (im getting no warnings etc at all)
pawn Код:
CMD:setadmin(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
     if(IsPlayerAdmin(playerid))
        {
            new sendername[MAX_PLAYER_NAME];
            new giveplayername[MAX_PLAYER_NAME];
            new giveplayerid,level;
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            if (!sscanf(params, "ii", giveplayerid,level))
            {
                if (giveplayerid != INVALID_PLAYER_ID)
                {
                    new string[128];
                    format(string, sizeof(string), "The admin %s has made you a level %d admin",sendername,level);
                    SendClientMessage(giveplayerid, COLOR_GRAD1, string);
                    format(string, sizeof(string), "You have made %s a level %d admin",giveplayername,level);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                    pInfo[giveplayerid][Admin] = level;
                }
            }
            else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setadmin [playerid] [level] 1-5");
        }
        else SendClientMessage(playerid, 0xFF0000FF, "You are not a owner Admin!");
    }
    return 1;
}
Reply
#2

If you are using SAMP 0.3d then you dont have to use sscanf because its not updates for 0.3d.
Reply
#3

I don't think the command is the problem, most likely it's the login part.
Show it.
Reply
#4

Quote:
Originally Posted by WoodPecker
Посмотреть сообщение
If you are using SAMP 0.3d then you dont have to use sscanf because its not updates for 0.3d.
i use 0.3c R2, bc the most seams to use 0.3c up to R5 if you look in the client servers.
Reply
#5

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
I don't think the command is the problem, most likely it's the login part.
Show it.
pawn Код:
public OnPlayerConnect(playerid)
{
    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]);
                SendClientMessage(playerid,lime,"You've been auto-logged in. [IP match]");
                return 1;
            }
        #endif
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Please enter your password below.","Login","Leave");
    } else {
        ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please register by entering a password below.","Register","Leave");
    }
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    if(pLogged[playerid] == 0) return SendClientMessage(playerid,yellow,"You must register or login before spawning!");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    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));
        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",REGISTERED_MONEY);
        INI_WriteInt(iFile,"Score",0);
        INI_WriteInt(iFile,"Admin",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) {
            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]);
            GivePlayerMoney(playerid,pInfo[playerid][Cash]);
        } 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;
        }
        return 1;
    }
    return 1;
}
EDIT: i even tried a another cmd, it seams that if i use something like this "if(sscanf(params," it makes the dialogs crash :S
Reply
#6

Anyone? i really need help to continue all the important commands :/
it doesnt matter what ever cmd i put into the scrip that use "sscanf" the login dialog crash.
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
That happens when you have no AddPlayerClass lines.
True, but also not true in this case, not to be rude..but i told in first post that i CAN register and join IF i dont have any sscanf cmd in the script, and if i add one..just one sscanf cmd it happens what you told me about AddPlayerClass, but the point is that i have a AddPlayerClass line..
Reply
#8

Dont think this is causing bug but look into this
Quote:

if (!sscanf(params, "ii", giveplayerid,level))

And here
Quote:

format(string, sizeof(string), "You have made %s a level %d admin",giveplayername,level);

Im almost 95% sure you havge to use integrer for admin level
I would make it like this
PHP код:
if (!sscanf(params"di"giveplayerid,level))
//and
format(stringsizeof(string), "You have made %s a level %i admin",giveplayername,level);
format(stringsizeof(string), "The admin %s has made you a level %i admin",sendername,level); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)