ici
03-15-2016, 09:42
Hey there fellas,
I have a nested enum data structure and I am trying to alter values by passing an element of the enum as a parameter.
Look at the "set" function and the commented line below so that you get an idea of what exactly I'm trying to achieve.
#include <sourcemod>
enum Info
{
Info1,
Info2
}
enum DataType
{
Type1[Info],
Type2[Info]
}
enum Struct
{
Data[DataType]
}
new g_Data[MAXPLAYERS+1][Struct];
public OnPluginStart()
{
RegConsoleCmd("sm_teststruct", SM_Test);
}
public OnClientPutInServer(client)
{
g_Data[client][Data][Type1][Info1] = 0;
}
public Action:SM_Test(client, args)
{
// set(client, DataType:Type1);
return Plugin_Handled;
}
set(client, DataType:param)
{
g_Data[client][Data][param][Info1] = 10;
g_Data[client][Data][param][Info2] = 20;
}
The problem is that it doesn't work and I'm trying to find a solution.
DataType:Type1 itself is an "array". Is there a way to tell the function which element/block of the DataType enum I want to modify?
I've tried adding brackets / untagging the param:
"error 028: invalid subscript (not an array or too many subscripts): "Type1""
"warning 215: expression has no effect"
"error 001: expected token: ";", but found: "]""
"error 029: invalid expression, assumed zero"
I'd be grateful if somebody can explain to me why this is not working. Also, I don't mind any dirty math solutions. I just want this concept to work.
I have a nested enum data structure and I am trying to alter values by passing an element of the enum as a parameter.
Look at the "set" function and the commented line below so that you get an idea of what exactly I'm trying to achieve.
#include <sourcemod>
enum Info
{
Info1,
Info2
}
enum DataType
{
Type1[Info],
Type2[Info]
}
enum Struct
{
Data[DataType]
}
new g_Data[MAXPLAYERS+1][Struct];
public OnPluginStart()
{
RegConsoleCmd("sm_teststruct", SM_Test);
}
public OnClientPutInServer(client)
{
g_Data[client][Data][Type1][Info1] = 0;
}
public Action:SM_Test(client, args)
{
// set(client, DataType:Type1);
return Plugin_Handled;
}
set(client, DataType:param)
{
g_Data[client][Data][param][Info1] = 10;
g_Data[client][Data][param][Info2] = 20;
}
The problem is that it doesn't work and I'm trying to find a solution.
DataType:Type1 itself is an "array". Is there a way to tell the function which element/block of the DataType enum I want to modify?
I've tried adding brackets / untagging the param:
"error 028: invalid subscript (not an array or too many subscripts): "Type1""
"warning 215: expression has no effect"
"error 001: expected token: ";", but found: "]""
"error 029: invalid expression, assumed zero"
I'd be grateful if somebody can explain to me why this is not working. Also, I don't mind any dirty math solutions. I just want this concept to work.