AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Enums & 2D array (https://forums.alliedmods.net/showthread.php?t=299458)

Natsheh 07-15-2017 08:40

Enums & 2D array
 
PHP Code:

enum COLORS_VAR
{
    
COLOR_NAME[32],
    
Float:COLOR_FVALUE[3],
    
Float:COLOR_FRENDERING
}

new const 
COLORS_DATA[][COLORS_VAR] = {
    { 
"Red", {200.0000.0000.0}, 100.0 },
    { 
"Red Orange", {255.0083.0073.0}, 135.0 },
    { 
"Orange", {255.0117.0056.0}, 140.0 }, 
    { 
"Yellow Orange", {255.0174.0066.0}, 120.0 }, 
    { 
"Peach", {255.0207.0171.0}, 140.0 }, 
    { 
"Yellow", {252.0232.0131.0}, 125.0 },
    { 
"Dark Lemon Lime", { 135.0200.0020.0 }, 115.0 },
    { 
"Lemon Yellow", {254.0254.0034.0}, 100.0 },
    { 
"Jungle Green", {059.0176.0143.0}, 125.0 },
    { 
"Yellow Green", {197.0227.0132.0}, 135.0 },
    { 
"Light Sea Green", {050.0175.0070.0}, 130.0 },
    { 
"Green", {000.0150.0000.0}, 100.0 },
    { 
"Aquamarine", {120.0219.0226.0}, 125.0 },
    { 
"Baby Blue", {135.0206.0235.0}, 150.0 },
    { 
"Charged Blue", {055.0015.0220.0}, 125.0 }, 
    { 
"Sky Blue", {128.0218.0235.0}, 090.0 },
    { 
"Blue", {000.0000.0255.0}, 075.0 },
    { 
"Violet", {146.0110.0174.0}, 175.0 },
    { 
"Dogwood Rose", {220.0050.0200.0}, 135.0 },
    { 
"Hot Pink", {255.0105.0180.0}, 150.0 },
    { 
"Magenta", {246.0100.0175.0}, 175.0 },
    { 
"Mahogany", {205.0074.0076.0}, 140.0 },
    { 
"Tan", {250.0167.0108.0}, 140.0 },
    { 
"Light Brown", {234.0126.0093.0}, 140.0 },
    { 
"Brown", {180.0103.0077.0}, 165.0 },
    { 
"Gray", {149.0145.0140.0}, 175.0 },
    { 
"Black", {000.0000.0000.0}, 125.0 },
    { 
"White", {255.0255.0255.0}, 125.0 }
}

public 
call_color_menu()
{
      
display_menu(id"MENU_ID""TITLE"COLORS_DATA[][COLOR_NAME], etc....) // this is line 512....
}

display_menu(id, const menu_name[], const title[], const menu[][], const msize, const colornum[3]="\r", const ikeys=MENU_KEYSmaxperpage=5page=0)
{
      
// code etc....


i get fail to compile....

error log:-

Code:

Error: Invalid expression, assumed zero on line 521

isnt this a 2D array >> COLORS_DATA[][COLOR_NAME] <<

eyal282 07-15-2017 08:42

Re: Enums & 2D array
 
Quote:

Originally Posted by Natsheh (Post 2535470)
PHP Code:

enum COLORS_VAR
{
    
COLOR_NAME[32],
    
Float:COLOR_FVALUE[3],
    
Float:COLOR_FRENDERING
}

new const 
COLORS_DATA[][COLORS_VAR] = {
    { 
"Red", {200.0000.0000.0}, 100.0 },
    { 
"Red Orange", {255.0083.0073.0}, 135.0 },
    { 
"Orange", {255.0117.0056.0}, 140.0 }, 
    { 
"Yellow Orange", {255.0174.0066.0}, 120.0 }, 
    { 
"Peach", {255.0207.0171.0}, 140.0 }, 
    { 
"Yellow", {252.0232.0131.0}, 125.0 },
    { 
"Dark Lemon Lime", { 135.0200.0020.0 }, 115.0 },
    { 
"Lemon Yellow", {254.0254.0034.0}, 100.0 },
    { 
"Jungle Green", {059.0176.0143.0}, 125.0 },
    { 
"Yellow Green", {197.0227.0132.0}, 135.0 },
    { 
"Light Sea Green", {050.0175.0070.0}, 130.0 },
    { 
"Green", {000.0150.0000.0}, 100.0 },
    { 
"Aquamarine", {120.0219.0226.0}, 125.0 },
    { 
"Baby Blue", {135.0206.0235.0}, 150.0 },
    { 
"Charged Blue", {055.0015.0220.0}, 125.0 }, 
    { 
"Sky Blue", {128.0218.0235.0}, 090.0 },
    { 
"Blue", {000.0000.0255.0}, 075.0 },
    { 
"Violet", {146.0110.0174.0}, 175.0 },
    { 
"Dogwood Rose", {220.0050.0200.0}, 135.0 },
    { 
"Hot Pink", {255.0105.0180.0}, 150.0 },
    { 
"Magenta", {246.0100.0175.0}, 175.0 },
    { 
"Mahogany", {205.0074.0076.0}, 140.0 },
    { 
"Tan", {250.0167.0108.0}, 140.0 },
    { 
"Light Brown", {234.0126.0093.0}, 140.0 },
    { 
"Brown", {180.0103.0077.0}, 165.0 },
    { 
"Gray", {149.0145.0140.0}, 175.0 },
    { 
"Black", {000.0000.0000.0}, 125.0 },
    { 
"White", {255.0255.0255.0}, 125.0 }
}

public 
call_color_menu()
{
      
display_menu(id"MENU_ID""TITLE"COLORS_DATA[][COLOR_NAME], etc....) // this is line 512....
}

display_menu(id, const menu_name[], const title[], const menu[][], const msize, const colornum[3]="\r", const ikeys=MENU_KEYSmaxperpage=5page=0)
{
      
// code etc....


i get fail to compile....

error log:-

Code:

Error: Invalid expression, assumed zero on line 521

isnt this a 2D array >> COLORS_DATA[][COLOR_NAME] <<


Unsure about the rest of the code but it doesn't make sense. You are inputting something probably problematic. Try inputting in your call_color_menu COLORS_VAR ( the enumeration )

Natsheh 07-15-2017 09:12

Re: Enums & 2D array
 
im trying to output the color name from ( the 2D array ) and insert it in the display_menu function which require a 2D array ( const menu[][] ) the problem is with my procedure.

klippy 07-15-2017 11:54

Re: Enums & 2D array
 
PHP Code:

COLORS_DATA[][COLOR_NAME

When accessing it, you have to index the first dimension. It can't just be [].

Natsheh 07-15-2017 14:17

Re: Enums & 2D array
 
Quote:

Originally Posted by KliPPy (Post 2535525)
PHP Code:

COLORS_DATA[][COLOR_NAME

When accessing it, you have to index the first dimension. It can't just be [].

Im trying to get all the colors name into 2d array called menu[][] how should i do this?

And it actually can be in some conditions..when u passing it into a 2d array param.

fysiks 07-16-2017 00:22

Re: Enums & 2D array
 
Loop through your array (using the first index) and use copy() to get it into the new array.


All times are GMT -4. The time now is 23:09.

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