Odd error with setting a default value for an Enum
#1

So I have my enum all setup, and the code compiles fine except for errors that pertain to unfinished pieces of the code. I want one (eventually more) of the slots in the

That is the enum that compiles correctly.

However when I add this, every single usage of the variable gPlayerData (which uses this enum for it's structure) gets an array index out of bounds error.

The compiler output (the line numbers don't really matter because if i comment out those lines it just goes to the next 26 calls to the variable)
Reply
#2

Enums are not arrays! They are merely structured defines. If you try to access gPlayerData[REPORT_CHAT], you are in fact accessing gPlayerData[-1] which is well out of bounds.
Reply
#3

I knew I was having a brain burp. Any way to set a default value for that slot then? (ofcourse without looping the entire array)
Reply
#4

Set it under OnPlayerConnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)