Raised This Month: $32 Target: $400
 8% 

[ TUT ]Dynamic Array


Post New Thread Reply   
 
Thread Tools Display Modes
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-18-2017 , 10:41   Re: [ TUT ]Dynamic Array
Reply With Quote #31

Yes, you can push pawn arrays into dynamic arrays. The speed won't matter in 99% of cases, so just go with whatever suits your needs.
klippy is online now
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 02-18-2017 , 11:40   Re: [ TUT ]Dynamic Array
Reply With Quote #32

Quote:
Originally Posted by Kotoamatsukami View Post
normal arrays are faster at inserting while dynamic arrays are faster at retrieving
Static arrays as faster for insertion and retrieving data. Do not believe?
Do some benchmarks, or understand how each of them works internally.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 02-18-2017 at 11:51.
addons_zz is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-29-2017 , 10:19   Re: [ TUT ]Dynamic Array
Reply With Quote #33

Hamlet, I think would by helpful explain about get/set array.
__________________








CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-29-2017 , 10:48   Re: [ TUT ]Dynamic Array
Reply With Quote #34

Quote:
Originally Posted by CrazY. View Post
Hamlet, I think would by helpful explain about get/set array.
get/set_array are unrelated with this tutorial.
__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-29-2017 , 19:02   Re: [ TUT ]Dynamic Array
Reply With Quote #35

Ok.
__________________








CrazY. is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 06-29-2017 , 08:38   Re: [ TUT ]Dynamic Array
Reply With Quote #36

I'm trying to use a dynamic array with read_file.

Something like that:

PHP Code:
    new Array:Text ArrayCreate(TextLength);

    while(
Line >= 0)
    {
        
read_file(FileLine--, TextTextLengthtxtlen);
    } 
This one obviously throws an error. Is there any way I can do it?

Last edited by eyal282; 06-29-2017 at 08:38.
eyal282 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-29-2017 , 09:17   Re: [ TUT ]Dynamic Array
Reply With Quote #37

Create a static array (new static_array[size]), put the string into it then push it with ArrayPushString to your Text array. You might be misunderstanding what cellarrays (dynamic arrays) are for.

Last edited by klippy; 06-29-2017 at 09:18.
klippy is online now
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-29-2017 , 09:21   Re: [ TUT ]Dynamic Array
Reply With Quote #38

Also don't use read_file.
__________________
HamletEagle is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 06-29-2017 , 10:26   Re: [ TUT ]Dynamic Array
Reply With Quote #39

Quote:
Originally Posted by KliPPy View Post
Create a static array (new static_array[size]), put the string into it then push it with ArrayPushString to your Text array. You might be misunderstanding what cellarrays (dynamic arrays) are for.
I can't set the length of "static_array" into a variable, which is why I must use a dynamic array.

Quote:
Originally Posted by HamletEagle View Post
Also don't use read_file.
Any better methods I can use for such purpose? Or in general read_file is a bad idea?

Last edited by eyal282; 06-29-2017 at 10:28.
eyal282 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-29-2017 , 21:47   Re: [ TUT ]Dynamic Array
Reply With Quote #40

How you read the file depends entirely on what is in the file and how you are going to use the data. Without context, there is really no suggestion that can be made other than what has already been said.

Any file reading/writing should use fopen(), fgets(), fputs(), fclose() and other similar functions.

I would recommend that you post a thread in Scripting Help explaining this file and how you are wanting to use it. Then, people can give you suggestions for how it might be done properly.
__________________

Last edited by fysiks; 06-29-2017 at 21:50.
fysiks is offline
Reply


Thread Tools
Display Modes

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 15:57.


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