SA-MP Forums Archive
Connecting two enums together - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Connecting two enums together (/showthread.php?tid=674804)



Connecting two enums together - JesusChrysler - 28.04.2020

Hello.
Code:
enum apartments {
	apID,
	apType,
	apName[64],
	apOwner,
	apOwnerName[MAX_PLAYER_NAME],
	apTill,
	Float:apX,
	Float:apY,
	Float:apZ,
	Float:apExitX,
	Float:apExitY,
	Float:apExitZ,
};
new apInfo[MAX_APARTMENTS][apartments];

enum apartmentroom {
	apID, // How do I make this apID connected to the apID in the other enum?
	aprOwner,
	aprOwnerName[MAX_PLAYER_NAME],
	aprCost,
	aprRentFee,
	aprLocked,
	Float:aprX,
	Float:aprZ,
	Float:aprZ,
};
My question is, how do I make 'apID' in the second enum connected to the one in the first enum?


Re: Connecting two enums together - Adamoneoone - 28.04.2020

Probably some kind of loop like
PHP Code:
for(new ii<MAX_APARTMENTSi++) thevaryouhaveforthesecondenum[i][apID] = apInfo[i][apID]; 



Re: Connecting two enums together - Markski - 28.04.2020

The only way to effectivelly do this would be to use apID as the index.

Other way would be to set apID to the id on each array at the same time, and letting each enum have a cache variable to hold the array position of the same apID on the other one and avoid having to loop in order to find each other.

I'm afraid Arrays aren't really made to be related to elements outside of themselves, not without some bodging at least, which will usually come in the shape of caching related indexes or search loops as mentioned.