SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Timer error (https://forum.sa-mp.com/showthread.php?t=677088)

_GHT_MarK445 29/06/2020 04:46 PM

Timer error
 
Hi guys, this is info, that I see in my server_log:
Code:

[18:46:08] [debug] Run time error 4: "Array index out of bounds"
[18:46:08] [debug]  Attempted to read/write array element at index 65535 in array of size 100
[18:46:08] [debug] AMX backtrace:
[18:46:08] [debug] #0 0004e060 in public miniguntimer () in jb.amx

And this is the code:
Code:

forward miniguntimer();
public miniguntimer()
{
        new string[128], mostkills = INVALID_PLAYER_ID;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && InEvent[i] == true)
            {
                        if(MgKills[i] > MgKills[mostkills]) mostkills = i;
                }
        }
        format(string, sizeof(string), "The player with Most Kills is %s with %d kills.", GetName(mostkills), MgKills[mostkills]);
        SendClientMessageToAll(MGDM, string);
        return 1;
}

Do you guys have any idea, what could be the problem?

GameOvr 29/06/2020 06:28 PM

Re: Timer error
 
Code:

mostkills = INVALID_PLAYER_ID
if(MgKills[i] > MgKills[mostkills])

If you still didnt understand the problem just repost I'll explain...

Here you go, I guess its a mistake
Code:

forward miniguntimer();
public miniguntimer()
{
    new string[128], mostkills = INVALID_PLAYER_ID;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && InEvent[i] == true)
        {
            if(mostkills == INVALID_PLAYER_ID) mostkills = i;
            if(MgKills[i] > MgKills[mostkills]) mostkills = i;
        }
    }
    format(string, sizeof(string), "The player with Most Kills is %s with %d kills.", GetName(mostkills), MgKills[mostkills]);
    SendClientMessageToAll(MGDM, string);
    return 1;
}



All times are GMT. The time now is 10:12 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.