Raised This Month: $ Target: $400
 0% 

Multi Dynamic Arrays - Possible?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SYNC1223
Junior Member
Join Date: Sep 2013
Old 09-22-2013 , 10:22   Multi Dynamic Arrays - Possible?
Reply With Quote #1

Hello guys
i need some advice how to do this in Dynamic Arrays.
PHP Code:
new const ball[3][][] = { 

        {
"num1","num2","num3","num4"}, 
        {
"num1","num2","num3","num4"},
        {
"num1","num2","num3","num4"


Thanks for help!

Last edited by SYNC1223; 09-22-2013 at 10:25.
SYNC1223 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-22-2013 , 11:09   Multi Dynamic Arrays - Possible?
Reply With Quote #2

Look at celltries.
__________________
Black Rose is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-22-2013 , 11:23   Re: Multi Dynamic Arrays - Possible?
Reply With Quote #3

Or dynamic array with pseudo struct (enum), if each item contains 4 strings.

PHP Code:
enum mMiscDatas
{
    
m_szString1[32],
    
m_szString2[32],
    
m_szString3[32],
    
m_szString4[32]
}

new Array:
g_aArray;

public 
plugin_init()
{
    
g_aArray ArrayCreate(mMiscDatas);

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-22-2013 , 14:56   Re: Multi Dynamic Arrays - Possible?
Reply With Quote #4

I used a dynamic array of dynamic arrays for Polymorph. The primary dynamic array simply held the pointers to the other dynamic arrays.

So, it really depends on what you are doing.
__________________

Last edited by fysiks; 09-22-2013 at 14:57.
fysiks is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-22-2013 , 16:00   Re: Multi Dynamic Arrays - Possible?
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
Or dynamic array with pseudo struct (enum), if each item contains 4 strings.

PHP Code:
enum mMiscDatas
{
    
m_szString1[32],
    
m_szString2[32],
    
m_szString3[32],
    
m_szString4[32]
}

new Array:
g_aArray;

public 
plugin_init()
{
    
g_aArray ArrayCreate(mMiscDatas);

I'm sorry. I can't understand how you would retrieve those 4 values. Could you possible make a quick example? Unless it's all stored in one array and you have to split it, then I don't want an example.
__________________

Last edited by Black Rose; 09-22-2013 at 16:00.
Black Rose is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-22-2013 , 17:01   Re: Multi Dynamic Arrays - Possible?
Reply With Quote #6

PHP Code:
    new _array[mMiscDatas];
    
ArrayGetArray(g_aArrayitem_array);
    
client_print(0print_chat"%s %s %s %s"_array[m_szString1], _array[m_szString2], _array[m_szString3], _array[m_szString4]); 
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-22-2013 at 17:03.
ConnorMcLeod is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-22-2013 , 17:25   Re: Multi Dynamic Arrays - Possible?
Reply With Quote #7

Now I realize that enums are just one array and a collection of memory offsets.
Code:
server_print("%d, %d, %d, %d", m_szString1, m_szString2, m_szString3, m_szString4);
Code:
0, 32, 64, 96
__________________

Last edited by Black Rose; 09-22-2013 at 18:18.
Black Rose is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-23-2013 , 01:46   Re: Multi Dynamic Arrays - Possible?
Reply With Quote #8

What can be usefull here is that sizeof(_array[m_szString2]) returns 32
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 18:48.


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