Raised This Month: $ Target: $400
 0% 

[help] Arrays in Enums?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
elfenlied ftw
Member
Join Date: Aug 2012
Old 12-14-2014 , 22:06   [help] Arrays in Enums?
Reply With Quote #1

When I compile my sourcemod plugin, I get a bunch of errors stating:
Quote:
error 047: array sizes do not match, or destination array is too small
Originally, I had a bunch of separate arrays but I decided to try and fit them in to an enum "struct" to look cleaner. I got this idea a while back while looking at the "RTD" sm plugin code.
Code:
#define MAX_RTD_EFFECTS 35
#define STRING_PERK_MAXLEN 100
enum g_ePerks
{
	String:g_strPerkName[STRING_PERK_MAXLEN],
	String:g_strPerkDesc[STRING_PERK_MAXLEN],
	String:g_strPerkKey[STRING_PERK_MAXLEN],
	g_ePerkType:g_nPerkType,
	bool:g_bPerkDisabled,	
	Float:g_flPerkTime
};
new g_nPerks[MAX_RTD_EFFECTS][g_ePerks];
My enum:
Code:
enum g_ePlayerBoxData
{
	Float:g_flPos1[3],
	Float:g_flPos2[3],
	Float:g_flMins[3],
	Float:g_flMaxs[3],
	Float:g_flOrig[3],
	bool:g_bCalc
};
new g_nPlayerBoxData[MAXPLAYERS+1][g_ePlayerBoxData];
Here is a line that triggers the compile error:
Code:
GetEntPropVector(client, Prop_Send, "m_vecOrigin", g_nPlayerBoxData[client][g_flPos2] );
Now, everything was working fine before I switched to the enum. Before I had arrays like:
Code:
new Float:g_flClientPos2[MAXPLAYERS+1][3];

Is there any way of making this work that I'm not seeing? Or am I going to have to settle with a bunch of separate arrays like I had done originally?

Thanks.

Last edited by elfenlied ftw; 12-14-2014 at 22:17.
elfenlied ftw is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 12-15-2014 , 06:54   Re: [help] Arrays in Enums?
Reply With Quote #2

I guess, it's same as this https://forums.alliedmods.net/showthread.php?t=249597
KissLick is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 12-15-2014 , 14:50   Re: [help] Arrays in Enums?
Reply With Quote #3

vectors does not work properly into enum array, you need to use a buffer and transfer cell by cell into your structure.
Mathias. is offline
elfenlied ftw
Member
Join Date: Aug 2012
Old 12-15-2014 , 14:51   Re: [help] Arrays in Enums?
Reply With Quote #4

Okay, thanks for the info.
elfenlied ftw 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 18:53.


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