Debug run time error 4 array index out of bounds

Всем привет! У меня в консоле вылазит такая ошибка, помогите решить: [18:00:20] [debug] Run time error 4: "Array index out of...


#1

Пользователь офлайн
 

Отправлено 31 октября 2021 — 20:45

  • Прохожий

Всем привет! У меня в консоле вылазит такая ошибка, помогите решить:

[18:00:20] [debug] Run time error 4: "Array index out of bounds"
[18:00:20] [debug]  Attempted to read/write array element at index 200 in array of size 200
[18:00:20] [debug] AMX backtrace:
[18:00:20] [debug] #0 006411b4 in public BadEngine () at C:UsersrotkiDesktopсерверPRIME (1)gamemodesprime.pwn:73049
[18:00:20] [debug] Run time error 4: "Array index out of bounds"
[18:00:20] [debug]  Attempted to read/write array element at index 200 in array of size 200
[18:00:20] [debug] AMX backtrace:
[18:00:20] [debug] #0 006411b4 in public BadEngine () at C:UsersrotkiDesktopсерверPRIME (1)gamemodesprime.pwn:73049
[18:00:21] [debug] Run time error 4: "Array index out of bounds"
[18:00:21] [debug]  Attempted to read/write array element at index 200 in array of size 200
[18:00:21] [debug] AMX backtrace:
[18:00:21] [debug] #0 006411b4 in public BadEngine () at C:UsersrotkiDesktopсерверPRIME (1)gamemodesprime.pwn:73049
[18:00:21] [debug] Run time error 4: "Array index out of bounds"
[18:00:21] [debug]  Attempted to read/write array element at index 200 in array of size 200
[18:00:21] [debug] AMX backtrace:
[18:00:21] [debug] #0 006411b4 in public BadEngine () at C:UsersrotkiDesktopсерверPRIME (1)gamemodesprime.pwn:73049
[18:00:22] [debug] Run time error 4: "Array index out of bounds"
[18:00:22] [debug]  Attempted to read/write array element at index 200 in array of size 200
[18:00:22] [debug] AMX backtrace:
[18:00:22] [debug] #0 006411b4 in public BadEngine () at C:UsersrotkiDesktopсерверPRIME (1)gamemodesprime.pwn:73049

Я уже выяснил, что в строке 73049 проблема, но я не понимаю какая. Помогите пожалуйста!

forward BadEngine();
public BadEngine()
{
    new veh, Float:spd[3], Float:hls;
    for(new i; i != GetMaxPlayers(); i++)
    {
        if( !BE_Play_Check[i] ) { continue; }
        veh = GetPlayerVehicleID( i );
        if( !veh ) { continue; }
        GetVehicleHealth( veh, hls );
        if( hls > BE_MIN_HLS ) { continue; }
        GetVehicleVelocity( veh, spd[0], spd[1], spd[2] );

        if( floatabs(spd[0]) > floatabs(spd[1]) )
        {
            if( floatabs(spd[ 0 ]) > BE_MAX_SPD )
            {
                hls = BE_MAX_SPD / floatabs(spd[ 0 ]);
                SetVehicleVelocity( veh, spd[0]*hls, spd[1]*hls, spd[2] );
            }
        }
        else
        {
            if( floatabs(spd[ 1 ]) > BE_MAX_SPD )
            {
                hls = BE_MAX_SPD / floatabs(spd[ 1 ]);
                SetVehicleVelocity( veh, spd[0]*hls, spd[1]*hls, spd[2] );
            }
        }
    }
}

Сообщение отредактировал Leonardo_Macfly: 31 октября 2021 — 23:12

0



#2

Отправлено 01 ноября 2021 — 07:35

  • Местный

Может у тебя в конфиге максимальное количество игроков больше чем MAX_PLAYERS?

0



#3

Отправлено 01 ноября 2021 — 08:57

  • Прохожий

Просмотр сообщенияexecution88 (01 ноября 2021 — 07:35) писал:

Может у тебя в конфиге максимальное количество игроков больше чем MAX_PLAYERS?

Нет, у меня на хостинге 500 слотов, и в max_players 500

0



#4

Отправлено 02 ноября 2021 — 07:25

  • Местный

Я так понял, ошибка в BE_Play_Check? Покажи как объявил

0



#5

Отправлено 03 ноября 2021 — 15:59

  • Знаток
[18:00:20] [debug] Run time error 4: "Array index out of bounds"
[18:00:20] [debug]  Attempted to read/write array element at index 200 in array of size 200

«Array index out of bounds» — Переводится как: Индекс массива за пределами границы. А во второй строке предоставленна информация, якобы что в данном месте произошел тот самый выход за пределы объявленного массива.
Чтобы избежать в дальнейшем подобных казусов, используй следующую конструкцию:

new Array[200];
for(new i; i < sizeof(Array); i++) {

	printf("%i", Array[i]);
}

В данном случае, в заголовке объявления цикла ты используешь GetMaxPlayers(), на сколько мне известно, эта функция возвращает наибольший Id игрока, при этом в ходе итерции цикла отсутствует проверка на валидность Id, нежели это не if( !BE_Play_Check[i] ) { continue; }. Если это так, то, организация кода оставляет желать лучшего. Это дурной тон, при наличии того-же foreach в YSI и его форков.

0


  • ← Предыдущая тема
  • Вопросы по скриптингу
  • Следующая тема →

  • Вы не можете создать новую тему
  • Тема закрыта


