Quote:
Originally Posted by fysiks
All of the variables defined in your RegisterData enum are integers, not strings. Strings themselves are arrays so your enum needs to have the extra dimension for the length of the string (plus 1).
Here is an example of properly storing strings with enums (including examples for using it as a global dataset and as player-specific datasets):
PHP Code:
enum _:MyEnum {
STRING1[32],
STRING2[32]
}
// Save one global set of data
g_GlobalData[MyEnum] = {
"Hello",
"World"
}
server_print("%s", g_GlobalData[STRING1]) // Get and use "Hello"
// Save data per-player
new g_UserData[MAXPLAYERS+1][MyEnum] // Data gets populated as needed
server_print("%s", g_UserData[id][STRING1]) // Get and use STRING1 for specific player
I'm not entirely sure what you're trying to do based on your post. What you claim solves your problems doesn't make much sense to me. I'm quite sure that g_DataKeys[RD_DeadSound][0] would reference just the first character of the string.
|
Exactly, all the integers of my Enumeration are integers but as you can see there are 3 lines defining another 3 integers as with of two values, and as you maybe know enumeration's total are made up by all the dimension sizez, if there aren't any specified automatically 1, and those 3 lines add twice to the enumeration as different values so what i wrote above makes perfect sense as i have to specify which RD_DeadSound i want to use.
As i use it for two different things:
- Creating Dynamic Arrays
- Creating the variable DataKeys
I don't think i would have been much useful to create and use a different enumeration and still i'd have to add that [2] cuz i'm too lazy to add more lines and i don't want to make my code any bigger.
So to exemplify:
We have
PHP Code:
enum AttentionSeek {
I_Want_Attention
You_Lost[2]
}
and a variable
PHP Code:
new glbVariableForStrings[AttentionSeek][] = {
"I Want Attention",
"You Lost 1",
"You Lost 2"
}
Using "AttentionSeek" would give us the number 3 since "You_Lost" has a dimension size of 2, but how do we use it? How do you know which "You_Lost" you are using? To answer this we have to look at something.. if we have a dimension with a size 2 in a Enumeration variable, that extra dimension will be used before using the variable's other dimensions that come after the dimension we choose to add the size of "AttentionSeek", which is the first dimension in the example above, so:
PHP Code:
glbVariableForStrings[You_Lost][0][0]
would give us our first character of "You Lost 1".