AlliedModders

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

LithuanianJack 06-06-2019 02:54

Index out of bounds
 
1 Attachment(s)
Hello. I can't find what's wrong with this plugin. I will be grateful if anyone will help me.

HTML Code:

L 06/06/2019 - 09:44:59: [AMXX] Displaying debug trace (plugin "crcsgo.amxx", version "5.72")
L 06/06/2019 - 09:44:59: [AMXX] Run time error 4: index out of bounds
L 06/06/2019 - 09:44:59: [AMXX]    [0] crcsgo.sma::MenuHandler (line 1869)


PHP Code:

public MenuHandler(idgMenuitem)
{    
    if(
item == MENU_EXIT)
    {
        
MenuMod[id] = 0;
        
menu_destroy(gMenu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
aMenu[2], Data[4][32], sKey[32], Name[32], mName[32], Key;
    
menu_item_getinfo(gMenuitemaMenu[0], Data[0], 31Data[1], 31aMenu[1]);
    
    
parse(Data[0], sKey31);
    
Key str_to_num(sKey);
    
    switch(
MenuMod[id])
    {
        case -
2:
        {
            
MenuMod[id] = 5;
            
aThing[id] = Key;
            
            
Menu(id);
        }
        case -
1:
        {
            
MenuMod[id] = 3;
            
WeaponinMarket[id] = Key;
            
            
client_cmd(id"messagemode Cost");
            
            
Menu(id);
        }
        case 
0:
        {
            
MenuMod[id] = Key;
            
Menu(id);
            
        }
        case 
1:
        {
            
parse(Data[0], Data[2], 31Data[3], 31);
            
            if(
bUsingGuns[id][str_to_num(Data[3])] == str_to_num(Data[2])) {
                
bUsingGuns[id][str_to_num(Data[3])] = 0;
                
client_print_color(idprint_team_default"%L"LANG_PLAYER"SKIN_REMOVED"PrefixWeaponNames[str_to_num(Data[2])], szWeaponNames[str_to_num(Data[3])]);
                } else {
                
bUsingGuns[id][str_to_num(Data[3])] = str_to_num(Data[2]);
                
client_print_color(idprint_team_default"%L"LANG_PLAYER"SKIN_CHANGED"PrefixWeaponNames[str_to_num(Data[2])], szWeaponNames[str_to_num(Data[3])]);
                
set_task(0.1"UpdateStatusText"id);
            }
            
            static 
szQuery[512], szUGuns[128]; format(szUGunssizeof(szUGuns), "");        
            for(new 
iCSW_VESTHELMi++) { format(szUGunssizeof(szUGuns), "%s%d "szUGunsbUsingGuns[id][i]); }        
            
formatex(szQuerysizeof(szQuery), "UPDATE `%s` SET `using_skins` = '%s' WHERE `username` = '%s';"TABLE_NAMEszUGunsget_user_name_ex(id));
                    
            
SQL_ThreadQuery(g_hTuple"QuerySetData"szQuery);
            
            
log_errors("[SKIN CHANGE] %s"szQuery);
            
            
MenuMod[id] = 1;
            
Menu(id);
        }
        case 
2:
        {
            if(
Chest[id][(item+1)] <= 0)
            {
                
Chest[id][(item+1)] = 0;
                
                if(
pKey[id] < 0)
                    
pKey[id] = 0;
                
                return 
PLUGIN_CONTINUE;
            }
            
            
Chest[id][(item+1)]--;
            
pKey[id]--;
            
            new 
chest item+1;
            
            new 
Float:rNum random_float((random(5)*1.0), 175.0);
            new 
chance = (rNum <= 1.0) ? : ((rNum <= 5.0) ? : ((rNum <= 25) ? 25 100 ));
            
/////////////////////////////////////////// 
            
new skinsCnt chestsChance[chest][chance];
            new 
skinNum random(skinsCnt);
            new 
skinId chestsList[chest][chance][skinNum];
            
            new 
szName[32]; get_user_name(idszName31);
            
            
            if(
<= chance <= 25) { print_color(0"%L"LANG_PLAYER"FOUNDITEM_ALL"PrefixszNameWeaponNames[skinId], szWeaponNames[Weapons[skinId]]); }
            else { 
client_print_color(idprint_team_default"%L"LANG_PLAYER"FOUNDITEM_SELF"PrefixWeaponNames[skinId], szWeaponNames[Weapons[skinId]]); }
            
            
uWeapon[skinId][id]++;
            
SaveData(id);
            
            
Menu(id);
        }
        case 
3:
        {
            if(
Key == -1) { MenuMod[id] = -1Menu(id); }
            else if(
Key == 0)
            {
                if(
inMarket[id]) { inMarket[id] = false; }
                else if(
MarketPoints[id] > 0)
                {
                    if(
mAmount[id] < 1mAmount[id] = 1;
                    
get_user_name(idName31);
                    
                    switch(
WeaponinMarket[id])
                    {
                        case 
CHEST_ID..(CHEST_ID+CHEST_COUNT): { print_color(0"%L"LANG_PLAYER"TOMARKET_CHEST"PrefixNamemAmount[id], chest_name((WeaponinMarket[id]-CHEST_ID)+1), MarketPoints[id]); }
                        case 
KEY_ID: { print_color(0"%L"LANG_PLAYER"TOMARKET_KEY"PrefixNamemAmount[id], MarketPoints[id]); }
                        default: { 
print_color(0"%L"LANG_PLAYER"TOMARKET_SKIN"PrefixNameWeaponNames[WeaponinMarket[id]], szWeaponNames[Weapons[WeaponinMarket[id]]], MarketPoints[id]); }
                    }
                    
                    
inMarket[id] = true;
                }
                
gLastMarketTime[id] = get_systime();
                
Menu(id);
            }
            
            
            else if(
Key == -99)
            {
                
client_cmd(id"messagemode setMarketAmount");
            }
            else if(
inMarket[Key] && Points[id] >= MarketPoints[Key])
            {
                
get_user_name(KeyName31); get_user_name(idmName31);
                
                if(
WeaponinMarket[Key] < CHEST_ID)
                {
                    if(
uWeapon[WeaponinMarket[Key]][Key] <= 0)
                    {
                        
inMarket[Key] = false;
                        
MarketPoints[Key] = 0;
                        
WeaponinMarket[Key] = 0;
                        
                        return 
PLUGIN_CONTINUE;
                    }
                    
                    
print_color(0"!g%s%L"PrefixLANG_PLAYER"BUYMARKETITEM"mNameWeaponNames[WeaponinMarket[Key]], MarketPoints[Key], Name);
                    
uWeapon[WeaponinMarket[Key]][id]++;
                    
uWeapon[WeaponinMarket[Key]][Key]--;
                    
                    if(!
uWeapon[WeaponinMarket[Key]][Key])
                        for(new 
iCSW_VESTHELMi++) { if(bUsingGuns[Key][i] == WeaponinMarket[Key]) { bUsingGuns[Key][i] = 0uWeaponKills[i][Key] = 0; break; } }
                    
                    static 
szQuery[512], szUGuns[128];
                    
format(szUGunssizeof(szUGuns), "");
                    for(new 
iCSW_VESTHELMi++) { format(szUGunssizeof(szUGuns), "%s%d "szUGunsbUsingGuns[id][i]); }
                    
formatex(szQuerysizeof(szQuery), "UPDATE `%s` SET `using_skins` = '%s' WHERE `username` = '%s';"TABLE_NAMEszUGunsget_user_name_ex(id));                    
                    
                    
SQL_ThreadQuery(g_hTuple"QuerySetData"szQuery);
                    
                    
log_errors("[SKIN SHOP] %s"szQuery);
                    
                    
format(szUGunssizeof(szUGuns), "");
                    for(new 
iCSW_VESTHELMi++) { format(szUGunssizeof(szUGuns), "%s%d "szUGunsbUsingGuns[Key][i]); }
                    
formatex(szQuerysizeof(szQuery), "UPDATE `%s` SET `using_skins` = '%s' WHERE `username` = '%s';"TABLE_NAMEszUGunsget_user_name_ex(Key));
                                        
                    
SQL_ThreadQuery(g_hTuple"QuerySetData"szQuery);
                    
                    
log_errors("[SKIN SHOP] %s"szQuery);
                }
                else if(
CHEST_ID <= WeaponinMarket[Key] <= CHEST_ID+CHEST_COUNT)
                {
                    new 
chId = (WeaponinMarket[Key]-CHEST_ID)+1;
                    
                    if(
Chest[Key][chId] <= 0)
                    {
                        
inMarket[Key] = false;
                        
MarketPoints[Key] = 0;
                        
WeaponinMarket[Key] = 0;
                        
                        return 
PLUGIN_CONTINUE;
                    }
                    
client_print_color(0print_team_default"^4%s%L"PrefixLANG_PLAYER"BUYMARKETCHEST"mNamechest_name(chId), MarketPoints[Key], Name);

                    
Chest[id][chId]++;
                    
Chest[Key][chId]--;
                }
                else if(
WeaponinMarket[Key] == KEY_ID)
                {
                    if(
pKey[Key] <= 0)
                    {
                        
inMarket[Key] = false;
                        
MarketPoints[Key] = 0;
                        
WeaponinMarket[Key] = 0;
                        
                        return 
PLUGIN_CONTINUE;
                    }
                    
                    
client_print_color(0print_team_default"^4%s%L"PrefixLANG_PLAYER"BUYMARKETKEY"mNameMarketPoints[Key], Name);
                                        
                    
pKey[id]++; pKey[Key]--;
                }
                
                
emit_sound(KeyCHAN_ITEMSOUND_SOLDVOL_NORMATTN_NORM ,PITCH_NORM );
                
Points[Key] += MarketPoints[Key];
                
Points[id] -= MarketPoints[Key];
                
SaveData(Key);
                
SaveData(id);
                
mAmount[Key]--;
                
                if(
mAmount[Key] <= 0)
                {
                    
inMarket[Key] = false;
                    
MarketPoints[Key] = 0;
                    
WeaponinMarket[Key] = 0;
                }
                
MenuMod[id] = 0;
            }
        }
        case 
4:
        {                
            new 
Random random_num(1100);
            new 
rNum;
            
            if(
Random && weaponRang[Key] == 3)
            {
                new 
chestNum random_num(17);
                new 
chest chestNum;    

                new 
chance 5;
                new 
skinsCnt chestsChance[chest][chance];
                new 
skinNum random(skinsCnt);
                new 
skinId chestsList[chest][chance][skinNum];
                
                
client_print_color(0print_team_default"^4%s%L"EVENTLANG_PLAYER"MENUTODUST_SKINS"get_user_name_ex(id), WeaponNames[skinId], szWeaponNames[Weapons[skinId]]);
                
                
uWeapon[skinId][id]++;
                
SaveData(id);
            }
            else if(
Random 25 && weaponRang[Key] == 4)
            {
                new 
chestNum random_num(17);
                new 
chest chestNum;        
                
                new 
chancerare 25;
                new 
skinsCntrare chestsChance[chest][chancerare];
                new 
skinNumrare random(skinsCntrare);    
                new 
skinIdrare chestsList[chest][chancerare][skinNumrare];
                
                
client_print_color(0print_team_default"^4%s%L"EVENTLANG_PLAYER"MENUTODUST_SKINS"get_user_name_ex(id), WeaponNames[skinIdrare], szWeaponNames[Weapons[skinIdrare]]);
                
                
uWeapon[skinIdrare][id]++;
                
SaveData(id);
            }
            else 
                
            if(
uWeapon[Key][id] > && weaponRang[Key] > 0)
            {
                
uWeapon[Key][id]--;
                
                
bUsingGuns[id][Weapons[Key]] = 0;
                
                if(!
uWeapon[Key][id])
                    
uWeaponKills[Key][id] = 0;
                    
                if(
weaponRang[Key] == 1rNum random_num(502500);        // Y
                
else if(weaponRang[Key] == 2rNum random_num(502500);  // R
                
if(weaponRang[Key] == 3rNum random_num(502500);         // B
                
else if(weaponRang[Key] == 4rNum random_num(200300);  // W
                        
                
Points[id] += rNum;
                        
                
client_print_color(idprint_team_default"^4%s%L"PrefixLANG_PLAYER"MENUTODUST"get_user_name_ex(id), rNum);
                
                
log_errors("[SKINLOG TRASH] %s išsikeite %s"get_user_name_ex(id), WeaponNames[Key]);
                
                
SaveData(id);
                } else {
                
uWeapon[Key][id] = 0;
                
SaveData(id);
            }
            
            
Menu(id);
        }
        case 
5:
        {
            if(
Key == -1) { aTarget[id] = 0; }
            if(
Key == -2) { MenuMod[id] = -2; }
            if(
Key == -3)
            {
                if(!
is_user_connected(aTarget[id])) 
                {
                    return 
PLUGIN_CONTINUE;
                }
                
                if(
aThing[id] < CHEST_ID)
                {
                    if(
uWeapon[aThing[id]][id] > 0)
                    {
                        
uWeapon[aThing[id]][aTarget[id]]++;
                        
uWeapon[aThing[id]][id]--;
                        
                        if(!
uWeapon[aThing[id]][id])
                            for(new 
iCSW_VESTHELMi++) { if(bUsingGuns[id][i] == aThing[id]) { bUsingGuns[id][i] = 0uWeaponKills[i][id] = 0; break; } }
                        
                        static 
szQuery[512], szUGuns[128]; format(szUGunssizeof(szUGuns), "");        
                        for(new 
iCSW_VESTHELMi++) { format(szUGunssizeof(szUGuns), "%s%d "szUGunsbUsingGuns[id][i]); }        
                        
formatex(szQuerysizeof(szQuery), "UPDATE `%s` SET `using_skins` = '%s' WHERE `username` = '%s';"TABLE_NAMEszUGunsget_user_name_ex(id));
                        
                        
SQL_ThreadQuery(g_hTuple"QuerySetData"szQuery);
                        
                        
log_errors("[SKIN GIFT] %s padovanojo %s - %s"get_user_name_ex(id), get_user_name_ex(aTarget[id]), WeaponNames[aThing[id]]);
                        
log_errors("[SKIN GIFT] %s"szQuery);
                        
                        
client_print_color(idprint_team_default"^4%s %L"PrefixLANG_PLAYER"GIFTSUCCESS_SKIN");
                        
print_color(aTarget[id], "%L"LANG_PLAYER"GIFTGOT_SKIN"Prefixget_user_name_ex(id), WeaponNames[aThing[id]], szWeaponNames[Weapons[aThing[id]]]);
                    }
                    
// else client_print_color(id, print_team_default, "Neturi tiek skinu!");
                
}
                else if(
CHEST_ID <= aThing[id] <= CHEST_ID+CHEST_COUNT)
                {
                    new 
cId aThing[id]-CHEST_ID;
                    if(
Chest[id][cId] >= aAmount[id])
                    {
                        
Chest[aTarget[id]][cId]+=aAmount[id]; 
                        
Chest[id][cId]-=aAmount[id];
                        
                        
client_print_color(idprint_team_default"^4%s %L"PrefixLANG_PLAYER"GIFTSUCCESS_CHEST");
                        
print_color(aTarget[id], "%L"LANG_PLAYER"GIFTGOT_CHEST"Prefixget_user_name_ex(id), aAmount[id]);
                    }
                    else 
client_print_color(idprint_team_default"Neturi tiek skryniu!");
                }
                else if(
aThing[id] == KEY_ID)
                {
                    if(
pKey[id] >= aAmount[id])
                    {
                        
pKey[aTarget[id]]+=aAmount[id]; pKey[id]-=aAmount[id];
                        
                        
client_print_color(idprint_team_default"^4%s %L"PrefixLANG_PLAYER"GIFTSUCCESS_KEY");
                        
print_color(aTarget[id], "%L"LANG_PLAYER"GIFTGOT_KEY"Prefixget_user_name_ex(id), aAmount[id]);
                    }
                    else 
client_print_color(idprint_team_default"Neturi tiek raktu!");
                }
                
                if(
aPoints[id] > && Points[id] >= aPoints[id])
                {
                    
Points[aTarget[id]] += aPoints[id];
                    
Points[id] -= aPoints[id];
                    
client_print_color(aTarget[id], print_team_default"%L"LANG_PLAYER"GIFTGOT_PTS"Prefixget_user_name_ex(id), aPoints[id]);
                    
log_errors("[SKINLOG PTS] %s padovanojo %s - %d tasku"get_user_name_ex(id), get_user_name_ex(aTarget[id]), aPoints[id]);
                }
                
                
SaveData(aTarget[id]);
                
SaveData(id);
                
                
MenuMod[id] = 0;
                
aThing[id] = 0;
                
aTarget[id] = 0;
                
aPoints[id] = 0;
            }
            
            if(
Key == -75)
            {
                
client_cmd(id"messagemode setAmount");
            }
            
            if(
Key == -4) { client_cmd(id"messagemode Gift"); }
            if(
Key 0) { aTarget[id] = Key; }
            
Menu(id);
        }
        case 
6:
        {
            new 
accesNum get_access(id);
            new 
Float:gPercent = ((accesNum == 4) ? 0.92 : ((accesNum == 3) ? 0.96 : (accesNum == 2) ? 0.98 1.0));
            
            switch(
item)
            {
                case 
0
                {
                    
Points[id] -= floatround(10000*gPercentfloatround_floor);
                    
pKey[id]++;
                    
                    
client_print_color(idprint_team_default"%L"LANG_PLAYER"BOUGHTKEY_1"Prefix);
                    
SaveKeys(id);
                }
                case 
1
                {
                    
Points[id] -= floatround(45000*gPercentfloatround_floor);
                    
pKey[id] += 5;
                    
                    
client_print_color(idprint_team_default"%L"LANG_PLAYER"BOUGHTKEY_5"Prefix);
                    
SaveKeys(id);
                }
                case 
2
                {
                    
Points[id] -= floatround(90000*gPercentfloatround_floor);
                    
pKey[id] += 10;
                    
                    
client_print_color(idprint_team_default"%L"LANG_PLAYER"BOUGHTKEY_10"Prefix);
                    
SaveKeys(id);
                }
                case 
3..(CHEST_COUNT+3):
                {
                    
Chest[id][item-2] += 1;
                    
                    
Points[id] -= 5000;
                    
                    
client_print_color(idprint_team_default"%L"LANG_PLAYER"BOUGHTCHEST_1"Prefixchest_name(item-2));
                    
                    
SaveChests(id);
                }
            }
        }
        case 
7:
        {
            
Menu(id);
        }
        default: { 
MenuMod[id] = 0; }
    }
    
    
menu_destroy(gMenu);
    return 
PLUGIN_HANDLED;



Natsheh 06-06-2019 04:50

Re: Index out of bounds
 
Post the full error log

LithuanianJack 06-07-2019 09:44

Re: Index out of bounds
 
Quote:

Originally Posted by Natsheh (Post 2654526)
Post the full error log

There is no more important information, but I'll post it as soon as possible

Natsheh 06-07-2019 09:47

Re: Index out of bounds
 
Are we suppose to guess what is on line 1869?

LithuanianJack 06-07-2019 09:49

Re: Index out of bounds
 
Quote:

Originally Posted by Natsheh (Post 2654714)
Are we suppose to guess what is on line 1869?

I attached the sma file

Natsheh 06-07-2019 10:10

Re: Index out of bounds
 
I mean it will be much easier if you highlighted that line anyways

new skinId = chestsList[chest][chance][skinNum];
This error happens when index of an array gets out of bounds I assume the 1st dimension of the array is out of bounds "chest"

You can contact the author Psychical for the fix or you can try debugging by yourself and check what is going out of bounds and fix it depending on the things that suppose to go correctly.

Airkish 06-08-2019 05:56

Re: Index out of bounds
 
Your skins.cfg is not written correctly


All times are GMT -4. The time now is 18:07.

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