Array Index Out of bounds
#1

pawn Код:
public ShowMotd(playerid)
{
    PlayerTextDrawShow(playerid, PlayerText:Textdraw0[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw1[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw2[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw3[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw4[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw5[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw6[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw7[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw8[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw9[playerid]);
    PlayerTextDrawShow(playerid, PlayerText:Textdraw10[playerid]);
    SetTimer("DestoryMotd", 5000, false);

    return 1;
}

public DestoryMotd(playerid)
{
    PlayerTextDrawHide(playerid, PlayerText:Textdraw0[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw1[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw2[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw3[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw4[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw5[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw6[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw7[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw8[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw9[playerid]);
    PlayerTextDrawHide(playerid, PlayerText:Textdraw10[playerid]);

    return 1;
}

public OnPlayerBanEx(playerid, banstr[MAX_PLAYER_NAME], reason[MAX_STR_LENGTH], ipban)
{
    new
        rows, fields;

    cache_get_data(rows, fields);
    if(!rows)
    {
        static
            str[MAX_STR_LENGTH*2];

        new
            target = GetPlayerID(banstr),
            query[MAX_QUERY_LENGTH],
            date[MAX_DATE_LENGTH], year, month, day;

        getdate(year, month, day);
        format(date, sizeof(date), "%02d/%02d/%04d", day, month, year);
       
        if(ipban == 0)
        {
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `bans` (`Username`, `BannedBy`, `Reason`, `Date`) VALUES ('%e', '%e', '%e', '%e')",
                banstr, Name[playerid], reason, date);
            mysql_tquery(mysql, query, "");

            format(str, sizeof(str), " %s (ID:%d) has been Banned by Admin %s (ID:%d) for %s", banstr, target, GetName(playerid), playerid, reason);
            SCMToAll(COLOR_RED, str);
            LogIt("Ban", str);
            Kick(target);
        }
        else
        {
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `bans` (`IP`, `BannedBy`, `Reason`, `Date`) VALUES ('%e', '%e', '%e', '%e')",
                banstr,Name[playerid], reason, date);
            mysql_tquery(mysql, query, "");

            if(target != -1)
            {
                format(str, sizeof(str), "%s (ID:%d) has been IP Banned by Admin %s (ID:%d) for %s", Name[target], target, GetName(playerid), playerid, reason);
                SCMToAll(-1, str);
                LogIt("BanIP", str);
                Kick(target);
            }
            else
            {
                format(str, sizeof(str), "IP Address %s has been banned by Admin %s (ID:%d) Reason: %s", banstr, GetName(playerid), playerid, reason);
                SCMToAdmins(COLOR_RED, str);
                LogIt("BanIP", str);
                Kick(target);
            }
        }

        CheckPlayerBan(banstr);
    }
    else return SCM(playerid, 0xFF0000FF, "Error: Username or IP Address has already been banned!");
    return 1;
}


stock CheckPlayerBan(banstr[MAX_PLAYER_NAME])
{
    new
        playerid = GetPlayerID(banstr),
        query[MAX_QUERY_LENGTH];

    mysql_format(mysql, query, sizeof(query), "SELECT * FROM `bans` WHERE `Username` = '%e' OR `IP` = '%e'", Name[playerid], IP[playerid]);
    mysql_tquery(mysql, query, "OnPlayerCheckBan", "s", banstr);
    return 1;
}
server logs

pawn Код:
[13:12:07] Command performed by ID 0: /stats 1
[13:12:15] Command performed by ID 1: /unban
[13:12:19] Command performed by ID 0: /car
[13:12:20] Command performed by ID 0: /get
[13:12:23] Command performed by ID 0: /bring
[13:12:25] Command performed by ID 1: /ban 1 .
[13:12:26] Command performed by ID 0: /loadrace PanZ
[13:12:26] race load: iRaces/PanZ.iR
[13:12:26] type: 0 location: 0.000000, 0.000000, 0.000000
[13:12:26] type: 0 location: 0.000000, 0.000000, 0.000000
[13:12:26] type: 0 location: 0.000000, 0.000000, 0.000000
[13:12:26] type: 0 location: 0.000000, 0.000000, 0.000000
[13:12:26] type: 0 location: 0.000000, 0.000000, 0.000000
[13:12:26] No object data
[13:12:28] Command performed by ID 0: /join
[13:12:30] Command performed by ID 1: /join
[13:12:48] Command performed by ID 1: /startrace
[13:12:55] Command performed by ID 1: /yellow
[13:12:58] Command performed by ID 1: /colors
[13:13:30] Command performed by ID 1: /slap
[13:13:36] Command performed by ID 1: /leave
[13:13:41] Command performed by ID 1: /cmy
[13:13:41] FFDD00AA color
[13:13:58] Command performed by ID 1: /setscore 1 1000
[13:14:03] Command performed by ID 1: /setscore 1 10000
[13:14:24] COME ON SHIT DISCONNECT IP: 197.36.63.7
[13:14:24] Race disconnect
[13:14:24] [part] Jeffy[DC] has left the server (1:2)
[13:14:24] [debug] Run time error 4: "Array index out of bounds"
[13:14:24] [debug]   Accessing element at negative index -1
[13:14:24] [debug] Backtrace:
[13:14:24] [debug] #0  000b0634 in CheckPlayerBan (banstr[24]=@0x00447ac4 "") at E:\OrigalX\gamemodes\Opticalx.pwn:9770
[13:14:24] [debug] #1  000b2800 in public OnPlayerBanEx (playerid=1, banstr[24]=@0x00447ac4 "", reason[128]=@0x00447aa8 "", ipban=0) at E:\OrigalX\gamemodes\Opticalx.pwn:10063
[13:14:24] [debug] Run time error 4: "Array index out of bounds"
[13:14:24] [debug]   Accessing element at negative index -1
[13:14:24] [debug] Backtrace:
[13:14:24] [debug] #0  000b0634 in CheckPlayerBan (banstr[24]=@0x00447ac4 "") at E:\OrigalX\gamemodes\Opticalx.pwn:9770
[13:14:24] [debug] #1  000b2800 in public OnPlayerBanEx (playerid=722484, banstr[24]=@0x00447aec "", reason[128]=@0x00447aec "", ipban=4487916, ... <1166643 variable arguments>) at E:\OrigalX\gamemodes\Opticalx.pwn:10063
[13:14:47] race load: iRaces/LS_Rooftop_Pro.iR
[13:14:47] type: -1 location: 0.000000, 0.000000, 0.000000
[13:14:47] type: -1 location: 0.000000, 0.000000, 0.000000
[13:14:47] type: -1 location: 0.000000, 0.000000, 0.000000
[13:14:47] type: -1 location: 0.000000, 0.000000, 0.000000
[13:14:47] type: -1 location: 0.000000, 0.000000, 0.000000
[13:14:47] No object data
[13:15:23] Incoming connection: 197.36.63.7:57432
[13:15:24] [join] Jeffy[DC] has joined the server (1:197.36.63.7)
[13:15:24] IP on connect: 197.36.63.7
[13:15:24] COME ON SHIT DISCONNECT IP: 197.36.63.7
[13:15:24] Race disconnect
[13:15:24] [part] Jeffy[DC] has left the server (1:2)
[13:15:25] [debug] Run time error 4: "Array index out of bounds"
[13:15:25] [debug]   Accessing element at index 4487916 past array upper bound 19
[13:15:25] [debug] Backtrace:
[13:15:25] [debug] #0  000ad79c in public ShowMotd (playerid=4487916) at E:\OrigalX\gamemodes\Opticalx.pwn:9547
[13:15:54] Command performed by ID 0: /unban jeffy[DC]
[13:16:16] Incoming connection: 197.36.63.7:62481
[13:16:17] [join] Jeffy[DC] has joined the server (1:197.36.63.7)
[13:16:17] IP on connect: 197.36.63.7
[13:16:18] [debug] Run time error 4: "Array index out of bounds"
[13:16:18] [debug]   Accessing element at index 4487916 past array upper bound 19
[13:16:18] [debug] Backtrace:
[13:16:18] [debug] #0  000ad79c in public ShowMotd (playerid=4487916) at E:\OrigalX\gamemodes\Opticalx.pwn:9547
[13:16:25] Command performed by ID 1: /cmy
[13:16:25] FFDD00AA color
[13:16:32] Command performed by ID 1: /rban
[13:16:35] Command performed by ID 1: /kcik
[13:16:37] Command performed by ID 1: /kick
[13:16:39] Command performed by ID 1: /kick 1 .
[13:16:40] COME ON SHIT DISCONNECT IP: 197.36.63.7
[13:16:40] Race disconnect
[13:16:40] [part] Jeffy[DC] has left the server (1:2)
[13:17:51] Incoming connection: 197.36.63.7:65208
[13:17:52] [join] Jeffy[DC] has joined the server (1:197.36.63.7)
[13:17:52] IP on connect: 197.36.63.7
[13:17:53] [debug] Run time error 4: "Array index out of bounds"
[13:17:53] [debug]   Accessing element at index 4487916 past array upper bound 19
[13:17:53] [debug] Backtrace:
[13:17:53] [debug] #0  000ad79c in public ShowMotd (playerid=4487916) at E:\OrigalX\gamemodes\Opticalx.pwn:9547
[13:18:01] Command performed by ID 1: /skin 230
[13:18:03] Command performed by ID 1: /ba
[13:18:05] Command performed by ID 1: /ban
[13:18:09] Command performed by ID 1: /mycookies
[13:18:18] Command performed by ID 1: /setcookies 1 10000
[13:18:23] Command performed by ID 1: /chp 1212 10
[13:18:28] Command performed by ID 1: /mycookies
[13:18:31] pickup pickedup: 0, 0, 0.000000, 0.000000, 0.000000
[13:18:35] Command performed by ID 1: /mycookies
[13:18:41] Command performed by ID 1: /chp 1212 100000000
[13:18:46] Command performed by ID 1: /dhp
[13:18:48] Command performed by ID 1: /chp 1212 100000000
[13:18:54] Command performed by ID 1: /a
[13:18:57] Command performed by ID 1: /announce
[13:19:00] Command performed by ID 1: /announce 1 10
[13:19:07] Command performed by ID 1: /announce 1 5 pgoo?
[13:19:09] *** IRC_OnUserJoinChannel (Bot ID 1): User Stephen (androirc@Be.alone) joined channel #yrs
[13:19:09] *** IRC_OnUserJoinChannel (Bot ID 2): User Stephen (androirc@Be.alone) joined channel #yrs
[13:19:09] *** IRC_OnUserSetChannelMode (Bot ID 1): User Poulet (poulet@cluck.cluck) on #yrs set mode: +v Stephen
[13:19:09] *** IRC_OnUserSetChannelMode (Bot ID 2): User Poulet (poulet@cluck.cluck) on #yrs set mode: +v Stephen
[13:19:13] Command performed by ID 1: /announce 10 pgoo?
[13:19:20] Command performed by ID 1: /announce  pgoo?
[13:19:23] Command performed by ID 1: /announce pgoo?
[13:19:30] Command performed by ID 1: /announce 5 pgoo?
[13:19:34] pickup pickedup: 0, 0, 0.000000, 0.000000, 0.000000
[13:19:47] Command performed by ID 1: /mycookies
[13:19:56] Command performed by ID 1: /ban 1 1
[13:20:11] Command performed by ID 1: /cmy
[13:20:11] FFDD00AA color
[13:20:33] Command performed by ID 1: /goto 0
[13:20:57] Command performed by ID 1: /kick 0
[13:20:59] Command performed by ID 1: /kick 0 .
[13:21:00] COME ON SHIT DISCONNECT IP: 192.168.1.2
[13:21:00] Race disconnect
[13:21:00] [part] JeaSon has left the server (0:2)
[13:21:09] Command performed by ID 1: /setlevel
[13:22:01] COME ON SHIT DISCONNECT IP: 197.36.63.7
[13:22:01] Race disconnect
[13:22:01] [part] Jeffy[DC] has left the server (1:2)
[13:22:01] [debug] Run time error 4: "Array index out of bounds"
[13:22:01] [debug]   Accessing element at negative index -1
[13:22:01] [debug] Backtrace:
[13:22:01] [debug] #0  000b0634 in CheckPlayerBan (banstr[24]=@0x00447ab0 "") at E:\OrigalX\gamemodes\Opticalx.pwn:9770
[13:22:01] [debug] #1  000b2800 in public OnPlayerBanEx (playerid=1, banstr[24]=@0x00447ab0 "", reason[128]=@0x00447aa8 "", ipban=0) at E:\OrigalX\gamemodes\Opticalx.pwn:10063
[13:22:01] [debug] Run time error 4: "Array index out of bounds"
[13:22:01] [debug]   Accessing element at negative index -1
[13:22:01] [debug] Backtrace:
[13:22:01] [debug] #0  000b0634 in CheckPlayerBan (banstr[24]=@0x00447ab0 "") at E:\OrigalX\gamemodes\Opticalx.pwn:9770
[13:22:01] [debug] #1  000b2800 in public OnPlayerBanEx (playerid=722484, banstr[24]=@0x00447ad8 "", reason[128]=@0x00447ad8 "", ipban=4487896, ... <1166638 variable arguments>) at E:\OrigalX\gamemodes\Opticalx.pwn:10063
[13:24:33] Incoming connection: 197.36.58.11:58908
[13:24:34] [join] Jeffy[DC] has joined the server (0:197.36.58.11)
[13:24:34] IP on connect: 197.36.58.11
[13:24:34] 041A956B469B5EAF56A719E1530535A435C15A9C88EF4CF95FBFCD851F4B4A01787B30F78960BBCCEB71F2EB12D4910562D9B681A307D77FFFB92DC34893B2E2
[13:24:35] COME ON SHIT DISCONNECT IP: 197.36.63.7
[13:24:35] Race disconnect
[13:24:35] [part] Jeffy[DC] has left the server (0:2)
[13:24:35] [debug] Run time error 4: "Array index out of bounds"
[13:24:35] [debug]   Accessing element at index 4487896 past array upper bound 19
[13:24:35] [debug] Backtrace:
[13:24:35] [debug] #0  000ad79c in public ShowMotd (playerid=4487896) at E:\OrigalX\gamemodes\Opticalx.pwn:9547
[13:26:08] *** IRC_OnUserJoinChannel (Bot ID 1): User Jeffy892 (Jeffy892@E530EE.19AD05.82AF28.80C45C) joined channel #yrs.admin
[13:26:08] *** IRC_OnUserJoinChannel (Bot ID 2): User Jeffy892 (Jeffy892@E530EE.19AD05.82AF28.80C45C) joined channel #yrs.admin
[13:26:08] *** IRC_OnUserSetChannelMode (Bot ID 1): User spork037 (james@covert.agent) on #yrs.admin set mode: +v Jeffy892
[13:26:09] *** IRC_OnUserSetChannelMode (Bot ID 2): User spork037 (james@covert.agent) on #yrs.admin set mode: +v Jeffy892
[13:29:51] race load: iRaces/BumbyRoads.iR
[13:29:52] type: 0 location: 0.000000, 0.000000, 0.000000
[13:29:52] type: 0 location: 0.000000, 0.000000, 0.000000
[13:29:52] type: 0 location: 0.000000, 0.000000, 0.000000
[13:29:52] type: 0 location: 0.000000, 0.000000, 0.000000
[13:29:52] type: 0 location: 0.000000, 0.000000, 0.000000
[13:29:52] No object data
Reply
#2

I am pretty sure you don't have to define an array size in your function header.
Reply
#3

Quote:
Originally Posted by Bible
Посмотреть сообщение
I am pretty sure you don't have to define an array size in your function header.
You don't have to, but you can if you know all of your variables are going to be the same size. If you don't define an array size you usually need to add a 'length = sizeof(var)' param so that you know the size of the variable.
Reply
#4

Quote:
Originally Posted by ev0lution
Посмотреть сообщение
You don't have to, but you can if you know all of your variables are going to be the same size. If you don't define an array size you usually need to add a 'length = sizeof(var)' param so that you know the size of the variable.
Isn't that what a constant variable is for? Or am I mixing stuff here?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)