AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [SP] String Arrays..... (https://forums.alliedmods.net/showthread.php?t=199142)

SkydiveX 10-24-2012 15:09

[SP] String Arrays.....
 
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. :)

Powerlord 10-24-2012 15:15

Re: [SP] String Arrays.....
 
An array of length 255 has 255 elements, numbered 0 through 254. So, index 255 is indeed out of bounds.

SkydiveX 10-24-2012 15:32

Re: [SP] String Arrays.....
 
Oh.... Thanks!

SkydiveX 10-24-2012 16:22

Re: [SP] String Arrays.....
 
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.

FaTony 10-24-2012 17:05

Re: [SP] String Arrays.....
 
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.


All times are GMT -4. The time now is 11:44.

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