AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Something about dynamic arrays (https://forums.alliedmods.net/showthread.php?t=347223)

abdelwahab 04-12-2024 22:29

Something about dynamic arrays
 
Hello,
so here is the thing, i know what it does but i don't understand how it does it if someone can explain it would be much appreciated, Thanks!
PHP Code:

new Array:GlobalArray;
public 
plugin_init() {
    new 
string[][] =
    {
        
"String 1",
        
"String 2",
        
"String 3",
        
"String 4"
    
}
    new Array:
StringHolder ArrayCreate(321);
    for(new 
i=0sizeof(string); i++)
        
ArrayPushString(StringHolderstring[i]);
    
// we pass an array :/
    
ArrayPushCell(GlobalArrayStringHolder);

    
arraytest()
}
public 
plugin_precache() GlobalArray =  ArrayCreate(11);
arraytest(){
    new  Array:
AnotherArray;AnotherArray ArrayGetCell(GlobalArray0);
    if(
AnotherArray != Invalid_Array){
        new 
szString[32];
        for(new 
0ArraySize(AnotherArray); i++){
            
ArrayGetString(AnotherArrayiszStringcharsmax(szString));
            
server_print(szString);
        }
    }



bigdaddy424 04-12-2024 23:31

Re: Something about dynamic arrays
 
Basic 2D arrays have a set size that cannot change, while dynamic arrays can adjust their size during runtime. Basic 2D arrays are best when you know the size beforehand and it won't change. Dynamic arrays are more flexible for changing sizes as needed.
Natives are explained and given examples
https://forums.alliedmods.net/showthread.php?t=249602
https://www.amxmodx.org/api/cellarray/__functions

abdelwahab 04-13-2024 00:25

Re: Something about dynamic arrays
 
Its not that thing i was talking about these lines
PHP Code:

ArrayPushCell(GlobalArrayStringHolder);
new Array:
AnotherArray;AnotherArray ArrayGetCell(GlobalArray0);
ArrayGetString(AnotherArrayiszStringcharsmax(szString)); 

what does it mean when i did push the array

abdelwahab 04-13-2024 00:41

Re: Something about dynamic arrays
 
I've read the tutorial long time ago and i know how to make dynamic arrays and use them, the thing that is confusing me when i push an dyn array that has strings into an dyn array ( 1 cell ) what happens,
and when i want to know the strings i put into that dyn array
i use this
PHP Code:

new Array:AnotherArray;AnotherArray ArrayGetCell(GlobalArray0); 

Srrry i'm not good with explaining
usage example ?
for example i created skins menu with ini file and there is 6 type each skin has 1...5 skins
[SKIN 1]
Skins = myskin1, ....ect
[SKIN 2]...
when u select u get random skins from the total skins.
what i don't really understand is that how that works cause i know how to do it i've seen the way in zp50_zombie_class system

abdelwahab 04-13-2024 02:44

Re: Something about dynamic arrays
 
Nvm i understood it.

HamletEagle 04-13-2024 06:57

Re: Something about dynamic arrays
 
Quote:

Originally Posted by abdelwahab (Post 2820890)
Nvm i understood it.

Please do not delete your posts. Also, if you figure out the solution, post it so that others can benefit from it in the future. It is selfish to come to an open source community, ask questions and then delete the topic or not post the solution.

abdelwahab 04-13-2024 10:29

Re: Something about dynamic arrays
 
Well yea, thats the thing i think my post is useless and if u can delete it i just didn't know that u can pass an dyn array into dyn array

Bugsy 04-13-2024 10:32

Re: Something about dynamic arrays
 
Other people may be in the same boat as you, and find your post. Problem solved.

fysiks 04-13-2024 16:50

Re: Something about dynamic arrays
 
I suspect that the important thing to know about dynamic arrays is that the array handle is just a reference to the actually data and it can be stored like you would do with any other variable. This is why, you can store many of these array handles into a dynamic array making a pseudo-2D dynamic array.

abdelwahab 04-14-2024 03:15

Re: Something about dynamic arrays
 
Thanks, that's exactly what i needed to hear!


All times are GMT -4. The time now is 21:53.

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