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

[SP] String Arrays.....


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SkydiveX
Member
Join Date: Jul 2012
Location: England
Old 10-24-2012 , 15:09   [SP] String Arrays.....
Reply With Quote #1

Just a simple question.

new String:AbilityNumInfo[255][10];

AbilityNumInfo[255][X] = "Blah";

I get array index out of bounds error.
I'm not entirely sure what is wrong.
Thanks in advance.
__________________

_____________________________________________ _______________
Pastafarian and proud!

Last edited by SkydiveX; 10-24-2012 at 15:09.
SkydiveX is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-24-2012 , 15:15   Re: [SP] String Arrays.....
Reply With Quote #2

An array of length 255 has 255 elements, numbered 0 through 254. So, index 255 is indeed out of bounds.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
SkydiveX
Member
Join Date: Jul 2012
Location: England
Old 10-24-2012 , 15:32   Re: [SP] String Arrays.....
Reply With Quote #3

Oh.... Thanks!
__________________

_____________________________________________ _______________
Pastafarian and proud!
SkydiveX is offline
SkydiveX
Member
Join Date: Jul 2012
Location: England
Old 10-24-2012 , 16:22   Re: [SP] String Arrays.....
Reply With Quote #4

How would I go about modifying the string? I get a must be assigned to an array error using this.
AbilityNumInfo[255][1] = "Name";
Damnit.
__________________

_____________________________________________ _______________
Pastafarian and proud!
SkydiveX is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-24-2012 , 17:05   Re: [SP] String Arrays.....
Reply With Quote #5

A string is an array. Use
PHP Code:
AbilityNumInfo[255] = "Name" 
If you want 2 dimensional array of strings, you'll have to create 3 dimensional array.
__________________
FaTony 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 21:33.


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