Raised This Month: $ Target: $400
 0% 

[TUT] Enumerations (enum)


Post New Thread Reply   
 
Thread Tools Display Modes
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 10-27-2010 , 21:06   Re: [TUT] Enumerations (enum)
Reply With Quote #31

Thanks, this has been very interesting.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 10-28-2010 , 23:05   Re: [TUT] Enumerations (enum)
Reply With Quote #32

I try to create a enum structs to store player data like this , but fail
Code:
enum DATA {
    DATA1[33], 
    DATA2[33], 
};
//...
new g_PlayerData[33][DATA];
//...
public myfunction(id) {
    //...
    g_PlayerData[id][DATA1[iWeapon]]++;
}
get the error:
Error: Invalid subscript (not an array or too many subscripts)

can someone correct me ?
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-28-2010 , 23:26   Re: [TUT] Enumerations (enum)
Reply With Quote #33

Code:
g_PlayerData[id][DATA1][iWeapon]++;
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
l4ulwtlln
Member
Join Date: Aug 2007
Old 11-11-2010 , 22:44   Re: [TUT] Enumerations (enum)
Reply With Quote #34

lets say i have
Code:
new const MAX_M = 10; new const MAX_D = 5; new g_multi[33][MAX_M][36]; new g_doors[33][MAX_M][MAX_D];
where g_multi will store some string and g_doors will store some integer

so i assumed this:
Code:
enum _:Somecells {     __multi[MAX_M][36],     __doors[MAX_D] } new g_Somedata[33][Somecells];
but doing so gives me a 'error 001: expected token: "}", but found "["'for __multi[MAX_M][36] . how do i do this properly?
l4ulwtlln is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-11-2010 , 23:22   Re: [TUT] Enumerations (enum)
Reply With Quote #35

Code:
new g_multi[33][MAX_M][36]; new g_doors[33][MAX_M][MAX_D];
They are different for '36' and 'MAX_D', so that's all you need in the enum.
Code:
enum _:Somecells {     __multi[36],     __doors[MAX_D] } new g_Somedata[33][MAX_M][Somecells]
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
l4ulwtlln
Member
Join Date: Aug 2007
Old 11-11-2010 , 23:35   Re: [TUT] Enumerations (enum)
Reply With Quote #36

kind of wrote it wrong. what if they werent the same? for example
Code:
new g_multi[33][MAX_M][36]; new g_doors[33][MAX_D][3];

im asking because i want to use it in ArrayCreate(Somecells)
l4ulwtlln is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 06-08-2011 , 05:00   Re: [TUT] Enumerations (enum)
Reply With Quote #37

Is it possible to create an array of Array? For instance

PHP Code:
new Array:g_aArray[5]
for (new 
0sizeof g_aArrayi++)
    
g_aArray[i] = ArrayCreate(1); 
The problem I'm having with this is that when I try something like:

PHP Code:
ArraySize(Array:g_aArray[0]) 
I'm forced to cast g_aArray as an array. Are there any solutions or should I just make the entire thing a cellarray? The reason it's predefined like this is because I know how many arrays I want to create, but not the size of the items in those arrays. I'm doing this for a list of command variations, so I know the number of commands, but not the number of variations that will end up being used.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 06-08-2011 at 05:06.
Tirant is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-08-2011 , 05:10   Re: [TUT] Enumerations (enum)
Reply With Quote #38

Use it with an enum.

Code:
enum MyEnum {     Array:blabla_1,     Array:blabla_2,     etc.. }; new Array:g_aArray[ MyEnum ];

then :

Code:
for( new i = 0; MyEnum:i < MyEnum; i++ ) {     g_aArray[ MyEnum:i ] = ArrayCreate( 1 );   } [...] ArraySize( g_aArray[ blabla_1 ] )
__________________
Arkshine is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-08-2011 , 05:12   Re: [TUT] Enumerations (enum)
Reply With Quote #39

Your current method is fine.

Are these 5 arrays specific for something?
Like could you name what they are?

If so, you could do this:

Code:
enum Arrays {     Array:Array1,     Array:Array2,     Array:Array3,     Array:Array4,     Array:Array5 }; new Array:g_aArrays[Arrays]; for (new Arrays:i; i < Arrays; i++)     g_aArray[i] = ArrayCreate(1);   // .. new iSize = ArraySize(g_aArray[Array1]);
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 06-08-2011 , 05:23   Re: [TUT] Enumerations (enum)
Reply With Quote #40

Oh, okay, I understand. I don't know why I didn't think of that. I've been going a lot of java lately, so the pawn enums are something a bit different (more useful in my opinion). I actually managed to do it without creating an enum type though. Handling it like

PHP Code:
enum _:Arrays
{
    Array:
Array1,
    Array:
Array2,
    Array:
Array3,
    Array:
Array4,
    Array:
Array5
}; 
Worked just fine for me, and saves me casting in the initialization and assignment loops.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant 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 01:54.


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