I've been developing a project which uses the switch()
function, like so:
switch (selectedMenu) {
case 1:
switch (selectedIndex) {
case 0:
invisibility = !invisibility;
break;
case 1:
invincibility = !invincibility;
break;
case 2:
superjump = !superjump;
break;
case 3:
//Option 4
break;
case 4:
//Option 5
break;
}
case 2:
switch (selectedIndex) {
case 0:
//Option 2
break;
case 1:
//Option 2
break;
case 2:
//Option 3
break;
case 3:
//Option 4
break;
case 4:
//Option 5
break;
}
case 3:
switch (selectedIndex) {
case 0:
//Option 2
break;
case 1:
//
break;
case 2:
//Option 3
break;
case 3:
//Option 4
break;
case 4:
//Option 5
break;
}
case 4:
switch (selectedIndex) {
case 0:
//Option 2
break;
case 1:
//Option 2
break;
case 2:
//Option 3
break;
case 3:
//Option 4
break;
case 4:
//Option 5
break;
}
case 5:
switch (selectedIndex) {
case 0:
//Option 2
break;
case 1:
SET_ENTITY_COORDS(pedID, -75.015, -818.215, 326.176);
break;
case 2:
//Option 3
break;
case 3:
//Option 4
break;
case 4:
//Option 5
break;
}
}
I've encountered a bug with my code.
The Problem
In case 5 -> case 1
there's this line: SET_ENTITY_COORDS(pedID, -75.015, -818.215, 326.176);
which should teleport a entity to a certain location. When I use an option in any of the cases above this teleport case it will teleport the entity aswell, even though it's not in the case.
It's very hard to explain, so lets make a drawing:
How do I adjust this so it only enables the function I specified in the case and not everything above it aswell?
(How do I adjust this so it only enables superjump instead of both superjump and teleports the user?)