SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 28/04/2020, 09:37 AM   #1
JesusChrysler
Big Clucker
 
Join Date: Nov 2014
Posts: 54
Reputation: 23
Default Connecting two enums together

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?
JesusChrysler is offline   Reply With Quote
Old 28/04/2020, 10:08 AM   #2
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 488
Reputation: 37
Default Re: Connecting two enums together

Probably some kind of loop like
PHP Code:
for(new ii<MAX_APARTMENTSi++) thevaryouhaveforthesecondenum[i][apID] = apInfo[i][apID]; 
Adamoneoone is offline   Reply With Quote
Old 28/04/2020, 11:45 AM   #3
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 133
Reputation: 59
Default Re: Connecting two enums together

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.
Markski is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why we use var for enums? Arxalan Scripting Help 2 31/01/2015 02:15 PM
Connecting 2 enums Strummer Scripting Help 0 22/07/2014 08:57 PM
Help with enums! PaulDinam Scripting Help 4 23/06/2013 05:51 PM
Enums Ehab1911 Scripting Help 7 30/09/2011 10:39 AM
Component IDs from file aren't loading into the enums, but save from the enums. Jack_Leslie Help Archive 7 19/08/2011 02:00 PM


All times are GMT. The time now is 04:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.