SA-MP Forums Archive
[HELP]TextDraw, Array out of bounds - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP]TextDraw, Array out of bounds (/showthread.php?tid=281304)



[HELP]TextDraw, Array out of bounds - TheBluec0de - 05.09.2011

that we do wrong?

Код:
C:\Users\Pavilion\Desktop\ILV Server\pawno\ILV.pwn(258) : error 032: array index out of bounds (variable "ILVBlu")
C:\Users\Pavilion\Desktop\ILV Server\pawno\ILV.pwn(282) : error 032: array index out of bounds (variable "ILVBlue")
C:\Users\Pavilion\Desktop\ILV Server\pawno\ILV.pwn(303) : error 032: array index out of bounds (variable "ILVBlue")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
a top of the script..

Код:
new Text:ILVBlue[6];
OnGameModeInit

Код:
	ILVBlue[1] = TextDrawCreate(494.000000, 430.000000, "~b~]~b~~h~]~b~~h~~h~]~b~~h~~h~~h~]~b~~h~~h~~h~~h~]]]]]]]~b~~h~~h~~h~]~b~~h~~h~]~b~~h~]~b~]");
	TextDrawBackgroundColor(ILVBlue[1], 255);
	TextDrawFont(ILVBlue[1], 0);
	TextDrawLetterSize(ILVBlue[1], 0.270000, 1.000000);
	TextDrawColor(ILVBlue[1], -1);
	TextDrawSetOutline(ILVBlue[1], 0);
	TextDrawSetProportional(ILVBlue[1], 1);
	TextDrawSetShadow(ILVBlue[1], 1);

	ILVBlue[2] = TextDrawCreate(494.000000, 419.000000, "--------------------");
	TextDrawBackgroundColor(ILVBlue[2], 255);
	TextDrawFont(ILVBlue[2], 0);
	TextDrawLetterSize(ILVBlue[2], 0.270000, 1.000000);
	TextDrawColor(ILVBlue[2], -1);
	TextDrawSetOutline(ILVBlue[2], 0);
	TextDrawSetProportional(ILVBlue[2], 1);
	TextDrawSetShadow(ILVBlue[2], 1);

	ILVBlue[3] = TextDrawCreate(502.000000, 338.000000, "~b~I~h~t~h~~h~a~b~l~h~i~h~~h~a~b~n");
	TextDrawBackgroundColor(ILVBlue[3], 255);
	TextDrawFont(ILVBlue[3], 0);
	TextDrawLetterSize(ILVBlue[3], 1.220000, 2.700000);
	TextDrawColor(ILVBlue[3], -1);
	TextDrawSetOutline(ILVBlue[3], 0);
	TextDrawSetProportional(ILVBlue[3], 1);
	TextDrawSetShadow(ILVBlue[3], 1);

	ILVBlue[4] = TextDrawCreate(522.000000, 365.000000, "~b~L~h~~h~a~b~s");
	TextDrawBackgroundColor(ILVBlue[4], 255);
	TextDrawFont(ILVBlue[4], 0);
	TextDrawLetterSize(ILVBlue[4], 1.160000, 2.700000);
	TextDrawColor(ILVBlue[4], -1);
	TextDrawSetOutline(ILVBlue[4], 0);
	TextDrawSetProportional(ILVBlue[4], 1);
	TextDrawSetShadow(ILVBlue[4], 1);

	ILVBlue[5] = TextDrawCreate(493.000000, 391.000000, "~b~V~h~e~h~~h~n~b~t~h~u~h~~h~r~b~a~h~s");
	TextDrawBackgroundColor(ILVBlue[5], 255);
	TextDrawFont(ILVBlue[5], 0);
	TextDrawLetterSize(ILVBlue[5], 1.160000, 2.700000);
	TextDrawColor(ILVBlue[5], -1);
	TextDrawSetOutline(ILVBlue[5], 0);
	TextDrawSetProportional(ILVBlue[5], 1);
	TextDrawSetShadow(ILVBlue[5], 1);
OnPlayerConnect

Код:
(Line: 258)   TextDrawHideForPlayer(playerid, ILVBlue[6]);
OnPlayerDisconnect

Код:
(Line: 282) TextDrawHideForPlayer(playerid, ILVBlue[6]);
OnPlayerSpawn

Код:
(Line: 303) TextDrawShowForPlayer(playerid, ILVBlue[6]);



Re: [HELP]TextDraw, Array out of bounds - =WoR=Varth - 05.09.2011

pawn Код:
new Text:ILVBlue[6];
By 6 mean 0-5, Not 1-6.


Re: [HELP]TextDraw, Array out of bounds - TheBluec0de - 05.09.2011

I put in textdraw ongamemodeinit, from 0 up to 4-.. but still same error.. help me


Re: [HELP]TextDraw, Array out of bounds - TheBluec0de - 05.09.2011

help ?


Re: [HELP]TextDraw, Array out of bounds - [MWR]Blood - 05.09.2011

You defined 6 cells, but you are using 5.
Aswell start with 0, not 1.


Re: [HELP]TextDraw, Array out of bounds - =WoR=Varth - 05.09.2011

pawn Код:
(Line: 258)   TextDrawHideForPlayer(playerid, ILVBlue[6]);
But you hide the wrong array.

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
You defined 6 cells, but you are using 5.
Aswell start with 0, not 1.
That's not his problem.


Re: [HELP]TextDraw, Array out of bounds - iPLEOMAX - 05.09.2011

What varth means is that you cannot use the actual (max) value of the variable.


pawn Код:
new something:var[5];

//you can use:

/* start */
var[0] = 5448; //ONE
var[1] = 1337; //TWO
var[2] = 1545; //THREE
var[3] = 8741; //FOUR
var[4] = 6544; //FIVE, there you have a total of 5 values. now if you add var[5], it goes out of bounds (6)..
/* end */