AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Array Invalid (Bug Perhaps)? (https://forums.alliedmods.net/showthread.php?t=50297)

mysticssjgoku4 01-23-2007 11:54

Array Invalid (Bug Perhaps)?
 
Code:
        //Get Item Information in TABLE     new i_sizes[2]     get_max_item_str_func(id,i_sizes)         new total_items = i_sizes[0]     new max_item_str = i_sizes[1]+10     new Items[1][max_item_str]

The compiler reads the
Code:
new Items[1][max_item_str]
as an invalid array size.

Also says
Code:
new Items[1][max_item_str+10]
is an invalid array size.

Now I understand why this is occuring, because there is a possibility of a negetive value being the array size, but is there an alternative to achiving this?
I'm sick at home today, so may be I'm just not thinking clear enough to figure this out on my own right now.

Thanks in advance.

--------------

Aye....even tried absolute value...this is somewhat of an annoynce.
Code:
    new total_items = i_sizes[0]     new max_item_str = abs(i_sizes[1])     new Items[1][max_item_str+10]

How the hell does it assume zero when it's the absolute value +10? :S
Bug perhaps?

---------------------------------
Even tried const variable + 10....
Code:
    new total_items = i_sizes[0]     new const max_item_str = abs(i_sizes[1])+10     new Items[1][max_item_str]

Brad 01-23-2007 12:19

Re: Array Invalid (Bug Perhaps)?
 
You just can't do that. You need to use constants when defining arrays.

mysticssjgoku4 01-23-2007 12:23

Re: Array Invalid (Bug Perhaps)?
 
Quote:

Originally Posted by Brad (Post 430669)
You just can't do that. You need to use constants when defining arrays.

But I should be able to do that :S, I don't see why. The cell size will never return 0 or below, so I see not a reason for this error. You can define "dynamic cell sizes" when creating a stock function, but you cannot do this when create a variable directly?
Perhaps a better explanation? I just don't see why it is limited to only constant sizes.

Brad 01-23-2007 13:04

Re: Array Invalid (Bug Perhaps)?
 
How do you do it when creating a stock function?

mysticssjgoku4 01-23-2007 13:18

Re: Array Invalid (Bug Perhaps)?
 
Code:
stock retrieve_data(query[]="",output[][32]) { }

But I believe that is something different. The function can use that variable, but it's not necessarily creating it, it's returning values to the variable that IS created. Right?
I just don't understand why I cannot create a dynamic array size :S

schnitzelmaker 01-23-2007 13:34

Re: Array Invalid (Bug Perhaps)?
 
Quote:

I just don't understand why I cannot create a dynamic array size :S
You cannot creat an dynamic array,why during compile it set how many memory is needed for this plugin and reserved it.
But you can use one of the metamod plugins who can this.
http://forums.alliedmods.net/showthread.php?t=43866


All times are GMT -4. The time now is 22:24.

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