Raised This Month: $51 Target: $400
 12% 

Enum struct, how do we access the struct property as parameter?


Post New Thread Reply   
 
Thread Tools Display Modes
LinLinLin
Senior Member
Join Date: Sep 2021
Old 12-08-2022 , 15:47   Re: Enum struct, how do we access the struct property as parameter?
Reply With Quote #11

no error and print four time in game.
PHP Code:
enum chancetype
{
    
chance_a 0,
    
chance_b,
    
chance_c,
    
chance_total
};

enum struct Eplayer
{
    
float a;
    
float chance[view_as<chancetype>(chance_total)];
}

public 
void OnClientPutInServer(int client)
{
    if( 
IsFakeClient(client) )
        return;

    
Eplayer a;
    for(
int i 0<= sizeofa.chance ); i++)
    {
        
PrintToChat(client,"sizeof : %d",i);
    }

and this is in wiki.

To allow implicit conversions of enums back to integers (that is, so functions expecting a value of type 'int' accepts it as one instead of generating a warning), the enum must either be anonymous (unnamed) or must start with a lowercase character.

so if you want to use an enum as an array size, don't set it's name or just use lowercas character in start.
LinLinLin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode