AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to initialize dynamic array in enum (https://forums.alliedmods.net/showthread.php?t=278439)

DavidLin 01-31-2016 15:43

How to initialize dynamic array in enum
 
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 );



Arkshine 01-31-2016 15:55

Re: How to initialize dynamic array in enum
 
Before adding info, you will have to initialize it.

DavidLin 01-31-2016 18:19

Re: How to initialize dynamic array in enum
 
Thanks :)

redivcram 02-15-2020 13:27

Re: How to initialize dynamic array in enum
 
Wtf? How do you initialize them?

HamletEagle 02-15-2020 15:07

Re: How to initialize dynamic array in enum
 
Quote:

Originally Posted by redivcram (Post 2683890)
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) .

redivcram 02-15-2020 16:45

Re: How to initialize dynamic array in enum
 
Quote:

Originally Posted by HamletEagle (Post 2683900)
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...

HamletEagle 02-16-2020 02:54

Re: How to initialize dynamic array in enum
 
PHP Code:

enum _:enumName { Array:test }

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


redivcram 02-16-2020 11:30

Re: How to initialize dynamic array in enum
 
Exactly, thanks!


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

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