SA-MP Forums Archive
Odd error with setting a default value for an Enum - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Odd error with setting a default value for an Enum (/showthread.php?tid=361624)



Odd error with setting a default value for an Enum - dowster - 21.07.2012

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)



Re: Odd error with setting a default value for an Enum - Vince - 21.07.2012

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.


Re: Odd error with setting a default value for an Enum - dowster - 21.07.2012

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)


Re: Odd error with setting a default value for an Enum - SuperViper - 21.07.2012

Set it under OnPlayerConnect.