View Single Post
LeToucan
New Member
Join Date: Jan 2016
Old 12-24-2018 , 03:19   Re: Enum Structs Available This Holiday Season
Reply With Quote #9

Is there a way we can push enum structs with array fields in them into an ArrayList? For example,

PHP Code:
#include <sourcemod>

enum struct Foo {
    
int x;
    
int y;
    
char strTest[32];
    
int iTest[16];
}

public 
void OnPluginStart() {
    
PrintToChatAll("Start");
    
    
Foo f;
    
strcopy(f.strTestsizeof(f.strTest), "Bar");
    
f.iTest[0] = 123;
    
    
ArrayList arr = new ArrayList();
    
    
PrintToChatAll("f.strTest = \"%s\", f.iTest[0] = %d"f.strTestf.iTest[0]);
    
    
arr.PushArray(fsizeof(f));
    
Foo copy;
    
arr.GetArray(0copysizeof(copy));
    
    
PrintToChatAll("copy.strTest = \"%s\", copy.iTest[0] = %d"copy.strTestcopy.iTest[0]);
    
PrintToChatAll("End");

has the following output

Code:
Start
f.strTest = "Bar", f.iTest[0] = 123
copy.strTest = "", copy.iTest[0] = 0
End
LeToucan is offline