AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with "enum" (https://forums.alliedmods.net/showthread.php?t=139943)

reinert 10-07-2010 05:57

help with "enum"
 
Why the hell names doesn't show up on my menu ???

here is the code:

PHP Code:

new TYPE:mode[64];
enum TYPE
{
    
NONE 0,
    NEW = 
1,
    
OLD 2
}

client_connect(id){
     
TYPE:mode[id] = NONE;
}

new 
mode1[256]
formatex(mode1255"You are [ %s ]"TYPE:mode[id])
menu_additem(menumode1"1"0); 


Ir show me like

You are [ ]



where is the problem ??

Arkshine 10-07-2010 06:14

Re: help with "enum"
 
The problem is you don't now what you are going.

- Can you tell me where you retrieve the name?
- The array should have 2 dimensions. [ id ][ name ]
- What is the point to tag an array of string with such enum?

wrecked_ 10-07-2010 19:36

Re: help with "enum"
 
The code is unnecessarily tagging the mode variable with TYPE: all over. You also cannot format the names inside an enumeration as a string.

Example similar to what I assume you were trying to do:
Code:
enum Type {     NONE = 0,     NEW = 1,     OLD = 2 } new const TypeNames[Type][5] = {     "None",     "New",     "Old" } new Type:Mode[33] public client_connect( id ) {     Mode[id] = NONE } func() {     new str[64]     formatex( str, 63, "You are [ %s ]", TypeNames[Mode[id]] )         // ... }

reinert 10-08-2010 05:26

Re: help with "enum"
 
Thank you!


All times are GMT -4. The time now is 10:16.

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