AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Run time error 4: index out of bounds (https://forums.alliedmods.net/showthread.php?t=294857)

alfinsh 03-09-2017 17:02

Run time error 4: index out of bounds
 
can somebody help me out with fixing these errors ?
Sorry , but only 5 min after post find this https://forums.alliedmods.net/showthread.php?t=107153
Please transfer if necessary.

Logs
Code:

L 03/09/2017 - 12:33:04: Start of error session.
L 03/09/2017 - 12:33:04: Info (map "c21_clr") (file "addons/amxmodx/logs/error_20170309.log")
L 03/09/2017 - 12:33:04: [AMXX] Displaying debug trace (plugin "kx_bcm_new.amxx")
L 03/09/2017 - 12:33:04: [AMXX] Run time error 4: index out of bounds
L 03/09/2017 - 12:33:04: [AMXX]    [0] kx_bcm_new.sma::BCM_Print (line 5967)
L 03/09/2017 - 12:33:04: [AMXX]    [1] kx_bcm_new.sma::SaveBlocks (line 5677)
L 03/09/2017 - 12:33:04: [AMXX]    [2] kx_bcm_new.sma::HandleOptionsMenu (line 3410)

Meta list
Code:

[ 1] AMX Mod X RUN - amxmodx_mm_i386. v1.8.2 ini Start ANY
[ 2] Orpheu RUN - orpheu_amxx_i386 v2.6.3 pl1 ANY ANY
[ 3] Fun RUN - fun_amxx_i386.so v1.8.2 pl1 ANY ANY
[ 4] Engine RUN - engine_amxx_i386 v1.8.2 pl1 ANY ANY
[ 5] FakeMeta RUN - fakemeta_amxx_i3 v1.8.2 pl1 ANY ANY
[ 6] CStrike RUN - cstrike_amxx_i38 v1.8.2 pl1 ANY ANY
[ 7] CSX RUN - csx_amxx_i386.so v1.8.2 pl1 ANY ANY
[ 8] Ham Sandwich RUN - hamsandwich_amxx v1.8.2 pl1 ANY ANY
[ 9] MySQL RUN - mysql_amxx_i386. v1.8.2 pl1 ANY ANY
9 plugins, 9 running

Version
Code:

Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
Exe build: 13:12:29 Aug 29 2013 (6153)

Error lines - marked Red
Code:

BCM_Print(id, const message_fmt[], any:...)
{
        static i; i = id ? id : GetPlayer();
        if ( !i ) return;
       
        static message[256], len;
        len = formatex(message, charsmax(message), "^4[%s %s]^3 ", PLUGIN_PREFIX, PLUGIN_VERSION);
        vformat(message[len], charsmax(message) - len, message_fmt, 3);
        message[192] = 0;
       
        static msgid_SayText;
        if ( !msgid_SayText ) msgid_SayText = get_user_msgid("SayText");
       
        static const team_names[][] =
        {
                "",
                "TERRORIST",
                "CT",
                "SPECTATOR"
        };
       
        static team; team = get_user_team(i);
       
        TeamInfo(i, id, team_names[0]);
       
        message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgid_SayText, _, id);
        write_byte(i);
        write_string(message);
        message_end();
       
        TeamInfo(i, id, team_names[team]);
}

Code:

SaveBlocks(id)
{
        if ( !g_admin[id] )
        {
                console_print(id, "You have no access to that command");
                return PLUGIN_HANDLED;
        }
       
        new ent;
        new file;
        new data[128];
        new block_count;
        new tele_count;
        new light_count;
        new block_type;
        new size;
        new property1[5], property2[5], property3[5], property4[5];
        new tele;
        new Float:origin[3];
        new Float:angles[3];
        new Float:tele_start[3];
        new Float:tele_end[3];
        new Float:max_size;
        new Float:size_max[3];
       
        file = fopen(g_file, "wt");
       
        block_count = 0;
        tele_count = 0;
       
        ent = -1;
        while ( ( ent = find_ent_by_class(ent, g_block_classname) ) )
        {
                block_type = entity_get_int(ent, EV_INT_body);
                entity_get_vector(ent, EV_VEC_origin, origin);
                entity_get_vector(ent, EV_VEC_angles, angles);
                entity_get_vector(ent, EV_VEC_maxs, size_max);
               
                GetProperty(ent, 1, property1);
                GetProperty(ent, 2, property2);
                GetProperty(ent, 3, property3);
                GetProperty(ent, 4, property4);
               
                if ( !property1[0] ) copy(property1, charsmax(property1), "/");
                if ( !property2[0] ) copy(property2, charsmax(property2), "/");
                if ( !property3[0] ) copy(property3, charsmax(property3), "/");
                if ( !property4[0] ) copy(property4, charsmax(property4), "/");
               
                max_size = size_max[0] + size_max[1] + size_max[2];
               
                if ( max_size > 128.0 )                size = LARGE;
                else if ( max_size > 64.0 )        size = NORMAL;
                else                                size = TINY;
               
                formatex(data, charsmax(data), "%c %f %f %f %f %f %f %d %s %s %s %s^n",\
                        g_block_save_ids[block_type],\
                        origin[0],\
                        origin[1],\
                        origin[2],\
                        angles[0],\
                        angles[1],\
                        angles[2],\
                        size,\
                        property1,\
                        property2,\
                        property3,\
                        property4
                        );
                fputs(file, data);
               
                ++block_count;
        }
       
        ent = -1;
        while ( ( ent = find_ent_by_class(ent, g_destination_classname) ) )
        {
                tele = entity_get_int(ent, EV_INT_iuser1);
                if ( tele )
                {
                        entity_get_vector(tele, EV_VEC_origin, tele_start);
                        entity_get_vector(ent, EV_VEC_origin, tele_end);
                       
                        formatex(data, charsmax(data), "* %f %f %f %f %f %f^n",\
                                tele_start[0],\
                                tele_start[1],\
                                tele_start[2],\
                                tele_end[0],\
                                tele_end[1],\
                                tele_end[2]
                                );
                        fputs(file, data);
                       
                        ++tele_count;
                }
        }
       
        ent = -1;
        while ( ( ent = find_ent_by_class(ent, g_light_classname) ) )
        {
                entity_get_vector(ent, EV_VEC_origin, origin);
               
                GetProperty(ent, 1, property1);
                GetProperty(ent, 2, property2);
                GetProperty(ent, 3, property3);
                GetProperty(ent, 4, property4);
               
                formatex(data, charsmax(data), "! %f %f %f / / / / %s %s %s %s^n",\
                        origin[0],\
                        origin[1],\
                        origin[2],\
                        property1,\
                        property2,\
                        property3,\
                        property4
                        );
                fputs(file, data);
               
                ++light_count;
        }
       
        static name[32];
        get_user_name(id, name, charsmax(name));
       
        for ( new i = 1; i <= g_max_players; ++i )
        {
                if ( g_connected[i] && ( g_admin[i] || g_gived_access[i] ) )
                {
                        BCM_Print(i, "^1%s^3 saved^1 %d block%s^3,^1 %d teleport%s^3 and^1 %d light%s^3! Total entites in map:^1 %d", name, block_count, block_count == 1 ? g_blank : "s", tele_count, tele_count == 1 ? g_blank : "s", light_count, light_count == 1 ? g_blank : "s", entity_count());
                }

        }
       
        fclose(file);
        return PLUGIN_HANDLED;
}

Code:

public HandleOptionsMenu(id, key)
{
        switch ( key )
        {
                case K1: ToggleSnapping(id);
                case K2: ToggleSnappingGap(id);
                case K3: GroupBlockAiming(id);
                case K4: ClearGroup(id);
                case K5:
                {
                        if ( g_admin[id] )        ShowChoiceMenu(id, CHOICE_DELETE, "Are you sure you want to delete all blocks and teleports?");
                        else                        ShowOptionsMenu(id);
                }
                case K6: SaveBlocks(id);
                case K7:
                {
                        if ( g_admin[id] )        ShowChoiceMenu(id, CHOICE_LOAD, "Loading will delete all blocks and teleports, do you want to continue?");
                        else                        ShowOptionsMenu(id);
                }

                case K0: ShowMainMenu(id);
        }
       
        if ( key != K5 && key != K7 && key != K0 ) ShowOptionsMenu(id);
}


grs4 03-10-2017 10:15

Re: Run time error 4: index out of bounds
 
change in bcmprint
PHP Code:

if ( !) return; 

to
PHP Code:

if ( !(<= <= 32) ) return; 

how often errors are thrown?


All times are GMT -4. The time now is 17:58.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.