Raised This Month: $ Target: $400
 0% 

Array Invalid (Bug Perhaps)?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 01-23-2007 , 11:54   Array Invalid (Bug Perhaps)?
Reply With Quote #1

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]
__________________


Last edited by mysticssjgoku4; 01-23-2007 at 12:17.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 01-23-2007 , 12:19   Re: Array Invalid (Bug Perhaps)?
Reply With Quote #2

You just can't do that. You need to use constants when defining arrays.
__________________
Brad is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 01-23-2007 , 12:23   Re: Array Invalid (Bug Perhaps)?
Reply With Quote #3

Quote:
Originally Posted by Brad View Post
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.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 01-23-2007 , 13:04   Re: Array Invalid (Bug Perhaps)?
Reply With Quote #4

How do you do it when creating a stock function?
__________________
Brad is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 01-23-2007 , 13:18   Re: Array Invalid (Bug Perhaps)?
Reply With Quote #5

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
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 01-23-2007 , 13:34   Re: Array Invalid (Bug Perhaps)?
Reply With Quote #6

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
__________________
schnitzelmaker 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 22:24.


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