AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] 2d dynamic array (https://forums.alliedmods.net/showthread.php?t=308622)

CrazY. 06-27-2018 16:28

[ H3LP ] 2d dynamic array
 
Hello, is there any way to pass 2d array through native?

Example:
Code:
new const g_szClassWeapons[][] = { "Weapon 1", "Weapon 2", "Weapon 3" }; public test() {     native_test(g_szClassWeapons, sizeof g_szClassWeapons); } ... public _native_test(iPluginId, iParamsCount) {     new szWeapon[][];     new iArraySize = get_param(2);     get_array(1, szWeapon, iArraySize);     for (new i = 0; i < iArraySize; i++)         server_print("Weapon[%d] = %s", i, szWeapon[i]); }

Ghosted 06-27-2018 16:46

Re: [ H3LP ] 2d dynamic array
 
What is this? code is splitted into 2 sections where first is another plugin and second is another? if not then this wont work.

PluginID & NumParams are parameters for register_native [Style = 0]

PS: new szWeapon[][]; << huh? (this is uninitalized, how compiler must set excact size of dimensions for that variable)

CrazY. 06-27-2018 16:50

Re: [ H3LP ] 2d dynamic array
 
It's just a example.

Natsheh 06-27-2018 17:38

Re: [ H3LP ] 2d dynamic array
 
Quote:

Originally Posted by CrazY. (Post 2599603)
It's just a example.

Use dynamic arrays and return the array id using a native.

When you want to retrieve something simply call arraygetstring depends on array type.

CrazY. 06-27-2018 18:28

Re: [ H3LP ] 2d dynamic array
 
I've solved this with bit-fields, not with array precisely.


All times are GMT -4. The time now is 12:24.

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