Looping through enum with switch
#1

Hi guys! Just a bit confused on how i would do this..

I am trying to make a payday system where it will loop through all of the ranks.. and pay a different amount depending on the rank... However this is my first time looping through an enum and im not quite sure about how to do this.

Here is the code that I've thought of:
Код:
for(new p = 0; fData:p < fData; p++) {
	switch(pData[i][FactionRank]) {
		case p: {
			FactionPayout += Faction_Data[factionid][fData:p];
			format(str, sizeof(str), "Employement Pay: %i", Faction_Data[factionid][fData:p]);
			break;
		}
	        default: break;
        }
}
But with this, I am getting an error on the case line:
Код:
error 008: must be a constant expression; assumed zero
Please help me out, I really appreciate it, will give rep!
Reply


Messages In This Thread
Looping through enum with switch - by MotherDucker - 09.09.2017, 15:38
Re: Looping through enum with switch - by Paulice - 09.09.2017, 19:34
Re: Looping through enum with switch - by n00blek - 09.09.2017, 19:45
Re: Looping through enum with switch - by Misiur - 09.09.2017, 20:29
Re: Looping through enum with switch - by OneDay - 09.09.2017, 21:25
Re: Looping through enum with switch - by MotherDucker - 10.09.2017, 13:00
Re: Looping through enum with switch - by MotherDucker - 12.09.2017, 12:47
Re: Looping through enum with switch - by JasonRiggs - 12.09.2017, 12:48
Re: Looping through enum with switch - by OneDay - 12.09.2017, 13:11

Forum Jump:


Users browsing this thread: 2 Guest(s)