This site has been archived and made available for preservation purposes. No edits can be made.

Results 1 to 8 of 8

Thread: enumerated constants

  1. #1

    enumerated constants

    hi

    i wanted to know how to use enumerated constants. all i know about is:
    const tagname: //"tagname:" is optional
    {
    const_1 = 0,
    const_2,
    const_3
    }
    the subsequent constants are automatically assigned as preconstant+1 (const_1 = 0, const_2 = 1, const_3 = 2) but i want to use other increment values. for exapmle
    enum tagname (<<=1)
    {
    const_1 = 1,
    const_2,
    const_3
    }
    the subsequent constants are now assigned as preconstant shifted 1 bit left. (const_1 = 0b001, const_2 = 0b010, const_3 = 0b100).

    anyone know how to manage that since the "enum" was removed?

  2. #2
    Administrator
    Join Date
    Jun 2011
    Location
    Germany
    Posts
    1,057
    Blog Entries
    5
    I haven't worked with the new version of PAWN myself, but a quick look at the new language guide reveals that it should be still possible to override the default increment value of 1:

    https://www.compuphase.com/pawn/Pawn_Language_Guide.pdf
    (page 101)

    I don't know the syntax though. I'd assume it's similar to that of the old PAWN version with enum.

  3. #3
    i have already read that guide but there is still no example for that case :/

  4. #4
    PHP Code:
    const E_RANDOM_ENUM: (<<=1// I think you need the colon there ^.^
    {
        
    const_1 1,
        
    const_2,
        
    const_3
    };

    new
        
    g_enumDataE_RANDOM_ENUM  ]
    ;

    //Usage
    g_enumDataconst_1 ] += 5;
    g_enumDataconst_2 ] += 6;
    g_enumDataconst_3 ] += 7
    Can you elaborate?
    A gaming community ran by one person, with servers made by individuals (in this case, me, myself)
    I plan to look for a trusted person who will help me create a decent roleplay/deathmatch server on Vault-TEC,
    PM me if you're interested

  5. #5
    Nope it gives me
    error 020: invalid symbol name ""
    Line:
    const E_RANDOM_ENUM: (<<=1)

    //Edit:
    @Lorenc_: For those arrays (often used in sa:mp scripting like PlayerInfo) you can use tags. for example
    new PlayerInfo[20][
    .name[20],
    Float:.pos[3],
    bool:.connected];
    Last edited by NeoPhoenix; 04-08-2012 at 05:20 PM.

  6. #6
    enum/constants are more neat, that piece looks so ugly lol.
    A gaming community ran by one person, with servers made by individuals (in this case, me, myself)
    I plan to look for a trusted person who will help me create a decent roleplay/deathmatch server on Vault-TEC,
    PM me if you're interested

  7. #7
    im not sure if you can use that constants in a way like in sa:mp. enumerators have been removed and those constants are not like enums in an older version of pawn

  8. #8
    Well to be honest, enumerators in the new version seem like a bunch of constants to me in an array.
    The syntax would probably be different for your understanding.
    Have you downloaded the latest PAWN version?


    I just come here to view whether there has been any progress or not, and review the wonderful progress that Recycler and the development team has made.
    My sincere thanks goes to them and to others who value my contributions the community, not to mention the ones that solely contribute.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •