Raised This Month: $51 Target: $400
 12% 

[TF2] Array Index is out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bitl
Senior Member
Join Date: Jul 2012
Old 11-02-2012 , 19:35   [TF2] Array Index is out of bounds
Reply With Quote #1

Hi.

I was working on my new plugin, Arms Race, when I encountered the "Array Index is out of bounds" error
Code:
	new RandomNumbersArrayScout[21] = {45,220,448,772,46,163,222,294,449,773,812,44,221,317,325,349,355,450,452,572,648};
	new randomnumScout = GetRandomInt(0, 21);
if (TF2_GetPlayerClass(client) == TFClass_Scout)
	{
		if (IsClientInGame(client))
		{
			SoundNormal(client);
			TF2Items_GiveWeapon(client, RandomNumbersArrayScout[randomnumScout]);
		}
	}
There are multiple of these for every class, so the problem occurs on each one.

Last edited by Bitl; 11-02-2012 at 19:36.
Bitl is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 11-02-2012 , 19:37   Re: [TF2] Array Index is out of bounds
Reply With Quote #2

21 elements (from 0 to 20)
so...
Leonardo is offline
Bitl
Senior Member
Join Date: Jul 2012
Old 11-02-2012 , 19:52   Re: [TF2] Array Index is out of bounds
Reply With Quote #3

Quote:
Originally Posted by Leonardo View Post
21 elements (from 0 to 20)
so...
But if I do that, will it get all 21 indexes?
Bitl is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 11-02-2012 , 20:02   Re: [TF2] Array Index is out of bounds
Reply With Quote #4

number of indexes - 21
max index - 20
to get index #21 you must set number of values 22
Leonardo is offline
Bitl
Senior Member
Join Date: Jul 2012
Old 11-02-2012 , 20:11   Re: [TF2] Array Index is out of bounds
Reply With Quote #5

Quote:
Originally Posted by Leonardo View Post
number of indexes - 21
max index - 20
to get index #21 you must set number of values 22
Ok, thanks.

One last thing, how do I implement TF2II to the code?
Bitl is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 11-02-2012 , 22:53   Re: [TF2] Array Index is out of bounds
Reply With Quote #6

Quote:
Originally Posted by Bitl View Post
One last thing, how do I implement TF2II to the code?
Code:
#include <tf2itemsinfo>
__________________
11530 is offline
Bitl
Senior Member
Join Date: Jul 2012
Old 11-02-2012 , 23:25   Re: [TF2] Array Index is out of bounds
Reply With Quote #7

Quote:
Originally Posted by 11530 View Post
Code:
#include <tf2itemsinfo>
I mean the code itself, it is already included.
Bitl is offline
Bitl
Senior Member
Join Date: Jul 2012
Old 11-03-2012 , 13:34   Re: [TF2] Array Index is out of bounds
Reply With Quote #8

Ok, I tried the arrays and for some reason on random it gets Scout's Bat on other classes than Scout.
Bitl is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 11-03-2012 , 15:42   Re: [TF2] Array Index is out of bounds
Reply With Quote #9

0 - tf_weapon_bat, not an invalid item.
Leonardo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-04-2012 , 08:06   Re: [TF2] Array Index is out of bounds
Reply With Quote #10

-1 is an invalid entity, though.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Reply



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

Forum Jump


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


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