loadbans stock crashing the server
#1

pawn Код:
stock LoadTempBans()
{
    printf("[System] Loading Bans's....");
    new line[1024];
    for(new id = 0; id < MAX_BANS; id++)
    {
        format(GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM Bans WHERE Banid = %d", id);
        mysql_query(GlobalQuery);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
            if(mysql_fetch_row(line))
            {
            sscanf(line,"p<|>ds[24]s[16]ds[75]",TempBans[id][Banid],TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate],TempBans[id][Reason]);
            if(strlen(TempBans[id][BannedName]) > 0) Bancount++;
            }
        }
    }
    return 1;
}
its crashing it.. idk why. it prints loading bans then crashes.
Reply
#2

Well that is a LOT of separate queries being executed extremely fast. Not sure it would cause the server to crash though, I'd recommend just doing one query, and working from that.

pawn Код:
stock LoadTempBans()
{
    printf("[System] Loading Bans's....");
    new line[1024];
    mysql_query("SELECT * FROM `bans`");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(line))
        {
            sscanf(line,"p<|>ds[24]s[16]ds[75]",TempBans[id][Banid],TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate],TempBans[id][Reason]);
            if(strlen(TempBans[id][BannedName]) > 0) Bancount++;
        }
    }
    return 1;
}
So now it's just one query that gets all of the information, and works with that. Should definitely help with processing time.
Reply
#3

how about the id define?

TempBans[id][Banid}
"id" part?

i'll have to make new vars?
Reply
#4

pawn Код:
stock LoadTempBans()
{
    printf("[System] Loading Bans's....");
    new line[1024];
    for(new id = 0; id < MAX_BANS; id++)
    {
        format(GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM Bans WHERE Banid = %d", id);
        mysql_query(GlobalQuery);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
            if(mysql_fetch_row(line))
            {
            sscanf(line,"p<|>ds[24]s[16]ds[75]",TempBans[id][Banid],TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate],TempBans[id][Reason]);
            if(strlen(TempBans[id][BannedName]) > 0) Bancount++;
            }
        }
    }
    return 1;
}
What is line? It has 1024 bytes and yet, apparent to that code, it has nothing in it? Yet you are querying it?
Reply
#5

Just add a counter in the while loop for that I guess.

pawn Код:
stock LoadTempBans()
{
    printf("[System] Loading Bans's....");
    new line[1024];
    new id = 0;
    mysql_query("SELECT * FROM `bans`");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(line))
        {
            sscanf(line,"p<|>ds[24]s[16]ds[75]",TempBans[id][Banid],TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate],TempBans[id][Reason]);
            if(strlen(TempBans[id][BannedName]) > 0) Bancount++;
            id++;
        }
    }
    return 1;
}
Reply
#6

i think the select is the problem.. kinda edited to my version o.0
test1 doesn't print. weird? the table is in database.
pawn Код:
stock LoadTempBans()
{
    printf("[System] Loading Bans's....");
    new line[1024],Bvar[2],Bstr[3][80];
    mysql_query("SELECT * FROM Bans");
    mysql_store_result();
    printf("Test1");
    if(mysql_num_rows() > 0)
    {
        printf("Test2");
        while(mysql_fetch_row(line))
        {
            printf("Test3");
            sscanf(line,"p<|>ds[24]s[16]ds[75]",Bvar[0],Bstr[0],Bstr[1],Bvar[1],Bstr[2]);
            if(strlen(Bstr[0]) > 0) Bancount++;
            Bvar[0] = TempBans[Bancount][Banid];
            Bvar[1] = TempBans[Bancount][UnbanDate];
            format(TempBans[Bancount][BannedName], 24, "%s",Bstr[0]);
            format(TempBans[Bancount][BannedIP],17,"%s",Bstr[1]);
            format(TempBans[Bancount][Reason],75,"%s",Bstr[2]);
            printf("Banid:%d, Unbandate:%d, Name:%s, IP:%s, Reason:%s",TempBans[Bancount][Banid],
            TempBans[Bancount][UnbanDate],TempBans[Bancount][BannedName],TempBans[Bancount][BannedIP],
            TempBans[Bancount][Reason]);
        }
    }
    printf("Finished");
    return 1;
}
crashinfo

pawn Код:
SA-MP Server: 0.3c RC2



Exception At Address: 0x00BA424A



Registers:

EAX: 0x00000000 EBX: 0x0159463C ECX: 0x0012EA00 EDX: 0x00000000

ESI: 0x0115DC18 EDI: 0x0115DC18 EBP: 0x0012E9EC ESP: 0x0012E9B8

EFLAGS: 0x00010202



Stack:

+0000: 0x0115DC18   0x00000000   0x0012E9FC   0x0115DC18

+0010: 0x0159463C   0x0012EA3F   0x7FFFFFBF   0x0012EA00

+0020: 0x00000042   0x0012ED4C   0x0014E914   0x0012EA18

+0030: 0x77E7F82C   0x0012EA90   0x00BA783F   0x00000000

+0040: 0x0012EA00   0x00000004   0x636E7546   0x6E6F6974

+0050: 0x796D203A   0x5F6C7173   0x72657571   0x61632079

+0060: 0x64656C6C   0x65687720   0x6F6E206E   0x6F632074

+0070: 0x63656E6E   0x20646574   0x61206F74   0x6420796E

+0080: 0x62617461   0x00657361   0xFFFFFFFF   0x0115DC18

+0090: 0x0021F56C   0x01676988   0x0159463C   0x00000FE4

+00A0: 0x00483E94   0x004F3A93   0x00000FFF   0x018E924C

+00B0: 0x0115DC18   0x019473C0   0x0012EA88   0x00486421

+00C0: 0x004B53AC   0x004F3A78   0x0115DC18   0x95605742

+00D0: 0x00000000   0x0012EA90   0x01676A34   0x00401096

+00E0: 0x0115DC18   0x01945FE0   0x016C9CE0   0x00402BB3

+00F0: 0x0115DC18   0x00000040   0x0012EAC8   0x01945FE0

+0100: 0x0012EF5C   0x00000000   0x00000000   0x0115DC18

+0110: 0x0021F5DC   0x0027C314   0x0027C300   0x0027D760

+0120: 0x002518A4   0x0027D6E8   0x002518A4   0x0159463C

+0130: 0x016C9CE0   0x00000000   0x01590020   0x001356A4
its stopping here mysql_query("SELECT * FROM Bans");
Reply
#7

Not sure what's the issue there, are you sure the right database is selected, containing the right tables? It's probably good practice to put the table name in backquotes too.

pawn Код:
mysql_query("SELECT * FROM `Bans`");
It might be having a problem with the syntax, try enabling MySQL logging and check mysql_log.txt when the crash happens, it should provide much more detailed information on the problem
Reply
#8

nothing in the log, i do this right after i load the bonus fish from a diff table.
pawn Код:
[18:26:52] Bonus Fish:Gold Fish
[18:26:52] [System] Loading Bans's....
[18:26:52] Test0

[Wed Dec 01 18:26:51 2010] -------------------------
[Wed Dec 01 18:26:51 2010]      Logging Started
[Wed Dec 01 18:26:51 2010] -------------------------
Reply
#9

Use mysql_debug(true); in your script in OnGameModeInit, then it'll log errors for MySQL in mysql_log.txt!
Reply
#10

L gstylezz plugin isnt giving errors.. its fixed now, i was using stricken kids plugin. tyvm
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)