[Help] Run time error 4: "Array index out of bounds"
#1

[02:06:02] [debug] Run time error 4: "Array index out of bounds"
[02:06:02] [debug] Accessing element at negative index -1
[02:06:02] [debug] AMX backtrace:
[02:06:02] [debug] #0 0018d65c in public CrimeDown () from rp.amx

PHP код:
public CrimeDown()
{
    for(new 
0MAX_PLAYERSi++)
    {
        new 
turned[MAX_PLAYER_NAME];
        new 
turnmes[256];
         
GetPlayerName(i,turned,sizeof(turned));
        if(
IsPlayerConnected(i))
        {
           if(
CharacterInfo[i][active_character[i]][cKadee]  > 0)
             {
                for(new 
0MAX_PLAYERSk++)
                {
                    if(
IsLaw(k) && duty[k] && CrimInRange(200.0i,k) && CharacterInfo[i][active_character[i]][cKadee] >= && WantedResetTimer[i] == 0)
                    {
                        
format(turnmessizeof(turnmes), ".: Wanted level %d :."CharacterInfo[i][active_character[i]][cKadee] );
                        
SendClientMessage(iCOLOR_YELLOWturnmes);
                         
SendClientMessage(iCOLOR_YELLOW" аѕГТРБХаЁйТЛ№йТ·ХиНВЩигЎЕй¤Ші ґТЗЁЦ§дБиЕґ");
                        
format(turnmessizeof(turnmes), "* бЁй§ИЩ№Вм: [%d]%s БХґТЗµФґµСЗ: %d ґТЗ",i,turnedCharacterInfo[i][active_character[i]][cKadee]);
                        
Sendpolice(turnmes);
                        
WantedResetTimer[i] = 1;
                        
WantedResetTimer2[i] = 10;
                    }
                    
SetTimerEx("SystemWanted"10000"d"i);
                }
            }
        }
    }

Reply
#2

pawn Код:
[active_character[i]]
If active_character[i] has value -1, then it crashes the server.

If you want to make sure though:
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The version 4.12 of crashdetect has been released in case you use 4.10

Update the plugin and create a file called "pawn.cfg" into the pawno directory. Open the file and write in it:
pawn Код:
-d3
Save the file and re-compile the scripts you use. Run your server again and show us again what it prints in the console/server log (It might gives extra information such as lines etc..)
Else change to:
pawn Код:
public CrimeDown()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        new turned[MAX_PLAYER_NAME];
        new turnmes[256];
        GetPlayerName(i,turned,sizeof(turned));
        if(IsPlayerConnected(i) && active_character[i] != -1)
        {
            if(CharacterInfo[i][active_character[i]][cKadee]  > 0)
            {
                for(new k = 0; k < MAX_PLAYERS; k++)
                {
                    if(IsLaw(k) && duty[k] && CrimInRange(200.0, i,k) && CharacterInfo[i][active_character[i]][cKadee] >= 1 && WantedResetTimer[i] == 0)
                    {
                        format(turnmes, sizeof(turnmes), ".: Wanted level %d :.", CharacterInfo[i][active_character[i]][cKadee] );
                        SendClientMessage(i, COLOR_YELLOW, turnmes);
                        SendClientMessage(i, COLOR_YELLOW, " аѕГТРБХаЁйТЛ№йТ·ХиНВЩигЎЕй¤Ші ґТЗЁЦ§дБиЕґ");
                        format(turnmes, sizeof(turnmes), "* бЁй§ИЩ№Вм: [%d]%s БХґТЗµФґµСЗ: %d ґТЗ",i,turned, CharacterInfo[i][active_character[i]][cKadee]);
                        Sendpolice(turnmes);
                        WantedResetTimer[i] = 1;
                        WantedResetTimer2[i] = 10;
                    }
                    SetTimerEx("SystemWanted", 1000, 0, "d", i);
                }
            }
        }
    }
}
and test it. It should be fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)