View Single Post
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 10-12-2016 , 12:19   Re: Pick random value from enum
Reply With Quote #4

Quote:
Originally Posted by thecount View Post
For enums of varying or long lengths, you may also add an element at the end of the list to represent the amount of elements before it to help with looping and such. Like:
PHP Code:
enum type{
enum1//0
enum2//1
enum3//2
TOTAL_ENUM 3

For your situation, I think you would just want something like
PHP Code:
view_as<Days>:GetRandomInt(MondaySunday); 
or whatever the syntax is for that. I don't cast variables to different types very often in SourcePawn.
Code:
int day = view_as<Days>(GetRandomInt(Monday, Sunday));
Got 2 same warnings on this line :
warning 213: tag mismatch
warning 213: tag mismatch
__________________
nhnkl159 is offline
Send a message via Skype™ to nhnkl159