AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Enum struct, how do we access the struct property as parameter? (https://forums.alliedmods.net/showthread.php?t=340663)

LinLinLin 12-08-2022 15:47

Re: Enum struct, how do we access the struct property as parameter?
 
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.


All times are GMT -4. The time now is 04:37.

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