AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Index : Out of bound (https://forums.alliedmods.net/showthread.php?t=295621)

ish12321 03-31-2017 06:51

Index : Out of bound
 
PHP Code:

enum _:WEAPONSWAR
{
    
WeaponType[64],
    
WeaponCommonName[64],
    
WeaponEntityName[64],
    
ItemID:WeaponItemID,
    
WeaponIdType:WeaponIDType,
    
WEAPON_BPAMMO
}

new const 
WeaponsData[][WEAPONSWAR] =
{
    {
"Hand-gun"        ,    "9x19mm Side-arm"    ,    "weapon_glock18"    ,    ITEM_GLOCK18,    WEAPON_GLOCK18    ,    120    }, 
    {
"Hand-gun"        ,    "KM.45 Tactical"    ,    "weapon_usp"        ,    ITEM_USP,        WEAPON_USP        ,    100    }, 
    {
"Hand-gun"        ,    "228 Compact"        ,    "weapon_p228"        ,    ITEM_P228,        WEAPON_P228        ,    52    },
    {
"Hand-gun"        ,    "Night Haw2.50c"    ,    "weapon_deagle"        ,    ITEM_DEAGLE,    WEAPON_DEAGLE    ,    35    }, 
    {
"Hand-gun"        ,    "Elites"            ,    "weapon_elite"        ,    ITEM_ELITE,        WEAPON_ELITE    ,    120    }, 
    {
"Hand-gun"        ,    "Five-Seven"        ,    "weapon_fiveseven"    ,    ITEM_FIVESEVEN,    WEAPON_FIVESEVEN,    100    },
    {
"Shotgun"        ,    "12 gauge"            ,    "weapon_m3"            ,    ITEM_M3    ,        WEAPON_M3        ,    32    }, 
    {
"Shotgun"        ,    "Auto-Shotgun"        ,    "weapon_xm1014"        ,    ITEM_XM1014,    WEAPON_XM1014    ,    32    },
    {
"Sub-machine"    ,    "TMP"                ,    "weapon_tmp"        ,    ITEM_TMP,        WEAPON_TMP        ,    120    },
    {
"Sub-machine"    ,    "MP5-Navy"            ,    "weapon_mp5navy"    ,    ITEM_MP5N,        WEAPON_MP5N        ,    120    },
    {
"Sub-machine"    ,    "KM-UMP45"            ,    "weapon_ump45"        ,    ITEM_UMP45,        WEAPON_UMP45    ,    100    },
    {
"Sub-machine"    ,    "ES-C90"            ,    "weapon_p90"        ,    ITEM_P90,        WEAPON_P90        ,    100    },
    {
"Sub-machine"    ,    "Ingram MAC-10"        ,    "weapon_mac10"        ,    ITEM_MAC10,        WEAPON_MAC10    ,    100    },
    {
"Rifles"        ,    "IDF-Defender"        ,    "weapon_galil"        ,    ITEM_GALIL,        WEAPON_GALIL    ,    90    },
    {
"Rifles"        ,    "Famas"                ,     "weapon_famas"        ,    ITEM_FAMAS,        WEAPON_FAMAS    ,    90    },
    {
"Rifles"        ,    "AK-47"                ,    "weapon_ak47"        ,    ITEM_AK47,        WEAPON_AK47        ,    90    },
    {
"Rifles"        ,    "M4A1"                ,    "weapon_m4a1"        ,    ITEM_M4A1,        WEAPON_M4A1        ,    90    },
    {
"Rifles"        ,    "Scout"                ,    "weapon_scout"        ,    ITEM_SCOUT,        WEAPON_SCOUT    ,    90    },
    {
"Rifles"        ,    "Ster-Aug"            ,    "weapon_aug"        ,    ITEM_AUG,        WEAPON_AUG        ,    90    },
    {
"Rifles"        ,    "Krieg 552"            ,    "weapon_sg552"        ,    ITEM_SG552,        WEAPON_SG552    ,    90    },
    {
"Rifles"        ,    "Krieg 550"            ,    "weapon_sg550"        ,    ITEM_SG550,        WEAPON_SG550    ,    90    },
    {
"Rifles"        ,    "Magnum"            ,    "weapon_awp"        ,    ITEM_AWP,        WEAPON_AWP        ,    30    },
    {
"Rifles"        ,    "D3/AU-1"            ,    "weapon_g3sg1"        ,    ITEM_G3SG1,        WEAPON_G3SG1    ,    90    },
    {
"Heavy"        ,    "Machine-gun"        ,    "weapon_m249"        ,    ITEM_M249,        WEAPON_M249        ,    200    },
    {
"Melee"        ,    "Knife"                ,    "weapon_knife"        ,    ITEM_KNIFE,        WEAPON_KNIFE    ,    0    },
    {
"Nade"            ,    "HE grenade"        ,    "weapon_hegrenade"    ,    ITEM_HEGRENADE,    WEAPON_HEGRENADE,    199    }


PHP Code:

public RG_Hook_GiveDefaultItems(const id)
{
135.    new WEAPONBPAMMO WeaponsData[CurrentWar][WEAPON_BPAMMO];

    
rg_remove_all_items(id);
    
rg_give_item(idWeaponsData[CurrentWar][WeaponEntityName]);

    if(
WEAPONBPAMMO 0)
    {
        
rg_set_user_bpammo(idWeaponsData[CurrentWar][WeaponIDType], WEAPONBPAMMO)
    }

    return 
HC_SUPERCEDE;


please help
PHP Code:

L 03/31/2017 06:12:06Start of error session.
L 03/31/2017 06:12:06Info (map "de_minidust2") (file "addons/amxmodx/logs/error_20170331.log")
L 03/31/2017 06:12:06: [AMXXDisplaying debug trace (plugin "cs_war.amxx"version "1.0")
L 03/31/2017 06:12:06: [AMXXRun time error 4index out of bounds 
L 03
/31/2017 06:12:06: [AMXX]    [0cs_war.sma::RG_Hook_GiveDefaultItems (line 135)
L 03/31/2017 06:13:01: [AMXXDisplaying debug trace (plugin "cs_war.amxx"version "1.0"


KiLLeR. 03-31-2017 07:27

Re: Index : Out of bound
 
What's hold CurrentWar? It seems that CurrentWar holds bigger value than size of WeaponsData.

You can try this and check what is happening?
PHP Code:

new WEAPONBPAMMO;
    if(
<= CurrentWar sizeof(WeaponsData))
    {
        
WEAPONBPAMMO WeaponsData[CurrentWar][WEAPON_BPAMMO]; 
    }
    else
    {
        
log_amx("[Error] Index: %i"CurrentWar);
    } 



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

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