INI_Int problem?
#1

Not sure what I am doing wrong.

Here's the code;
pawn Код:
if(fexist(UserPath(playerid)))
    {
        new INI:File = INI_Open(UserPath(playerid));
        if(INI_Int(File,"Status" == 2)
        {
            new string[128];
            format(string, sizeof(string), ""red"Your account has been banned!"white"\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", INI_String(file, "BannedBy"), INI_String(file, "BanReason"), INI_String(file, "BanDate"));
            ShowPlayerDialog(playerid, BAN_DIALOG, DIALOG_STYLE_MSGBOX, " ", string, "OK", "");
            KickEx(playerid);
            INI_Close(ini);
            return 0;
        }
        else
        {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
            SendClientMessage(playerid,X11_SLATEGREY, "Welcome to Valhalla's TDM Server. We hope you enjoy your stay.");
            return 1;
        }
        return 1;
    }
Error:
Quote:

412) : error 029: invalid expression, assumed zero
(412) : error 035: argument type mismatch (argument 1)
(412) : error 001: expected token: ";", but found "return"
(412) : fatal error 107: too many error messages on one line

Line 412:
pawn Код:
if(INI_Int(File,"Status" == 2)
Basically, it should check in the user ini file, if the status is 2 then it kicks them.
Reply
#2

I'm not sure this is how it works, but give this a try.
pawn Код:
if (INI_Int(File, "Status") == 2)
Reply
#3

Added that, the compiler crashes on compiling now?

pawn Код:
if(fexist(UserPath(playerid)))
    {
        new INI:File = INI_Open(UserPath(playerid));
        //if(INI_Int(File,"Status" == 2))
        if (INI_Int(File, "Status") == 2)
        {
            new string[128];
            format(string, sizeof(string), ""red"Your account has been banned!"white"\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", INI_String(file, "BannedBy"), INI_String(file, "BanReason"), INI_String(file, "BanDate"));
            ShowPlayerDialog(playerid, BAN_DIALOG, DIALOG_STYLE_MSGBOX, " ", string, "OK", "");
            KickEx(playerid);
            INI_Close(ini);
        }
        else
        {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
            SendClientMessage(playerid,X11_SLATEGREY, "Welcome to Valhalla's TDM Server. We hope you enjoy your stay.");
        }
        return 1;
    }
Reply
#4

I've commented pretty much everything;

pawn Код:
if(fexist(UserPath(playerid))) {
    new INI:File = INI_Open(UserPath(playerid));
    if (INI_Int(File, "Status") == 2) {
        //new string[128];
        //format(string, sizeof(string), ""red"Your account has been banned!"white"\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", INI_String(file, "BannedBy"), INI_String(file, "BanReason"), INI_String(file, "BanDate")); // <- It's probably this string crashing everything, try commenting it
        //Instead
        //format(string, sizeof(string), "{FF0000}Your account has been banned!{FFFFFF}\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", INI_String(file, "BannedBy"), INI_String(file, "BanReason"), INI_String(file, "BanDate"));
        //ShowPlayerDialog(playerid, BAN_DIALOG, DIALOG_STYLE_MSGBOX, " ", string, "OK", "");
        //KickEx(playerid);
        //INI_Close(ini);
    }
    /*else {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
        SendClientMessage(playerid,X11_SLATEGREY, "Welcome to Valhalla's TDM Server. We hope you enjoy your stay.");
    }*/

    return 1;
}
Still crashing.
Reply
#5

Recoded it slightly;

pawn Код:
new INI:File = INI_Open(UserPath(playerid));
    if (INI_Int(File, "Status") == 2) {
        new string[128];
        format(string, sizeof(string), "{FF0000}Your account has been banned!{FFFFFF}\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", INI_String(file, "BannedBy"), INI_String(file, "BanReason"), INI_String(file, "BanDate"));
        ShowPlayerDialog(playerid, BAN_DIALOG, DIALOG_STYLE_MSGBOX, " ", string, "OK", "");
        KickEx(playerid);
        INI_Close(ini);
    }
    /*else
    {
        if(fexist(UserPath(playerid)))

        {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
            SendClientMessage(playerid,X11_SLATEGREY, "Welcome to Valhalla's TDM Server. We hope you enjoy your stay.");
        }
        else
        {
        SendClientMessage(playerid,X11_SLATEGREY, "Welcome to Valhalla's TDM Server. We hope you enjoy your stay.");
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registration","Type your password below to register a new account.","Register","Quit");
        }
    }*/
The problem is with this
pawn Код:
if (INI_Int(File, "Status") == 2) {
Reply
#6

Right, so that's stopped the crashing.

pawn Код:
if(fexist(UserPath(playerid)))
    {
        new INI:File = INI_Open(UserPath(playerid));
        new status;
        INI_Int("Status", status);
        if(status == 2)
        {
            new string[128];
            format(string, sizeof(string), "{FF0000}Your account has been banned!{FFFFFF}\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", INI_String(File, "BannedBy"), INI_String(File, "BanReason"), INI_String(File, "BanDate"));
            ShowPlayerDialog(playerid, BAN_DIALOG, DIALOG_STYLE_MSGBOX, " ", string, "OK", "");
            KickEx(playerid);
            INI_Close(ini);
        } else {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
            SendClientMessage(playerid,X11_SLATEGREY, "Welcome to Valhalla's TDM Server. We hope you enjoy your stay.");
        }
        return 1;
    }
Quote:

A1.pwn(412) : error 017: undefined symbol "value"
A1.pwn(416) : error 029: invalid expression, assumed zero
A1.pwn(416) : error 035: argument type mismatch (argument 1)
A1.pwn(416) : error 001: expected token: ";", but found "return"
A1.pwn(416) : fatal error 107: too many error messages on one line

pawn Код:
INI_Int("Status", status);
pawn Код:
format(string, sizeof(string), "{FF0000}Your account has been banned!{FFFFFF}\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", INI_String(File, "BannedBy"), INI_String(File, "BanReason"), INI_String(File, "BanDate"));
Reply
#7

pawn Код:
stock IsPlayerBanned(playerid)
{
    new file[128];
    format(file, sizeof(file), "/%s/%s.ini", USRPATH GetName(playerid));
    /*INI_Int(file, "Status") == 2
    {
        return true;
    }
    else{
    return false;
    }*/

}
It's this line that causes it to crash, i've tried it in a stock.

INI_Int(file, "Status") == 2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)