Raised This Month: $62 Target: $400
 15% 

How to create structure with dynamic memory?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
karaulov
Member
Join Date: Jul 2018
Old 02-11-2019 , 03:17   How to create structure with dynamic memory?
Reply With Quote #1

for example, how to create this structure in AMXX:


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

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


List<Struct2> ...

?
karaulov is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 02-11-2019 , 04:17   Re: How to create structure with dynamic memory?
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=140103
__________________
Airkish is offline
karaulov
Member
Join Date: Jul 2018
Old 02-11-2019 , 04:35   Re: How to create structure with dynamic memory?
Reply With Quote #3

But how to create dynamic array of structures inside another structure ?

as
Code:
struct str1
{
...
}

struct str2
{
...
std::vector<str1> str1list;
...
}
karaulov is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-11-2019 , 05:25   Re: How to create structure with dynamic memory?
Reply With Quote #4

Use a dynamic array handle in the structure.
__________________
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
Old 02-11-2019 , 09:24   Re: How to create structure with dynamic memory?
Reply With Quote #5

PHP Code:
enum struct1 {
 
Var1,
 Array:
array_
}

plugin_init ()
{
   new var [ 
struct1 ]
   var [ 
array_ ] = _:ArrayCreate (); 
__________________
@Jailbreak MOD [Alot of features + API] 100% done !
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Last edited by Natsheh; 02-11-2019 at 09:24.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
karaulov
Member
Join Date: Jul 2018
Old 02-11-2019 , 22:58   Re: How to create structure with dynamic memory?
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
PHP Code:
enum struct1 {
 
Var1,
 Array:
array_
}

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

new var [ struct1 ]

This is dynamic array of struct1 ?

Last edited by karaulov; 02-11-2019 at 22:58.
karaulov is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2019 , 23:33   Re: How to create structure with dynamic memory?
Reply With Quote #7

No, 'var' is now a single instance of struct1. You'd have to create another dynamic array using ArrayCreate().
__________________
fysiks is offline
Old 02-12-2019, 01:18
Natsheh
This message has been deleted by Natsheh.
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:41.


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