Raised This Month: $51 Target: $400
 12% 

How to initialize dynamic array in enum


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DavidLin
Member
Join Date: Jan 2016
Old 01-31-2016 , 15:43   How to initialize dynamic array in enum
Reply With Quote #1

How do I initialize a dynamic array in enum ? If I want to add info in them later on ?

PHP Code:
new Array: zombie_classes;
enum _ZombieSpecifics {
        
zClassId,
        
zNameMAX_NAME_LENGTH ], zDescriptionMAX_DESC_LENGTH ],
        
zModelMAX_MODL_LENGTH ], zClawsMAX_MODL_LENGTH ],
        
zHealthzArmorzSpeedzGravity,
        Array: 
zHit, Array: zMiss, Array: zPain, Array: zDeath <-- How to initialize these ?
}

public 
plugin_precache( ) {
        
zombie_classes ArrayCreateZombieSpecifics );

DavidLin is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-31-2016 , 15:55   Re: How to initialize dynamic array in enum
Reply With Quote #2

Before adding info, you will have to initialize it.
__________________
Arkshine is offline
DavidLin
Member
Join Date: Jan 2016
Old 01-31-2016 , 18:19   Re: How to initialize dynamic array in enum
Reply With Quote #3

Thanks
DavidLin is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 02-15-2020 , 13:27   Re: How to initialize dynamic array in enum
Reply With Quote #4

Wtf? How do you initialize them?

Last edited by redivcram; 02-15-2020 at 13:27.
redivcram is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-15-2020 , 15:07   Re: How to initialize dynamic array in enum
Reply With Quote #5

Quote:
Originally Posted by redivcram View Post
Wtf? How do you initialize them?
The same way you write any data in an array sized by an enum(you don't initialize directly inside the enum) .
__________________
HamletEagle is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 02-15-2020 , 16:45   Re: How to initialize dynamic array in enum
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
The same way you write any data in an array sized by an enum(you don't initialize directly inside the enum) .
So, basically:
PHP Code:
zHit ArrayCreate(n); 
? That's completely 'legal' to do in plugin_init for instance despite it being an enum member?

EDIT: Wait, I'm supposed to use ArrayGet for zombie_classes to get zHit and initialize it that way? I'm getting the hang of Dyn Arrays...

Last edited by redivcram; 02-15-2020 at 16:51.
redivcram is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-16-2020 , 02:54   Re: How to initialize dynamic array in enum
Reply With Quote #7

PHP Code:
enum _:enumName { Array:test }

someFunc:
new 
data[enumName]
data[test] = ArrayCreate(...) 
__________________

Last edited by HamletEagle; 02-16-2020 at 02:55.
HamletEagle is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 02-16-2020 , 11:30   Re: How to initialize dynamic array in enum
Reply With Quote #8

Exactly, thanks!
redivcram is offline
Reply



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 21:59.


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