Raised This Month: $ Target: $400
 0% 

Dynamic arrays


Post New Thread Reply   
 
Thread Tools Display Modes
fakuivan
Senior Member
Join Date: Nov 2015
Old 11-20-2015 , 23:09   Re: Dynamic arrays
Reply With Quote #11

Quote:
Originally Posted by Timiditas View Post
You were right, really is not that complicated and works good for my purpose.
Still have two questions though:
1. The sourcemod doc says:

How much slower is it, compared to a normal private array?
And is this "slower" referring only to more complicated operations like iterating through, copying, moving and such, or also to something simple like getting a string out of it?

2. I am getting a compile error when doing this:
Code:
    new String:gString[MyConstant];
    GetArrayString(MyArrayHandle, 5, gString, sizeof(gString));
Here, "MyConstant" is defined in the plugin header outside of any function:
Code:
static const MyConstant = 96;
It throws me this error:
warning 224: indeterminate array size in "sizeof" expression (symbol "")
It only works when I replace MyConstant with a direct expression like 96 in the line, creating the gString. Why would sizeof(gString) be indeterminate, when MyConstant is .. well.. a CONSTANT?
sizeof() is replaced at compile time and it only works with fixed size arrays, why don't you use the variable used to asign the string size :v ?

Code:
    new String:gString[MyConstant];
    GetArrayString(MyArrayHandle, 5, gString, MyConstant);
fakuivan is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 11-20-2015 , 23:14   Re: Dynamic arrays
Reply With Quote #12

Quote:
Originally Posted by fakuivan View Post
sizeof() is replaced at compile time and it only works with fixed size arrays, why don't you use the variable used to asign the string size :v ?

Code:
    new String:gString[MyConstant];
    GetArrayString(MyArrayHandle, 5, gString, MyConstant);
Just curious, did you realize that you are reviving a 6,5 years old thread?
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 11-21-2015 , 23:45   Re: Dynamic arrays
Reply With Quote #13

Quote:
Originally Posted by arne1288 View Post
Just curious, did you realize that you are reviving a 6,5 years old thread?
I noticed that when I entered the scripting section :V
fakuivan 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:02.


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