Why does this crash my server?
#1

Hello,

Im having a problem loading my clubs. It just simply crashes my server..
The Crashdetect backtrace traces NOTHING. This is my code:
pawn Код:
forward LoadClubs();
public LoadClubs()
{
    new rows, fields, i=0;
    cache_get_data( rows, fields, Handle);
    if(!rows)
    {
        print("Clubs table is empty, no results found.");
        return 1;
    }
    while(rows > i < MAX_CLUBS)
    {
        AClubData[i][ID] = cache_get_row_int(i, 0);
        cache_get_row(i, 2, AClubData[i][Owner], Handle, 24);
        AClubData[i][ClubX] = cache_get_row_float(i, 21);
        AClubData[i][ClubY] = cache_get_row_float(i, 22);
        AClubData[i][ClubZ] = cache_get_row_float(i, 23);
        AClubData[i][PickUpID] = CreateDynamicPickup(1273, 1, AClubData[i][ClubX], AClubData[i][ClubY], AClubData[i][ClubZ], -1);
    }
    return 1;
}
What could be wrong? D:
Reply
#2

that's all ?
Server crash while using this script ONLY ?
can't be, just make sure Plugins are loaded.
Reply
#3

Well it is... When i comment the line of the query it does NOT crash... :S
Reply
#4

Add prints, check logs, ... General debugging, really. On a side note, if you are only going to use 5 fields then you should select those five fields in your query explicitly instead of selecting - what I assume to be - the entire row.
Reply
#5

pawn Код:
while(rows > i < MAX_CLUBS)
Why not just use this...?

pawn Код:
for(new i = 0; i < MAX_CLUBS; i++)
The while() loop you have is likely what's causing the crash.
Reply
#6

@RealCop Thats how i did all of the loadings... This is the first thing to crash. D:
Reply
#7

Okay update on what happens: I join. It kicks me reason: Kicking 127.0.0.1 because they didn't log on to the game.
Then it gives out TWICE Server crashed while excecuting ET.amx
AMX backtrace:
NOTHING HERE.
Reply
#8

The problem is probably on the while loop. An endless looping could very easily crash the server. Now I don't really know what you want to do exactly but perhaps you should add ++i; or something to make the loop possible. Because right now the loop is like saying

while(5 > 1 < 5) {
// Then your functions go there
}

And basically it redoes exactly the same thing forever
while(5 > 1 < 5) {
// Then your functions go there
}

Unless you state something to get higher/lower each time so the loop will come possible.

Hope this helps.
Reply
#9

But the max_clubs is 100 and the rows is just 1... So does that still make sense?
Reply
#10

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
pawn Код:
while(rows > i < MAX_CLUBS)
Why not just use this...?

pawn Код:
for(new i = 0; i < MAX_CLUBS; i++)
The while() loop you have is likely what's causing the crash.
It exactly is. You're using the while control structure as a logic structure.
Mainly all whiles are used with only 1 condition,
and then the next conditions are within the while.
Because while only returns true or false, so yea...
Thats the main cause of the crash.
(Longer explanation: http://www.tutorialspoint.com/java/j...op_control.htm)

Try this:
pawn Код:
while(i < MAX_CLUBS)
    {
        if(rows > i)
        {
            AClubData[i][ID] = cache_get_row_int(i, 0);
            cache_get_row(i, 2, AClubData[i][Owner], Handle, 24);
            AClubData[i][ClubX] = cache_get_row_float(i, 21);
            AClubData[i][ClubY] = cache_get_row_float(i, 22);
            AClubData[i][ClubZ] = cache_get_row_float(i, 23);
            AClubData[i][PickUpID] = CreateDynamicPickup(1273, 1, AClubData[i][ClubX], AClubData[i][ClubY], AClubData[i][ClubZ], -1);
        }
        else break;
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)