AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to create structure with dynamic memory? (https://forums.alliedmods.net/showthread.php?t=314269)

karaulov 02-11-2019 03:17

How to create structure with dynamic memory?
 
for example, how to create this structure in AMXX:


Code:


struct Struct1
{
  var1;
  var2;
  var3;
 ...
}

struct Struct2
{
  var1;
  List<Struct1>
...
}


List<Struct2> ...


?

Airkish 02-11-2019 04:17

Re: How to create structure with dynamic memory?
 
https://forums.alliedmods.net/showthread.php?t=140103

karaulov 02-11-2019 04:35

Re: How to create structure with dynamic memory?
 
But how to create dynamic array of structures inside another structure ?

as
Code:

struct str1
{
...
}

struct str2
{
...
std::vector<str1> str1list;
...
}


HamletEagle 02-11-2019 05:25

Re: How to create structure with dynamic memory?
 
Use a dynamic array handle in the structure.

Natsheh 02-11-2019 09:24

Re: How to create structure with dynamic memory?
 
PHP Code:

enum struct1 {
 
Var1,
 Array:
array_
}

plugin_init ()
{
   new var [ 
struct1 ]
   var [ 
array_ ] = _:ArrayCreate (); 


karaulov 02-11-2019 22:58

Re: How to create structure with dynamic memory?
 
Quote:

Originally Posted by Natsheh (Post 2639181)
PHP Code:

enum struct1 {
 
Var1,
 Array:
array_
}

plugin_init ()
{
   new var [ 
struct1 ]
   var [ 
array_ ] = _:ArrayCreate (); 



new var [ struct1 ]

This is dynamic array of struct1 ? :)

fysiks 02-11-2019 23:33

Re: How to create structure with dynamic memory?
 
No, 'var' is now a single instance of struct1. You'd have to create another dynamic array using ArrayCreate().


All times are GMT -4. The time now is 09:47.

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