1 человек читают эту тему
0 пользователей, 1 гостей, 0 скрытых пользователей

  • Главная
  • Форум
  • Pawn-скриптинг, SA:MP
  • Уроки
  • [Урок] Как бороться с выходами за пределы массива (CrashDetect)


  1. 06.12.2015, 11:46


    #1

    Как бороться с выходами за пределы массива (CrashDetect)

    Чтобы не объяснять индивидуально каждому в разделе «Вопросы», распишу здесь один распространённый случай, в котором срабатывает CrashDetect.

    Допустим, у нас есть скрипт test.pwn:

    PHP код:


    #include <a_samp>main()
    {
        new 
    a[10];
        for (new 
    020i++)
            
    a[i] = i;
        for (new 
    020i++)
            
    printf("%d"a[i]);




    При выполнении этого кода плагин CrashDetect выведет сообщение:

    Код:

    [debug] Run time error 5: "Invalid memory access"
    [debug] AMX backtrace:
    [debug] #0 00000078 in ?? (0x00000000, 0x00000000, 0xf050b5c3) from test.amx
    [debug] #1 0000000b in main () from test.amx
    Script[gamemodes/test.amx]: Run time error 5: "Invalid memory access"

    Для начала откомпилируем код в режиме отладки (в теме про CrashDetect написано, как это сделать) и запустим скрипт заново:

    Код:

    [debug] Run time error 4: "Array index out of bounds"
    [debug]  Accessing element at index 10 past array upper bound 9
    [debug] AMX backtrace:
    [debug] #0 000000a4 in main () at C:servergamemodestest.pwn:7
    Script[gamemodes/test.amx]: Run time error 4: "Array index out of bounds"

    Теперь данных в сообщении достаточно, чтобы найти причину ошибки.
    «Array index out of bounds» переводится как «выход за пределы массива».
    Означает это, что вы что-то пытаетесь сделать с несуществующим элементом массива.

    Обратите внимание: в сообщении красным цветом выделен несуществующий элемент, зелёным — максимальный номер элемента в массиве.

    Код:

    [debug]  Accessing element at index 10 past array upper bound 9

    Ошибка произошла из-за того, что сервер попытался получить доступ к 10-му элементу массива, когда в массиве есть только элементы с номерами от 0 до 9.
    Также синим цветом выделено название исходного файла (иногда ошибки возникают не только в .pwn мода, но и в инклудах и фильтрскриптах) и номер строки, на которой произошла ошибка.

    Код:

    [debug] #0 000000a4 in main () at C:servergamemodestest.pwn:7

    Смотрим строку №7 в test.pwn:

    PHP код:


    for (new 020i++) 



    Обратите внимание на условие выхода из цикла: выход происходит только когда i становится равно 20.
    При этом размер массива — 10 элементов.

    Как нам исправить эту проблему? Нужно сделать так, чтобы цикл был не до 20, а до (<размер массива> — 1).

    PHP код:


    for (new 0<= 10 1i++) 



    Проблема решена? Ещё нет.
    Выхода за пределы массива не будет, но что, если в будущем понадобится изменить размер массива, скажем, с 10 до 8?
    Представьте себе мод из 30 000 строк кода: вам придётся обыскивать весь мод, чтобы найти, в каких циклах происходит перебор массива, и во всех этих циклах заменять 10 на 8.
    Это как бомба замедленного действия: сейчас вы решите проблему, но вместо неё в будущем появится другая.
    Чтобы такого не было, в цикле следует использовать оператор sizeof, который возвращает размер массива.

    PHP код:


    for (new 0<= sizeof(a) - 1i++) 



    Можно немного упростить запись, убрав «- 1» и заменив знак «меньше или равно» на «меньше».

    PHP код:


    for (new 0sizeof(a); i++) 



    В итоге получится такой код:

    PHP код:


    #include <a_samp>main()
    {
        new 
    a[10];
        for (new 
    0sizeof(a); i++)
            
    a[i] = i;
        for (new 
    0sizeof(a); i++)
            
    printf("%d"a[i]);




    Компилируем и запускаем:

    Код работает без ошибок. Проблема решена.

    Автор статьи: Daniel_Cortez

    Копирование данной статьи на других ресурсах без разрешения автора запрещено!

    Индивидуально в ЛС по скриптингу не помогаю. Задавайте все свои вопросы

    здесь (click)

    .



  2. 14 пользователя(ей) сказали cпасибо:


  3. 01.12.2016, 22:31


    #2

    Аватар для DoN_SancheS

    Пользователь


    Тогда от чего может быть это:



  4. 07.12.2016, 04:28


    #3

    Аватар для Strong

    Пользователь


    Цитата Сообщение от DoN_SancheS
    Посмотреть сообщение

    Тогда от чего может быть это:

    От кривых рук



  5. 11.12.2016, 12:18


    #4

    Аватар для DoN_SancheS

    Пользователь


    То-есть?
    Я понимаю что я сделал что то не так но не понимаю почему ты умничаешь вместо того чтобы помогать.



  6. 11.12.2016, 12:49


    #5

    Цитата Сообщение от DoN_SancheS
    Посмотреть сообщение

    То-есть?
    Я понимаю что я сделал что то не так но не понимаю почему ты умничаешь вместо того чтобы помогать.

    Ты пытаешься сделать что-то, в чём не разбираешься, тебе нужно сначала изучить основы.



  7. Пользователь сказал cпасибо:


  8. 31.10.2022, 21:37


    #6

    Аватар для hawertin

    Пользователь


    А у меня почему то архив не открывается.


 

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)


Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •  
  • BB коды Вкл.
  • Смайлы Вкл.
  • [IMG] код Вкл.
  • [VIDEO] код Вкл.
  • HTML код Выкл.

Правила форума

Было всё в порядке но потом обратил внимание на это в логах,предположительно началось после того как создал транспорт на продажу.

Очень надеюсь на вашу помощь 

[09:45:10] [debug] Run time error 4: "Array index out of bounds"
[09:45:10] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[09:45:10] [debug] AMX backtrace:
[09:45:10] [debug] #0 006b01c0 in J_AddStaticVehicleEx (model=904, Float:x=56.22650, Float:y=1002.40002, Float:z=11.51420, Float:a=183.88000, color_1=0, color_2=0, spawntime=60000, interior=0, world=0) at C:Users123123Downloadsffffffffgamemodesffff.pwn:56143
[09:45:10] [debug] #1 00431878 in public fo_OnGameModeInit () at C:Users123123Downloadsffffffffgamemodesffff.pwn:10045
[09:45:10] [debug] #2 00009800 in public SSCANF_OnGameModeInit () at C:Users123123Downloadsffffffffpawnoincludefixobject.inc:266
[09:45:10] [debug] #3 000035f8 in public OnGameModeInit () at C:Users123123Downloadsffffffffpawnoincludesscanf2.inc:205
[09:45:10] _____________________________________________________________________
[09:45:10]  QQQQWWWWWQQQ X
[09:45:10] (vk.com/m22vtw) © 2018 (FFFF FFFFF)
[09:45:10] _____________________________________________________________________
[09:45:10] Number of vehicle models: 11

#0 006b01c0 in J_AddStaticVehicleEx

J_AddStaticVehicleEx(model,Float:x,Float:y,Float:z,Float:a,color_1,color_2,spawntime = 300,interior = 0,world = 0)
{
	new carid = AddStaticVehicleEx(model, x, y, z, a, color_1, color_2, spawntime);
	VehicleInfo[carid][vAntiRepair]=2;
	VehicleInfo[carid][vLock]=0;
	//VehicleHealth[carid] = 1000;
	VehicleInfo[carid][vModel] = model;
	VehicleInfo[carid][vPos_X] = x;
	VehicleInfo[carid][vPos_Y] = y;
	VehicleInfo[carid][vPos_Z] = z;
	VehicleInfo[carid][vPos_A] = a;
	VehicleInfo[carid][vColor_1] = color_1;
	VehicleInfo[carid][vColor_2] = color_2;
	VehicleInfo[carid][vSpawnTime] = spawntime;
	LinkVehicleToInterior(carid, interior);
	SetVehicleVirtualWorld(carid, world);
	VehicleInfo[carid][vTuning] = GetVehicleTuningState( model );
	switch(model)
	{
	case 430, 446, 452, 453, 454, 472, 473, 484, 493: VehicleState[carid] = VEHICLE_STATE_BOAT;
	case 417, 425, 447, 460, 469, 476, 487, 488, 497, 511, 512, 513, 519, 520, 548, 553,
		563, 577, 592, 593:  VehicleState[carid] = VEHICLE_STATE_PLANE;
	case 581, 522, 461, 521, 523, 463, 468, 471, 586: VehicleState[carid] = VEHICLE_STATE_BIKE;
	case 509, 481, 510: VehicleState[carid] = VEHICLE_STATE_VELIK;
	case 462,448: VehicleState[carid] = VEHICLE_STATE_MOPED;
	case 538, 537: VehicleState[carid] = VEHICLE_STATE_TRAIN;
	default: VehicleState[carid] = VEHICLE_STATE_CAR;
	}
	return carid;
}

#1 00431878 in public fo_OnGameModeInit

	//Загрузка автомобилей
	for(new i = 0;i < OWNABLECARS;i ++)
	{
		OwnableCar[i] = J_AddStaticVehicleEx(CarInfo[i][cModel],CarInfo[i][cPos_X],CarInfo[i][cPos_Y],CarInfo[i][cPos_Z],CarInfo[i][cPos_A],CarInfo[i][cColor_1],CarInfo[i][cColor_2],60000);
		CarText[i] = CreateDynamic3DTextLabel("-",-1,0,0,0.5,5.0,INVALID_PLAYER_ID,OwnableCar[i]);
		ReSetCarPrice(i);
		new number = OwnableCar[i];
		new virt = CarInfo[i][cVirt];
		if(!GetString(CarInfo[i][cOwner],"The State")) SetVehicleVirtualWorld(number, virt);

	}
	

Отредактировано 22 июня, 2018 пользователем edikzver


Причина: Дополнил

Регистрация
10 Окт 2012
Сообщения
30
Лучшие ответы
0
Репутация
1

  • #1

Привет, запускаю мод на майарене и у меня вылетают следующие ошибки в консоли:

Код:

[17:37:14] [debug] Run time error 4: "Array index out of bounds"
[17:37:14] [debug]  Accessing element at index 24 past array upper bound 23
[17:37:14] [debug] AMX backtrace:
[17:37:14] [debug] #0 004322d4 in public Iter_OnGameModeInit () from wrp.amx
[17:37:14] [debug] #1 native CallLocalFunction () [080dfac0] from samp03svr
[17:37:14] [debug] #2 0000a508 in public SSCANF_OnGameModeInit () from wrp.amx
[17:37:14] [debug] #3 native CallLocalFunction () [080dfac0] from samp03svr
[17:37:14] [debug] #4 000009bc in public dc_cmd_OnGameModeInit () from wrp.amx
[17:37:14] [debug] #5 000006f8 in public OnGameModeInit () from wrp.amx

cc: @oscar-broman

I have recently ran my gamemode in debug mode and got some stacktraces, most of them were due to my own fault but I have seen some that appear to directly trace back to weapon-config.

[06:06:48] [debug] Run time error 4: "Array index out of bounds"
[06:06:48] [debug]  Accessing element at index 48 past array upper bound 46
[06:06:48] [debug] AMX backtrace:
[06:06:48] [debug] #0 00347668 in public WC_OnPlayerDamage (&playerid=@0x005f326c, &Float:amount=@0x005f3270, &issuerid=@0x005f3274, &weapon=@0x005f3278, &bodypart=@0x005f327c) at SFCRRPG.pwn:2715
[06:06:48] [debug] #1 0003986c in public OnPlayerDamage (&playerid=@0x005f326c, &Float:amount=@0x005f3270, &issuerid=@0x005f3274, &weapon=@0x005f3278, &bodypart=@0x005f327c) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:5448
[06:06:48] [debug] #2 000315b8 in InflictDamage (playerid=6, Float:amount=2.64000, issuerid=4, weaponid=48, bodypart=27, bool:ignore_armour=false) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:4608
[06:06:48] [debug] #3 0002754c in public OnPlayerGiveDamage (playerid=4, damagedid=6, Float:amount=2.64000, weaponid=48, bodypart=27) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:3219
[06:06:48] [debug] Run time error 4: "Array index out of bounds"
[06:06:48] [debug]  Accessing element at index 48 past array upper bound 46
[06:06:48] [debug] AMX backtrace:
[06:06:48] [debug] #0 00347668 in public WC_OnPlayerDamage (&playerid=@0x005f326c, &Float:amount=@0x005f3270, &issuerid=@0x005f3274, &weapon=@0x005f3278, &bodypart=@0x005f327c) at SFCRRPG.pwn:2715
[06:06:48] [debug] #1 0003986c in public OnPlayerDamage (&playerid=@0x005f326c, &Float:amount=@0x005f3270, &issuerid=@0x005f3274, &weapon=@0x005f3278, &bodypart=@0x005f327c) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:5448
[06:06:48] [debug] #2 000315b8 in InflictDamage (playerid=6, Float:amount=2.64000, issuerid=4, weaponid=48, bodypart=27, bool:ignore_armour=false) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:4608
[06:06:48] [debug] #3 0002754c in public OnPlayerGiveDamage (playerid=4, damagedid=6, Float:amount=2.64000, weaponid=48, bodypart=27) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:3219
[06:06:49] [debug] Run time error 4: "Array index out of bounds"
[06:06:49] [debug]  Accessing element at index 48 past array upper bound 46
[06:06:49] [debug] AMX backtrace:
[06:06:49] [debug] #0 00347668 in public WC_OnPlayerDamage (&playerid=@0x005f326c, &Float:amount=@0x005f3270, &issuerid=@0x005f3274, &weapon=@0x005f3278, &bodypart=@0x005f327c) at SFCRRPG.pwn:2715
[06:06:49] [debug] #1 0003986c in public OnPlayerDamage (&playerid=@0x005f326c, &Float:amount=@0x005f3270, &issuerid=@0x005f3274, &weapon=@0x005f3278, &bodypart=@0x005f327c) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:5448
[06:06:49] [debug] #2 000315b8 in InflictDamage (playerid=6, Float:amount=2.64000, issuerid=4, weaponid=48, bodypart=27, bool:ignore_armour=false) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:4608
[06:06:49] [debug] #3 0002754c in public OnPlayerGiveDamage (playerid=4, damagedid=6, Float:amount=2.64000, weaponid=48, bodypart=27) at C:UsersJeroenDocumentsgitSONAsona-cnrpawnoincludeweapon-configweapon-config.inc:3219

Posts: 763
Threads: 31
Joined: Oct 2013

Reputation:

0

Hello

PHP код:



[09:25:17] [debugRun time error 4"Array index out of bounds"

[09:25:17] [debug]  Attempted to read/write array element at index 65535 in array of size 100

[09:25:17] [debugAMX backtrace:

[
09:25:17] [debug#0 00098364 in public FC_OnPlayerDeath (0, 65535, 255) from TDM.amx

[09:25:17] [debug#1 native CallLocalFunction () from samp03svr

[09:25:17] [debug#2 0000e3e8 in public OnPlayerDeath (0, 65535, 255) from TDM.amx

[09:25:17] [death] [H]e[R]o died 255 




PHP код:



[09:09:44] [debugAMX backtrace:

[
09:09:44] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx

[09:11:27] [debugRun time error 4"Array index out of bounds"

[09:11:27] [debug]  Attempted to read/write array element at index 5 in array of size 5

[09:11:27] [debugAMX backtrace:

[
09:11:27] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx

[09:12:15] [debugRun time error 4"Array index out of bounds"

[09:12:15] [debug]  Attempted to read/write array element at index 5 in array of size 5

[09:12:15] [debugAMX backtrace:

[
09:12:15] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx 




OnPlayerEnterCheckpoint

PHP код:



public OnPlayerEnterCheckpoint(playerid)

{

new 
text[128];

    if(
IsCapturing[playerid][usapro] == 1)

    {

        if(
IsPlayerInVehicle(playeridusapro))

        {

             DisablePlayerCheckpoint(playerid);

            
IsCapturing[playerid][usapro] = 0;

                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~USA prototype ~w~for his team!"pName(playerid));

                
RemovePlayerFromVehicle(playerid);

                        
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");

GivePlayerMoney(playerid6000);

SetVehicleToRespawn(usapro);

SetPlayerScore(playeridGetPlayerScore(playerid)+6);

TogglePlayerAllDynamicCPs(playerid1);

TextStats(playerid);

                
Savestatus(playerid);

        }

        else

        {

             DisablePlayerCheckpoint(playerid);

            
SCM(playeridRED"You're not in the USA Prototype.");

        }

    }

    if(
IsCapturing[playerid][auspro] == 1)

    {

        if(
IsPlayerInVehicle(playeridauspro))

        {

            
DisablePlayerCheckpoint(playerid);

            
IsCapturing[playerid][auspro] = 0;

            
TextStats(playerid);

                
Savestatus(playerid);

                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~ Australia prototype ~w~for his team!"pName(playerid));

                
RemovePlayerFromVehicle(playerid);

 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");

 
GivePlayerMoney(playerid6000);

 
SetVehicleToRespawn(auspro);

 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);

TogglePlayerAllDynamicCPs(playerid1);

        }

        else

        {

              
DisablePlayerCheckpoint(playerid);

            
SCM(playeridRED"You're not in the Australia Prototype.");

        }

    }

    if(
IsCapturing[playerid][arabpro] == 1)

    {

        if(
IsPlayerInVehicle(playeridarabpro))

        {

            
DisablePlayerCheckpoint(playerid);

            
IsCapturing[playerid][arabpro] = 0;

            
TextStats(playerid);

                
Savestatus(playerid);

                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Arabian prototype ~w~for his team!"pName(playerid));

                
RemovePlayerFromVehicle(playerid);

 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");

 
GivePlayerMoney(playerid6000);

 
SetVehicleToRespawn(arabpro);

 
SetPlayerScore(playeridGetPlayerScore(playerid)+6);

TogglePlayerAllDynamicCPs(playerid1);

        }

        else

        {

            
DisablePlayerCheckpoint(playerid);

            
SCM(playeridRED"You're not in the Arabian Prototype.");

        }

    }

    if(
IsCapturing[playerid][sovpro] == 1)

    {

        if(
IsPlayerInVehicle(playeridsovpro))

        {

            
DisablePlayerCheckpoint(playerid);

                   
RemovePlayerFromVehicle(playerid);

                   
TextStats(playerid);

                
Savestatus(playerid);

                   
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Soviet prototype ~w~for his team!"pName(playerid));

                
IsCapturing[playerid][sovpro] = 0;

                
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");

                 
GivePlayerMoney(playerid6000);

                
SetVehicleToRespawn(sovpro);

                
SetPlayerScore(playeridGetPlayerScore(playerid)+6);

                 
TogglePlayerAllDynamicCPs(playerid1);

        }

        else

        {

            
DisablePlayerCheckpoint(playerid);

            
SCM(playeridRED"You're not in the Soviet Prototype.");

        }

    }

    if(
IsCapturing[playerid][eurapro] == 1)

    {

        if(
IsPlayerInVehicle(playerideurapro))

        {

            
DisablePlayerCheckpoint(playerid);

                
format(textsizeof(text), "~r~%s~w~ has Captured ~r~Erusia prototype ~w~for his team!"pName(playerid));

                
IsCapturing[playerid][eurapro] = 0;

                
RemovePlayerFromVehicle(playerid);

                
TextStats(playerid);

                
Savestatus(playerid);

                 
SCM(playeridC_GREEN"Congratulations! You got +6 score and +6000 cash!");

                 
GivePlayerMoney(playerid6000);

             
SetVehicleToRespawn(eurapro);

             
SetPlayerScore(playeridGetPlayerScore(playerid)+6);

              
TogglePlayerAllDynamicCPs(playerid1);

        }

        else

        {

            
DisablePlayerCheckpoint(playerid);

            
SCM(playeridRED"You're not in the Erusia Prototype.");

        }

    }

    return 
1;






EDIT: Why i got those errors ?

Posts: 1,506
Threads: 13
Joined: Jun 2015

Fix the indentation, re-write the code and if the problem still persists, debug the code.

For the OnPlayerDeath, you gotta check if killerid is != INVALID_PLAYER_ID and you should be done.

Can you show textstats & savestatus?

(You have a array with [4] )

PS: compile with -d3 to get exact line of error.

Posts: 763
Threads: 31
Joined: Oct 2013

Reputation:

0

Already do that.. but the error still
Why i got that error ?
EDIT: ok ilean

Posts: 6,242
Threads: 8
Joined: Jun 2008

IsCapturing[playerid][*team*]

This array could be used a lot more efficiently rather than having an array for each player, for each location to capture…

Probably nothing to do with the error, but just saying so you may find another way of doing it.

Like, you could track the locations as an array, and have the Team ID tracked via that, and it would be less arrays.

Could even have the playerid tracked in a Location[site][capper] and have capper reflect who is capturing via their playerid, and check the players team when they are capping as to which team is capping.

Posts: 763
Threads: 31
Joined: Oct 2013

Reputation:

0

then how to solve it ?
anyway
iLeane..
about onplayerdeath(my code that) and i’ll give you errors

Quote:


public OnPlayerDeath(playerid, killerid, reason)
{

if(killerid != INVALID_PLAYER_ID)
DropPlayerWeapons(playerid); //here, we send that, when you die, you will drop your weaps (sorry da english)
gHelmet[playerid] = false;

if(PlayerHeadShot[playerid] == true)
PlayerHeadShot[playerid] = false;
..
..
..
..
..

f(killerid != INVALID_PLAYER_ID)
i{
// code

}

Posts: 763
Threads: 31
Joined: Oct 2013

Reputation:

0

Okey i’ll..
same errors:

PHP код:



[10:25:29] [debugRun time error 4"Array index out of bounds"

[10:25:29] [debug]  Attempted to read/write array element at index 5 in array of size 5

[10:25:29] [debugAMX backtrace:

[
10:25:29] [debug#0 0016201c in public OnPlayerEnterCheckpoint (3) from TDM.amx 




and i will edit onplayerdeath as yu said

PHP код:



[10:26:41] [debug]

[
10:24:29] [debugRun time error 4"Array index out of bounds"

[10:24:29] [debug]  Attempted to read/write array element at index 65535 in array of size 100

[10:24:29] [debugAMX backtrace:

[
10:24:29] [debug#0 00098364 in public FC_OnPlayerDeath (3, 65535, 54) from TDM.amx

[10:24:29] [debug#1 native CallLocalFunction () from samp03svr

[10:24:29] [debug#2 0000e3e8 in public OnPlayerDeath (3, 65535, 54) from TDM.amx

 Run time error 4"Array index out of bounds"

[10:26:41] [debug]  Attempted to read/write array element at index 65535 in array of size 100

[10:26:41] [debugAMX backtrace:

[
10:26:41] [debug#0 00098364 in public FC_OnPlayerDeath (0, 65535, 255) from TDM.amx

[10:26:41] [debug#1 native CallLocalFunction () from samp03svr

[10:26:41] [debug#2 0000e3e8 in public OnPlayerDeath (0, 65535, 255) from TDM.amx 




PHP код:



[10:32:36] [debugRun time error 4"Array index out of bounds"

[10:32:36] [debug]  Attempted to read/write array element at index 5 in array of size 5

[10:32:36] [debugAMX backtrace:

[
10:32:36] [debug#0 0016201c in public OnPlayerEnterCheckpoint (0) from TDM.amx 




only those ?
about onplayerdeath i’ll use ilean code.. but OnPlayerEnterCheckpoint?

Did you compile with -d3?

Posts: 1,506
Threads: 13
Joined: Jun 2015

Quote:

Originally Posted by iLearner
Посмотреть сообщение

Did you compile with -d3?

Eh, mind explaining how can I use flags? They don’t work on my compiler, maybe I am doing something wrong.

The OnVehicleDeath code is wrong.

Показать скрытое содержание
[[debug] Run time error 4: «Array index out of bounds»
[debug] Accessing element at index 8 past array upper bound 7
[debug] AMX backtrace:
[debug] #0 008b01e0 in public AloginAuth (playerid=0, inputtext[][email protected] «123456») at gamemodesM-mod.pwn:50971

forward AloginAuth(playerid, inputtext[]);
public AloginAuth(playerid, inputtext[])
{
	new rows, fields;
	cache_get_data(rows, fields);
	if(!rows)
	{
		SendClientMessage(playerid, COLOR_GREY, "Неверный пароль");
		SetPVarInt(playerid, "attempt_pass", GetPVarInt(playerid, "attempt_pass") + 1);
		if(GetPVarInt(playerid, "attempt_pass") > 3)
		{
			DeletePVar(playerid, "attempt_pass");
			SKick(playerid, 2112);
		}
	}
	else
	{
	    new string[144];
		AdminLogged[playerid] = true;
		PI[playerid][pAdmin] = cache_get_row_int(0, 1, dbHandle);
		AdminInfo[playerid][admGoto] = cache_get_row_int(0, 6, dbHandle);
	    AdminInfo[playerid][admGethere] = cache_get_row_int(0, 7, dbHandle);
	    AdminInfo[playerid][admSpectate] = cache_get_row_int(0, 8, dbHandle);
	    AdminInfo[playerid][admTimeMin] = cache_get_row_int(0, 9, dbHandle);
		AdminInfo[playerid][admAlog] = cache_get_row_int(0, 10, dbHandle);

		if(!IsPlayerGrandAdmin(playerid))
		{
			if(PI[playerid][pSex] == 1) format(string, sizeof(string), "[A] %s %s[%i] авторизовался", admin_rank_name[PI[playerid][pAdmin]], GetName(playerid), playerid);
			else format(string, sizeof(string), "[A] %s %s[%i] авторизовалась", admin_rank_name[PI[playerid][pAdmin]], GetName(playerid), playerid);
			SendAdminMessage(COLOR_BLUE, string);
		}

		Iter_Add(Admins, playerid);

		new day, month, year;
  		getdate(year, month, day);
		mysql_format(dbHandle, string, 144, "UPDATE "T_ADMIN" SET `last_connect` = '%d.%d.%d' WHERE `name` = '%s' LIMIT 1", day, month, year, GetName(playerid));
		mysql_tquery(dbHandle, string, "", "");
	}
	return 1;
}

  • #1

При запуске мода вот такая ошибка и мод Unknown

[16:32:00] [debug] Run time error 4: «Array index out of bounds»
[16:32:00] [debug] Accessing element at negative index -1
[16:32:00] [debug] AMX backtrace:
[16:32:00] [debug] #0 0014ca2c in ?? () from new.amx
[16:32:00] [debug] #1 00015968 in public zcmd_OnGameModeInit () from new.amx
[16:32:00] [debug] #2 native CallLocalFunction () [00472260] from samp-server-cr.exe
[16:32:00] [debug] #3 00012bf0 in public SSCANF_OnGameModeInit () from new.amx
[16:32:00] [debug] #4 native CallLocalFunction () [00472260] from samp-server-cr.exe
[16:32:00] [debug] #5 0000cecc in public Itter_OnGameModeInit () from new.amx
[16:32:00] [debug] #6 native CallLocalFunction () [00472260] from samp-server-cr.exe
[16:32:00] [debug] #7 0000c2f8 in public OnGameModeInit () from new.amx

Помогите исправить пожалуйста . 















  • #1

Ошибка

L 08/11/2021 — 20:10:44: Info (map «de_kabul») (file «addons/amxmodx/logs/error_20210811.log»)
L 08/11/2021 — 20:10:44: [AMXX] Displaying debug trace (plugin «Dispenser_3_Lvl.amxx», version «1.0.2»)
L 08/11/2021 — 20:10:44: [AMXX] Run time error 4: index out of bounds
L 08/11/2021 — 20:10:44: [AMXX] [0] Dispenser_3_Lvl.sma::DispenserThink (line 467)
L 08/11/2021 — 22:49:25: Start of error session.
L 08/11/2021 — 22:49:25: Info (map «de_dust2_2x2_winter16») (file «addons/amxmodx/logs/error_20210811.log»)
L 08/11/2021 — 22:49:25: [AMXX] Displaying debug trace (plugin «Dispenser_3_Lvl.amxx», version «1.0.2»)
L 08/11/2021 — 22:49:25: [AMXX] Run time error 4: index out of bounds
L 08/11/2021 — 22:49:25: [AMXX] [0] Dispenser_3_Lvl.sma::DispenserThink (line 467)
L 08/11/2021 — 22:49:36: [AMXX] Displaying debug trace (plugin «Dispenser_3_Lvl.amxx», version «1.0.2»)
L 08/11/2021 — 22:49:36: [AMXX] Run time error 4: index out of bounds
L 08/11/2021 — 22:49:36: [AMXX] [0] Dispenser_3_Lvl.sma::DispenserThink (line 467)

ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5263 (http://www.amxmodx.org)
Билд
ReHLDS version: 3.8.0.702-dev
Build date: 18:22:55 Nov 8 2020 (2402)
Build from: https://github.com/dreamstalker/rehlds/commit/543728d
ReGamedll
ReGameDLL version: 5.20.0.492-dev
Версия Metamod
Metamod-r v1.3.0.128, API (5:13)
Список метамодулей
[ 1] AMX Mod X        RUN   -    amxmodx_mm_i386.so          v1.9.0.5263      ini  Start ANY  
[ 2] Reunion RUN - reunion_mm_i386.so v0.1.92d ini Start Never
[ 3] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 4] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 5] POD-Bot mm RUN - podbot_mm_i386.so vV3B22b ini Chlvl ANY
[ 6] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY ANY
[ 7] WHBlocker RUN - whblocker_mm_i386.so v1.5.697 ini Chlvl ANY
[ 8] Fun RUN - fun_amxx_i386.so v1.9.0.5271 pl1 ANY ANY
[ 9] Engine RUN - engine_amxx_i386.so v1.9.0.5271 pl1 ANY ANY
[10] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5271 pl1 ANY ANY
[11] GeoIP RUN - geoip_amxx_i386.so v1.9.0.5271 pl1 ANY ANY
[12] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5271 pl1 ANY ANY
[13] CSX RUN - csx_amxx_i386.so v1.9.0.5271 pl1 ANY ANY

[14] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5271 pl1 ANY ANY
[15] ReAPI RUN - reapi_amxx_i386.so v5.18.0.203-dev pl1 ANY Never
[16] MySQL RUN - mysql_amxx_i386.so v1.9.0.5271 pl1 ANY ANY
[17] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl1 ANY Never
[18] CSDM2 RUN - csdm_amxx_i386.so v2.1.3c-KWo pl1 ANY ANY

Список плагинов
[  1] CSDM Auto Balance       1.0         xPaw              csdm_auto_balan  running  
[ 2] Vip Test 1.0 daywer vip_test.amxx running
[ 3] Money Rewards 1.0.1 the_hunter money_rewards.a running
[ 4] Anti-Ad 0.1 Mati antiad.amxx running
[ 5] MapConfigX 1.1 AdaskoMX mapconfigx.amxx running
[ 6] AMXBans: Screens Gm 1.6 Larte Team amxbans_ssban.a running
[ 7] AMXBans: Main Gm 1.6 Larte Team amxbans_main.am debug
[ 8] AMXBans: Freeze Gm 1.6 Larte Team amxbans_freeze. running
[ 9] AMXBans: Core Gm 1.6 Larte Team amxbans_core.am running
[ 10] AMXBans: Flagged Gm 1.6 Larte Team amxbans_flagged running
[ 11] AES: Informer 0.5 Vega serfreeman1337 aes_informer.am running
[ 12] Stats Configuration 1.9.0.5263 AMXX Dev Team statscfg.amxx running
[ 13] AES: CStrike Addon 0.5 Vega serfreeman1337 aes_exp_cstrike running
[ 14] Advanced Experience Sy 0.5 Vega serfreeman1337 aes_main.amxx running

[ 15] AES: StatsX 0.5 Vega serfreeman1337 aes_statsx_cstr running
[ 16] Prefix Manager 0.1 serfreeman1337 prefixManager.a running
[ 17] Hide Slash Commands 1.0.0 Kreation +mod.le SymbolChat.amxx running
[ 18] Steam Models 0.1b+mod.l Freedo.m steam_models.am running
[ 19] Afk Control 0.4 Stable Freedo.m | neygo afk_control.amx running
[ 20] Admin Spectator ESP 1.3 KoST admin_spec_esp. running
[ 21] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 22] Admin Commands 1.9.0.5263 AMXX Dev Team admincmd.amxx running
[ 23] Admin Help 1.9.0.5263 AMXX Dev Team adminhelp.amxx running
[ 24] Slots Reservation 1.9.0.5263 AMXX Dev Team adminslots.amxx running
[ 25] Multi-Lingual System 1.9.0.5263 AMXX Dev Team multilingual.am running
[ 26] Menus Front-End 1.9.0.5263 AMXX Dev Team menufront.amxx running
[ 27] Commands Menu 1.9.0.5263 AMXX Dev Team cmdmenu.amxx running
[ 28] Players Menu 1.9.0.5271 AMXX Dev Team plmenu.amxx running
[ 29] Teleport Menu 1.9.0.5263 AMXX Dev Team telemenu.amxx running

[ 30] Plugin Menu 1.9.0.5263 AMXX Dev Team pluginmenu.amxx running
[ 31] Admin Chat 1.9.0.5263 AMXX Dev Team adminchat.amxx running
[ 32] Anti Flood 1.9.0.5263 AMXX Dev Team antiflood.amxx running
[ 33] Scrolling Message 1.9.0.5263 AMXX Dev Team scrollmsg.amxx running
[ 34] Info. Messages 1.9.0.5263 AMXX Dev Team imessage.amxx running
[ 35] Admin Votes 1.9.0.5263 AMXX Dev Team adminvote.amxx running
[ 36] TimeLeft 1.9.0.5263 AMXX Dev Team timeleft.amxx running
[ 37] CS Shop 5.0 iNeedHelp CS_Shop_n.amxx running
[ 38] MoneyTransfer 0.3 ZETA [M|E|N] money_transfer_ running
[ 39] Admin Rich 1.0 Emilioneri admin_rich_with debug
[ 40] Autoresponder/Advertis 0.5 MaximusBrood ad_manager.amxx running
[ 41] Reset Score 1.0 Silenttt resetscore.amxx running
[ 42] Weapon Menu 1.0 Mattcook & xerob weaponmenu_rus. running
[ 43] GunGame AMMO 2.2 Prayer gg_ammo.amxx running
[ 44] Ultimate Gore 1.6 JTP10181 amx_gore_ultima running

[ 45] Super Bunny Hopper 1.2 Cheesy Peteza bhop.amxx running
[ 46] Bullet Damage 0.0.1 ConnorMcLeod bullet_damage.a running
[ 47] MultiJump 1.1 Solo[59rus] multijump_with_ running
[ 48] Vampire 1.0c Shalfey vampire3+vip.am running
[ 49] Grenade Trail 1.0 Jim grenade_trail.a running
[ 50] Sentry CSDM Menu 1.0 sap273 amx_sentry_menu running
[ 51] Sentry CSDM Menu 1.0 sap273 amx_sentry_menu running
[ 52] AMX Admin Model 1.1.1 whitemike amx_adminmodel. running
[ 53] Blue Fade 0.1 Stimul Blue_Fade.amxx running
[ 54] Golden Ak 47 1.0 AlejandroSk GoldenAk_ul.amx running
[ 55] Automatic Unstuck 1.5 NL)Ramon(NL stuck.amxx running
[ 56] CSDM Spec 1.0 miRror spec_switch.amx running
[ 57] SF TripMine 0.3.4 serfreeman1337 sfTripMine_FIX_ running
[ 58] DeagsMapManager 3.25Beta Deags/AMXX Commu deagsmapmanager running
[ 59] Maps Menu 1.9.0.5263 AMXX Dev Team mapsmenu.amxx running

[ 60] Golden M4A1 1.0 Alicx DarK GoldenM4a1_ul.a running
[ 61] VIP CSDM 1.0 Godzilla csdm_vipmenu_27 running
[ 62] Unlimited Clip v 1.0 Sap unlimited_clip_ running
[ 63] Kill Rewards 1.4 HoLLyWooD kill_rewards.am running
[ 64] WalkGuard 1.3.2 mogel walkguard.amxx running
[ 65] Knife Scratch 1.0 PahanCS KnifeScratch.am running
[ 66] All Chat 1.1 Ian Cammarata allchat.amxx running
[ 67] No Radio Flood 1.1 Starsailor no_radio_flood. running
[ 68] Unlimited Team Changes 1.3 HamletEagle unlimited_teamc running
[ 69] silentnades 1.0 regalis silent_nades.am running
[ 70] Test dhud_message_te running
[ 71] effect day/night 1.3 Destro day_night.amxx running
[ 72] Block name change 1.0 grankee changename.amxx running
[ 73] Unlimited Money 2.0 NL)Ramon(NL unlimited_money running
[ 74] Sentry guns 1.1 JGHG & miRror sentryguns_2000 running

[ 75] Connect Exec 1.0 AleX connect_exec.am running
[ 76] Knife Double Frags 0.3 Rul4 kdf_ul.amxx running
[ 77] Golden AWP 1.1 Anonymousstar goldenawp_ul.am running
[ 78] Auto recording demo 2.0 IzI | Bonaqua (R amx_autodemorec running
[ 79] plugin_trail 1.3.1 Bahrmanou plugin_trail.am running
[ 80] Change Team 1.1 neygomon & Alien changeteam.amxx running
[ 81] x x x map.amxx running
[ 82] say /motd 1.1 Pa1n say_motd.amxx running
[ 83] AntiFlash FINAL 5.0 Leo_[BH] antiflash5.amxx running
[ 84] ReChecker Logging 1.0 custom rc_logging.amxx running
[ 85] Golden Deagle 1.6 AlejandroSk deaglegold_ul.a running
[ 86] Game Namer 1.1 NeuroToxin gamenamechanger running
[ 87] Ultimate Chats Control 5.2(c) neygomon ucc.amxx running
[ 88] UCC Addon: VoteGAG 1.2 neygomon ucc_votegag.amx running
[ 89] Build Dispenser 1.0.2 bogdan_kondruk Dispenser_3_Lvl running
[ 90] MG Grab 1.0 Nickron mg_grab.amxx running
[ 91] Black Smoke 1.0 xPaw, Justick colored_smoke.a running
[ 92] Player Status 1.0 Player Status csdm_hp.amxx running
[ 93] Weapon Model + Sound R 1.2 GHW_Chronic GHW_Weapon_Repl running
[ 94] Custom Radio Commands 0.6 KaLoSZyFeR custom_radio.am running
[ 95] All Info 1.4 Rockon allinfo.amxx running
[ 96] Spectator Hud Informat 0.0.1 ConnorMcLeod spec_hud_info.a running
[ 97] Plugin 1.0 ~D4rkSiD3Rs~ admins_speed.am running
[ 98] Auto VIP [STEAM] 1.1 ArtHa auto_steam_vip. running
[ 99] CSDM Main 3.6 CSDM Team csdm_main.amxx running
[100] ReCSDM Equip 3.6 ReCSDM Team csdm_equip.amxx debug
[101] CSDM Spawns 3.6 CSDM Team csdm_spawn_pres running
[102] CSDM Misc 3.6 CSDM Team csdm_misc.amxx running
[103] CSDM Protection 3.6 BAILOPAN csdm_protection running
[104] CSDM Item Mode 2.1.3d FALUCO & KWo & S csdm_itemmode.a debug

Автор плагина
bogdan_kondruk
Версия плагина
1.0.2
Исходный код

здравствуйте помогите исправить ошибку

  • 24.5 KB
    Просмотры: 86















  • #2

Код:

if(get_user_team(iOwner) != pev( iEnt, pev_iuser4))
{
    BreakAllPlayerDispensers(iOwner);
-    g_iPlayerDispenser[id] = 0
+    g_iPlayerDispenser[iOwner] = 0
    return PLUGIN_CONTINUE;
}

Я так понимаю, так должно было быть

Author

Message

Veteran Member

Fuck For Fun's Avatar

Old

08-18-2014

, 14:48

 

Run time error 4: index out of bounds

Reply With Quote

#1


Quote:

L 08/19/2014 — 03:07:02: [AMXX] Displaying debug trace (plugin «Days.amxx»)
L 08/19/2014 — 03:07:02: [AMXX] Run time error 4: index out of bounds
L 08/19/2014 — 03:07:02: [AMXX] [0] Days.sma::CmdVoteMenu_Handler

Code:

public CmdShowVoteMenu()
{
    static szMenu[ 100 ], iMenu, iTotalVotes;
    
    iTotalVotes = GetTotalVotes();
    
    formatex( szMenu, charsmax( szMenu ), "r[%s] yDays Vote  wMenu^n^nr// wTime Left: y%i Seconds^nwr// wTotal Votes: y%i  Votes", g_szMenuPrefix, g_iCounter, iTotalVotes );
    
    iMenu = menu_create( szMenu, "CmdVoteMenu_Handler" );
    
    for ( new i = 0; i < sizeof g_iSelectedDays; i++ )
    {
        formatex( szMenu, charsmax( szMenu ), "w%s r[y%i Votes -  %i%sr]", g_szDaysData[ g_iSelectedDays[ i ] ][ m_DayName ], g_iVotes[ i  ], (iTotalVotes > 0 ) ? ( floatround( ( float( g_iVotes[ i ] ) /  float( iTotalVotes ) ) * 100 ) ) : 0, "%" );
        
        menu_additem( iMenu, szMenu );
    }
    
    for ( new i = 0; i < g_iMaxPlayers; i++ )
    {
        if ( !is_user_connected( i ) )
            continue;
            
        menu_display( i, iMenu, 0 );
    }
}

public CmdVoteMenu_Handler( client, iMenu, item )
{
    if ( item != MENU_EXIT && is_user_connected( client ) )
    {
        if ( !g_iCounter )
            return 1;
    
        if ( g_iPlayersVotes[ client ] != DAY_NONE )
            return 1;
            
        g_iPlayersVotes[ client ] = g_iSelectedDays[ item ];
        
        g_iVotes[ item ]++;
        
        ColorChat( 0, RED, "%s^x03 %s^x01 has voted to^x04 %s^x01.",  g_szPrefix, GetUserName( client ), g_szDaysData[ g_iSelectedDays[ item ]  ][ m_DayName ] );
    }
    
    return 1;
}

Last edited by Fuck For Fun; 08-23-2014 at 17:13.

Fuck For Fun is offline

Send a message via Skype™ to Fuck For Fun

AMX Mod X Plugin Approver

HamletEagle's Avatar

Join Date: Sep 2013

Location: Romania

Old

08-18-2014

, 15:11

 

Re: Run time error 4: index out of bounds

Reply With Quote

#2


1. Don’t do a players loop like this. Use get_players.
2. Maybe you shoud check is player is connected/alive.

__________________

HamletEagle is offline

Veteran Member

Fuck For Fun's Avatar

Old

08-18-2014

, 15:30

 

Re: Run time error 4: index out of bounds

Reply With Quote

#3


Quote:

Originally Posted by HamletEagle
View Post

1. Don’t do a players loop like this. Use get_players.
2. Maybe you shoud check is player is connected/alive.

where check player connected/alive?

Give me another option to loop that I always use that.

Fuck For Fun is offline

Send a message via Skype™ to Fuck For Fun

AMX Mod X Plugin Approver

HamletEagle's Avatar

Join Date: Sep 2013

Location: Romania

Old

08-18-2014

, 15:40

 

Re: Run time error 4: index out of bounds

Reply With Quote

#4


Quote:

Originally Posted by HamletEagle
View Post

1. Don’t do a players loop like this. Use get_players.
2. Maybe you shoud check is player is connected/alive.

In bold, what you asked.

__________________


Last edited by HamletEagle; 08-18-2014 at 15:40.

HamletEagle is offline

Veteran Member

Fuck For Fun's Avatar

Old

08-18-2014

, 15:47

 

Re: Run time error 4: index out of bounds

Reply With Quote

#5


Does not seem to me, to do check alive player’s to votedays.

i set Connected and I will check it..

And as for CmdGgDay I have no idea ..

Fuck For Fun is offline

Send a message via Skype™ to Fuck For Fun

AMX Mod X Plugin Approver

HamletEagle's Avatar

Join Date: Sep 2013

Location: Romania

Old

08-18-2014

, 15:51

 

Re: Run time error 4: index out of bounds

Reply With Quote

#6


Code:

public CmdVoteMenu_Handler( client, iMenu, item ) {     if ( item != MENU_EXIT && is_user_connected( id ) )     {         if ( !g_iCounter )             return 1;             if ( g_iPlayersVotes[ client ] != DAY_NONE )             return 1;                     g_iPlayersVotes[ client ] = g_iSelectedDays[ item ];                 g_iVotes[ item ]++;                 ColorChat( 0, RED, "%s^x03 %s^x01 has voted to^x04 %s^x01.", g_szPrefix, GetUserName( client ), g_szDaysData[ g_iSelectedDays[ item ] ][ m_DayName ] );     }         return 1; }

For 1:

Code:

new iPlayers[ 32 ], iNum get_players( iPlayers, iNum ) for( new i = 0; i < iNum; i++ ) { }

__________________


Last edited by HamletEagle; 08-18-2014 at 15:52.

HamletEagle is offline

Veteran Member

Fuck For Fun's Avatar

Old

08-18-2014

, 21:15

 

Re: Run time error 4: index out of bounds

Reply With Quote

#7


post in thread


Last edited by Fuck For Fun; 08-19-2014 at 16:57.

Fuck For Fun is offline

Send a message via Skype™ to Fuck For Fun

Veteran Member

fysiks's Avatar

Join Date: Sep 2007

Location: Flatland, USA

Old

08-19-2014

, 02:23

 

Re: Run time error 4: index out of bounds

Reply With Quote

#8


Did you check the values that are being used to index ALL of the arrays in your function which is causing the errors?

__________________

fysiks is offline

Senior Member

Deathknife's Avatar

Old

08-19-2014

, 04:49

 

Re: Run time error 4: index out of bounds

Reply With Quote

#9


This won’t fix your problem, but shouldn’t

Code:

g_iCurrentDay = g_iSelectedDays[ random( sizeof g_iSelectedDays ) ];

be:

Code:

g_iCurrentDay = g_iSelectedDays[ random( charsmax(g_iSelectedDays) ) ];

Deathknife is offline

Veteran Member

Flick3rR's Avatar

Join Date: Feb 2014

Location: Bulgaria, Stara Zagora

Flick3rR is offline

Send a message via Skype™ to Flick3rR

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Debug run time error 19 file or function is not found
  • Debug log rimworld как исправить
  • Debug error что это
  • Debug error run time check failure 2 stack around the variable
  • Debug error pure virtual function call

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии