SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/11/2019, 08:16 PM   #21
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,842
Reputation: 1312
Default Re: [HELP] Run time error 4: "Array index out of bounds"

You have a much bigger problem. That will use all textdraw slots.

Code:
for(new i = 0; i < MAX_PLAYERS; i++)
    {

        TAXIMET[i] = TextDrawCreate(378.000000, 360.000000, "Taximetro");
        TextDrawBackgroundColor(TAXIMET[i], 255);
        TextDrawFont(TAXIMET[i], 1);
        TextDrawLetterSize(TAXIMET[i], 0.500000, 1.000000);
        TextDrawColor(TAXIMET[i], -1);
        TextDrawSetOutline(TAXIMET[i], 0);
        TextDrawSetProportional(TAXIMET[i], 1);
        TextDrawSetShadow(TAXIMET[i], 1);
        TextDrawUseBox(TAXIMET[i], 1);
        TextDrawBoxColor(TAXIMET[i], 255);
        TextDrawTextSize(TAXIMET[i], 494.000000, 230.000000);

        TAXIMET2[i] = TextDrawCreate(470.000000, 360.000000, "$0");
        TextDrawBackgroundColor(TAXIMET2[i], 255);
        TextDrawFont(TAXIMET2[i], 1);
        TextDrawLetterSize(TAXIMET2[i], 0.500000, 1.000000);
        TextDrawColor(TAXIMET2[i], -1);
        TextDrawSetOutline(TAXIMET2[i], 0);
        TextDrawSetProportional(TAXIMET2[i], 1);
        TextDrawSetShadow(TAXIMET2[i], 1);

        // Velocimetro y Taximetro

        santiago1[i] = TextDrawCreate(620.447937, 337.500030, "usebox");
        TextDrawLetterSize(santiago1[i], 0.000000, 4.609256);
        TextDrawTextSize(santiago1[i], 539.610473, 0.000000);
        TextDrawAlignment(santiago1[i], 1);
        TextDrawColor(santiago1[i], 0);
        TextDrawUseBox(santiago1[i], 1);
        TextDrawBoxColor(santiago1[i], 0x0B0B0BAA);
        TextDrawSetShadow(santiago1[i], 1);
        TextDrawSetOutline(santiago1[i], 0);
        TextDrawFont(santiago1[i], 0);

        santiago2[i] = TextDrawCreate(620.447998, 384.750000, "usebox");
        TextDrawLetterSize(santiago2[i], 0.000000, 4.544444);
        TextDrawTextSize(santiago2[i], 539.610534, 0.000000);
        TextDrawAlignment(santiago2[i], 1);
        TextDrawColor(santiago2[i], -1);
        TextDrawUseBox(santiago2[i], 1);
        TextDrawBoxColor(santiago2[i], 0x0B0B0BAA);
        TextDrawSetShadow(santiago2[i], 0);
        TextDrawSetOutline(santiago2[i], 0);
        TextDrawFont(santiago2[i], 0);

        santiago3[i] = TextDrawCreate(588.930725, 404.833251, "KM/h");
        TextDrawLetterSize(santiago3[i], 0.321155, 0.958333);
        TextDrawAlignment(santiago3[i], 1);
        TextDrawColor(santiago3[i], -1);
        TextDrawSetShadow(santiago3[i], 0);
        TextDrawSetOutline(santiago3[i], 1);
        TextDrawBackgroundColor(santiago3[i], 51);
        TextDrawFont(santiago3[i], 1);
        TextDrawSetProportional(santiago3[i], 1);

        santiago4[i] = TextDrawCreate(549.106384, 384.416839, "Velocimetro");
        TextDrawLetterSize(santiago4[i], 0.302412, 1.308332);
        TextDrawAlignment(santiago4[i], 1);
        TextDrawColor(santiago4[i], -1);
        TextDrawSetShadow(santiago4[i], 0);
        TextDrawSetOutline(santiago4[i], 1);
        TextDrawBackgroundColor(santiago4[i], 51);
        TextDrawFont(santiago4[i], 1);
        TextDrawSetProportional(santiago4[i], 1);

        santiago5[i] = TextDrawCreate(558.008972, 399.583282, "0");
        TextDrawLetterSize(santiago5[i], 0.449999, 1.600000);
        TextDrawAlignment(santiago5[i], 1);
        TextDrawColor(santiago5[i], -1);
        TextDrawSetShadow(santiago5[i], 0);
        TextDrawSetOutline(santiago5[i], 1);
        TextDrawBackgroundColor(santiago5[i], 51);
        TextDrawFont(santiago5[i], 1);
        TextDrawSetProportional(santiago5[i], 1);

        santiago6[i] = TextDrawCreate(546.296081, 337.166625, "Combustible");
        TextDrawLetterSize(santiago6[i], 0.321156, 1.424999);
        TextDrawAlignment(santiago6[i], 1);
        TextDrawColor(santiago6[i], -1);
        TextDrawSetShadow(santiago6[i], 0);
        TextDrawSetOutline(santiago6[i], 1);
        TextDrawBackgroundColor(santiago6[i], 51);
        TextDrawFont(santiago6[i], 1);
        TextDrawSetProportional(santiago6[i], 1);

        santiago7[i] = TextDrawCreate(548.638305, 352.333374, "0/100");
        TextDrawLetterSize(santiago7[i], 0.449999, 1.600000);
        TextDrawAlignment(santiago7[i], 1);
        TextDrawColor(santiago7[i], -1);
        TextDrawSetShadow(santiago7[i], 0);
        TextDrawSetOutline(santiago7[i], 1);
        TextDrawBackgroundColor(santiago7[i], 51);
        TextDrawFont(santiago7[i], 1);
        TextDrawSetProportional(santiago7[i], 1);
Pottus is offline   Reply With Quote
Old 12/11/2019, 08:35 PM   #22
Th3N0oB
Big Clucker
 
Join Date: Oct 2016
Location: Ecuador
Posts: 132
Reputation: 1
Default Re: [HELP] Run time error 4: "Array index out of bounds"

Quote:
Originally Posted by Pottus View Post
You have a much bigger problem. That will use all textdraw slots.

Code:
for(new i = 0; i < MAX_PLAYERS; i++)
    {

        TAXIMET[i] = TextDrawCreate(378.000000, 360.000000, "Taximetro");
        TextDrawBackgroundColor(TAXIMET[i], 255);
        TextDrawFont(TAXIMET[i], 1);
        TextDrawLetterSize(TAXIMET[i], 0.500000, 1.000000);
        TextDrawColor(TAXIMET[i], -1);
        TextDrawSetOutline(TAXIMET[i], 0);
        TextDrawSetProportional(TAXIMET[i], 1);
        TextDrawSetShadow(TAXIMET[i], 1);
        TextDrawUseBox(TAXIMET[i], 1);
        TextDrawBoxColor(TAXIMET[i], 255);
        TextDrawTextSize(TAXIMET[i], 494.000000, 230.000000);

        TAXIMET2[i] = TextDrawCreate(470.000000, 360.000000, "$0");
        TextDrawBackgroundColor(TAXIMET2[i], 255);
        TextDrawFont(TAXIMET2[i], 1);
        TextDrawLetterSize(TAXIMET2[i], 0.500000, 1.000000);
        TextDrawColor(TAXIMET2[i], -1);
        TextDrawSetOutline(TAXIMET2[i], 0);
        TextDrawSetProportional(TAXIMET2[i], 1);
        TextDrawSetShadow(TAXIMET2[i], 1);

        // Velocimetro y Taximetro

        santiago1[i] = TextDrawCreate(620.447937, 337.500030, "usebox");
        TextDrawLetterSize(santiago1[i], 0.000000, 4.609256);
        TextDrawTextSize(santiago1[i], 539.610473, 0.000000);
        TextDrawAlignment(santiago1[i], 1);
        TextDrawColor(santiago1[i], 0);
        TextDrawUseBox(santiago1[i], 1);
        TextDrawBoxColor(santiago1[i], 0x0B0B0BAA);
        TextDrawSetShadow(santiago1[i], 1);
        TextDrawSetOutline(santiago1[i], 0);
        TextDrawFont(santiago1[i], 0);

        santiago2[i] = TextDrawCreate(620.447998, 384.750000, "usebox");
        TextDrawLetterSize(santiago2[i], 0.000000, 4.544444);
        TextDrawTextSize(santiago2[i], 539.610534, 0.000000);
        TextDrawAlignment(santiago2[i], 1);
        TextDrawColor(santiago2[i], -1);
        TextDrawUseBox(santiago2[i], 1);
        TextDrawBoxColor(santiago2[i], 0x0B0B0BAA);
        TextDrawSetShadow(santiago2[i], 0);
        TextDrawSetOutline(santiago2[i], 0);
        TextDrawFont(santiago2[i], 0);

        santiago3[i] = TextDrawCreate(588.930725, 404.833251, "KM/h");
        TextDrawLetterSize(santiago3[i], 0.321155, 0.958333);
        TextDrawAlignment(santiago3[i], 1);
        TextDrawColor(santiago3[i], -1);
        TextDrawSetShadow(santiago3[i], 0);
        TextDrawSetOutline(santiago3[i], 1);
        TextDrawBackgroundColor(santiago3[i], 51);
        TextDrawFont(santiago3[i], 1);
        TextDrawSetProportional(santiago3[i], 1);

        santiago4[i] = TextDrawCreate(549.106384, 384.416839, "Velocimetro");
        TextDrawLetterSize(santiago4[i], 0.302412, 1.308332);
        TextDrawAlignment(santiago4[i], 1);
        TextDrawColor(santiago4[i], -1);
        TextDrawSetShadow(santiago4[i], 0);
        TextDrawSetOutline(santiago4[i], 1);
        TextDrawBackgroundColor(santiago4[i], 51);
        TextDrawFont(santiago4[i], 1);
        TextDrawSetProportional(santiago4[i], 1);

        santiago5[i] = TextDrawCreate(558.008972, 399.583282, "0");
        TextDrawLetterSize(santiago5[i], 0.449999, 1.600000);
        TextDrawAlignment(santiago5[i], 1);
        TextDrawColor(santiago5[i], -1);
        TextDrawSetShadow(santiago5[i], 0);
        TextDrawSetOutline(santiago5[i], 1);
        TextDrawBackgroundColor(santiago5[i], 51);
        TextDrawFont(santiago5[i], 1);
        TextDrawSetProportional(santiago5[i], 1);

        santiago6[i] = TextDrawCreate(546.296081, 337.166625, "Combustible");
        TextDrawLetterSize(santiago6[i], 0.321156, 1.424999);
        TextDrawAlignment(santiago6[i], 1);
        TextDrawColor(santiago6[i], -1);
        TextDrawSetShadow(santiago6[i], 0);
        TextDrawSetOutline(santiago6[i], 1);
        TextDrawBackgroundColor(santiago6[i], 51);
        TextDrawFont(santiago6[i], 1);
        TextDrawSetProportional(santiago6[i], 1);

        santiago7[i] = TextDrawCreate(548.638305, 352.333374, "0/100");
        TextDrawLetterSize(santiago7[i], 0.449999, 1.600000);
        TextDrawAlignment(santiago7[i], 1);
        TextDrawColor(santiago7[i], -1);
        TextDrawSetShadow(santiago7[i], 0);
        TextDrawSetOutline(santiago7[i], 1);
        TextDrawBackgroundColor(santiago7[i], 51);
        TextDrawFont(santiago7[i], 1);
        TextDrawSetProportional(santiago7[i], 1);
What do you mean by that friend? What do you think would be the solution for those Texdraws, place them in OnPlayerConnect? Since those, carry [playerid].
Th3N0oB is offline   Reply With Quote
Old 12/11/2019, 08:35 PM   #23
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 753
Reputation: 147
Default Re: [HELP] Run time error 4: "Array index out of bounds"

Quote:
Originally Posted by Th3N0oB View Post
Yes, I did that quickly just now, to rule out some outdating, but they do have the parameters that it should.
I am clueless. I downloaded YSI and intentionally had wrong parameter count. It actually reported the script line and not y_foreach_iterators.inc file as it happened to you.

Create an empty gamemode and create few vehicles in OnGameModeInit to see if the same warning is given again. If it does and you do not use the siren at all, modifying the hooked function to remove anything related to siren might be a workaround for now.

Quote:
Originally Posted by Th3N0oB View Post
What do you mean by that friend? What do you think would be the solution for those Texdraws, place them in OnPlayerConnect? Since those, carry [playerid].
Per-player instead of global textdraws: https://wiki.sa-mp.com/wiki/CreatePlayerTextDraw
Calisthenics is offline   Reply With Quote
Old 12/11/2019, 09:04 PM   #24
Th3N0oB
Big Clucker
 
Join Date: Oct 2016
Location: Ecuador
Posts: 132
Reputation: 1
Default Re: [HELP] Run time error 4: "Array index out of bounds"

Quote:
Originally Posted by Calisthenics View Post
I am clueless. I downloaded YSI and intentionally had wrong parameter count. It actually reported the script line and not y_foreach_iterators.inc file as it happened to you.

Create an empty gamemode and create few vehicles in OnGameModeInit to see if the same warning is given again. If it does and you do not use the siren at all, modifying the hooked function to remove anything related to siren might be a workaround for now.



Per-player instead of global textdraws: https://wiki.sa-mp.com/wiki/CreatePlayerTextDraw
Regarding YSI, I think it's a good idea what you just said, I was doing some tests and these are the results:

The error is the same whether or not the value of "0" is added with respect to "addsiren", and THE AMX SIZE OF THESE SHORT LINES IS: 12.421 Lol


pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <JunkBuster>
#include <a_samp>
#include <crashdetect>
#include <progress2>
#include <zcmd>
#include <a_mysql>
#include <sscanf2>
#include <streamer>
#include <foreach>
#include <mSelection>
#include <mSelection2>
#include <a_zones>
#include <yom_buttons>
#include <vfunc>
#include <geolocation>
#include <fix_mapas>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    CreateVehicle(431,1546.1302,-1679.9119,5.9938,179.5670,0,0,-1,0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

Warnings

pawn Code:
...\pawno\include\YSI_Data\y_foreach\y_foreach_iterators.inc(714) : warning 202: number of arguments does not match definition
...\gamemodes\testysi.pwn(249) : warning 203: symbol is never used: "_progress2_renderBar"
Pawn compiler 3.10.8            Copyright (c) 1997-2006, ITB CompuPhase

Header size:           5108 bytes
Code size:           267048 bytes
Data size:         26429628 bytes
Stack/heap size:      16384 bytes; estimated max. usage=1605 cells (6420 bytes)
Total requirements:26718168 bytes

2 Warnings.

Now, if I try to remove the include <progress2>, this is the result:

pawn Code:
...\pawno\include\YSI\y_iterate.inc(73) : fatal error 111: user error: Use `#include <YSI_Data\y_iterate>`

Compilation aborted.

Pawn compiler 3.10.8            Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

PD: All the include that I use in the Gamemode that I am working on, are the ones that I placed in the test gamemode.
PD 2:I begin to think that everything started by changing <progress> to <progress2> but the change was necessary because of the error presented by the crashdetec log.
Th3N0oB is offline   Reply With Quote
Old 12/11/2019, 09:54 PM   #25
Th3N0oB
Big Clucker
 
Join Date: Oct 2016
Location: Ecuador
Posts: 132
Reputation: 1
Default Re: [HELP] Run time error 4: "Array index out of bounds"

Update: By removing the include foreach, everything is resolved in the test gamemode, (even the file size is normal again), something is interfering with the foreach.inc file inside it: #define include <foreach> , I just updated to the latest version of foreach.inc, but the warning follows.
Th3N0oB is offline   Reply With Quote
Old 13/11/2019, 06:54 AM   #26
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 753
Reputation: 147
Default Re: [HELP] Run time error 4: "Array index out of bounds"

Standalone foreach hasn't been updated for a long time. Include YSI_Data\y_iterate instead which is the updated version. Include YSI libraries after a_samp and before any other.

progress2 includes y_iterate, so you might be right and it conflicts with standalone foreach.

I also noticed vfunc.inc, make sure you have version 1.2 which has added siren parameter.
Calisthenics is offline   Reply With Quote
Old 13/11/2019, 09:01 PM   #27
Th3N0oB
Big Clucker
 
Join Date: Oct 2016
Location: Ecuador
Posts: 132
Reputation: 1
Default Re: [HELP] Run time error 4: "Array index out of bounds"

I update: The problem of the YSI warning was finally SOLVED, but the file size is still around 17Mb, it is assumed that it should already be in its normal size of 3Mb already compiled, is that due to the problem of Global TextDraws mentioned above?
Th3N0oB is offline   Reply With Quote
Old 14/11/2019, 12:31 PM   #28
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 753
Reputation: 147
Default Re: [HELP] Run time error 4: "Array index out of bounds"

Quote:
Originally Posted by Th3N0oB View Post
I update: The problem of the YSI warning was finally SOLVED, but the file size is still around 17Mb, it is assumed that it should already be in its normal size of 3Mb already compiled, is that due to the problem of Global TextDraws mentioned above?
Quote:
Originally Posted by Th3N0oB View Post
Basic Description of the Problem

With the #include <YSI_Data / y_iterate>
The testysi.amx file is approximately 5Mb in size.

Without the #include <YSI_Data / y_iterate>
The testysi.amx file is approximately 1Kb in size. (The original size)

So what is happening with this include, is it defective, or am I doing something wrong? The script has very few lines it is impossible that despite too much or what would be the solution to this, it is giving me problems with my original gamemode, and I am testing with that base gamemode, but with that excessive size, I need to fix it.
In an empty gamemode with only y_iterate included (note that it must be backslash <YSI_Data\y_iterate>), the amx size is 11.3MB. However in a gamemode I was coding last year with y_iterate, y_groops, y_commands, y_dialog, y_timers and y_va includes, surprisingly the size of it was only 984KB.

If I had to take a wild guess, I would say that the more code of YSI libraries you use into the script, the lower the size (data size, but header and stack/heap size will be increased) will become eventually. Do not forget about YSI_YES_HEAP_MALLOC.

pawn Code:
#include <a_samp>

#define YSI_YES_HEAP_MALLOC

// YSI includes
#include <YSI_Data\y_iterate>

// rest of includes
Calisthenics is offline   Reply With Quote
Old 14/11/2019, 08:19 PM   #29
Th3N0oB
Big Clucker
 
Join Date: Oct 2016
Location: Ecuador
Posts: 132
Reputation: 1
Default Re: [HELP] Run time error 4: "Array index out of bounds"

Quote:
Originally Posted by Calisthenics View Post
In an empty gamemode with only y_iterate included (note that it must be backslash <YSI_Data\y_iterate>), the amx size is 11.3MB. However in a gamemode I was coding last year with y_iterate, y_groops, y_commands, y_dialog, y_timers and y_va includes, surprisingly the size of it was only 984KB.

If I had to take a wild guess, I would say that the more code of YSI libraries you use into the script, the lower the size (data size, but header and stack/heap size will be increased) will become eventually. Do not forget about YSI_YES_HEAP_MALLOC.

pawn Code:
#include <a_samp>

#define YSI_YES_HEAP_MALLOC

// YSI includes
#include <YSI_Data\y_iterate>

// rest of includes
The inclination of / a \ in the include, remained the same, showed no result, the file size was still exaggerated, I decided to lower the version of the YSI to 4, and weighs only 6Mb (although the same is much, the normal weight 3Mb), the problem now is the spawn inside the server, one problem seems to drag the other, I hope to fix it soon.
Th3N0oB is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[debug] Run time error 4: "Array index out of bounds" problem MaestrulFritz Scripting Help 1 31/08/2019 12:14 PM
[debug] Run time error 4: "Array index out of bounds" nGen.SoNNy Scripting Help 3 06/03/2019 05:16 PM
Run time error 4: "Array index out of bounds" in Server Console! HAGAKURE Scripting Help 6 13/07/2016 10:18 PM
[debug] Run time error 4: "Array index out of bounds" and many more errors :P ntmp Scripting Help 2 11/08/2014 03:10 PM
Run time error 4: "Array index out of bounds" in public turftaking [SF]OutLawZ Scripting Help 1 01/08/2012 06:07 AM


All times are GMT. The time now is 03:53 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.