Reputation: 77
I am new to coding, and need some help with something. I am sorting out cases from a GTA Mod Menu, and trying to add a new one from an SDK. When I try to add it, and add a case for it so it knows what to do, I get the error in the title. I am coding in C++.
int activeLineIndexVeh = 0;
void process_veh_menu()
{
const float lineWidth = 230.0;
const int lineCount = 9;
std::string caption = "Vehicle Options";
static struct {
LPCSTR text;
bool *pState;
bool *pUpdated;
} lines[lineCount] = {
{ "Car Spawner", NULL, NULL },
{ "Random Paint", NULL, NULL },
{ "Fix", NULL, NULL },
{ "Custom Plate", NULL, NULL },
{ "Seat Belt", &featureVehSeatbelt, &featureVehSeatbeltUpdated },
{ "Wrap In Spawned", &featureVehWrapInSpawned, NULL },
{ "Invincible", &featureVehInvincible, &featureVehInvincibleUpdated },
{ "Strong Wheels", &featureVehInvincibleWheels, &featureVehInvincibleWheelsUpdated },
{ "Speed Boost", &featureVehSpeedBoost, NULL }
};
DWORD waitTime = 150;
while (true)
{
// timed menu draw, used for pause after active line switch
DWORD maxTickCount = GetTickCount() + waitTime;
do
{
// draw menu
draw_menu_line(caption, lineWidth, 7.9, 14.0, 4.0, 4.0, false, true);
for (int i = 0; i < lineCount; i++)
if (i != activeLineIndexVeh)
draw_menu_line(line_as_str(lines[i].text, lines[i].pState),
lineWidth, 4.0, 60.0 + i * 22.8, 4.0, 9.0, false, false);
draw_menu_line(line_as_str(lines[activeLineIndexVeh].text, lines[activeLineIndexVeh].pState),
lineWidth + 0.0, 2.0, 60.0 + activeLineIndexVeh * 22.9, 4.0, 7.0, true, false);
update_features();
WAIT(0);
} while (GetTickCount() < maxTickCount);
waitTime = 0;
// process buttons
bool bSelect, bBack, bUp, bDown;
get_button_state(&bSelect, &bBack, &bUp, &bDown, NULL, NULL);
if (bSelect)
{
menu_beep();
// common variables
BOOL bPlayerExists = ENTITY::DOES_ENTITY_EXIST(PLAYER::PLAYER_PED_ID());
Player player = PLAYER::PLAYER_ID();
Ped playerPed = PLAYER::PLAYER_PED_ID();
switch (activeLineIndexVeh)
{
case 0:
if (process_carspawn_menu()) return;
break;
case 1:
if (bPlayerExists)
{
if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0))
{
Vehicle veh = PED::GET_VEHICLE_PED_IS_USING(playerPed);
VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, rand() % 255, rand() % 255, rand() % 255);
if (VEHICLE::GET_IS_VEHICLE_PRIMARY_COLOUR_CUSTOM(veh))
VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(veh, rand() % 255, rand() % 255, rand() % 255);
}
else
{
set_status_text("player isn't in a vehicle");
}
}
break;
case 2:
if (bPlayerExists)
if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0))
VEHICLE::SET_VEHICLE_FIXED(PED::GET_VEHICLE_PED_IS_USING(playerPed));
else
set_status_text("player isn't in a vehicle");
break;
// switchable features
default:
if (lines[activeLineIndexVeh].pState)
*lines[activeLineIndexVeh].pState = !(*lines[activeLineIndexVeh].pState);
if (lines[activeLineIndexVeh].pUpdated)
*lines[activeLineIndexVeh].pUpdated = true;
}
waitTime = 200;
}
else
if (bBack || trainer_switch_pressed())
{
menu_beep();
break;
}
else
if (bUp)
{
menu_beep();
if (activeLineIndexVeh == 0)
activeLineIndexVeh = lineCount;
activeLineIndexVeh--;
waitTime = 150;
}
else
if (bDown)
{
menu_beep();
activeLineIndexVeh++;
if (activeLineIndexVeh == lineCount)
activeLineIndexVeh = 0;
waitTime = 150;
}
case 3: // error starts here
Ped playerPed = PLAYER::PLAYER_PED_ID();
// No point in displaying the keyboard if they aren't in a vehicle
if (!PED::IS_PED_IN_ANY_VEHICLE(playerPed, false)) return;
// Invoke keyboard
GAMEPLAY::DISPLAY_ONSCREEN_KEYBOARD(true, "", "", VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT(PED::GET_VEHICLE_PED_IS_IN(playerPed, false)), "", "", "", 9);
// Wait for the user to edit
while (GAMEPLAY::UPDATE_ONSCREEN_KEYBOARD() == 0) WAIT(0);
// Make sure they didn't exit without confirming their change, and that they're still in a vehicle
if (!GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT() || !PED::IS_PED_IN_ANY_VEHICLE(playerPed, false)) return;
// Update the licenseplate
VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT(PED::GET_VEHICLE_PED_IS_IN(playerPed, false), GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT());
}
}
Upvotes: 1
Views: 4867
Reputation: 169
You are trying to add a case, and you should do so at the correct position. Try adding in case 3 between case 2 and the default case, like so:
switch (activeLineIndexVeh)
{
case 0:
if (process_carspawn_menu()) return;
break;
case 1:
if (bPlayerExists)
{
if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0))
{
Vehicle veh = PED::GET_VEHICLE_PED_IS_USING(playerPed);
VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, rand() % 255,rand() % 255, rand() % 255);
if (VEHICLE::GET_IS_VEHICLE_PRIMARY_COLOUR_CUSTOM(veh))
VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(veh, rand() % 255, rand() % 255, rand() % 255);
}
else
{
set_status_text("player isn't in a vehicle");
}
}
break;
case 2:
if (bPlayerExists)
if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0))
VEHICLE::SET_VEHICLE_FIXED(PED::GET_VEHICLE_PED_IS_USING(playerPed));
else
set_status_text("player isn't in a vehicle");
break;
// switchable features
case 3:
Ped playerPed = PLAYER::PLAYER_PED_ID();
// No point in displaying the keyboard if they aren't in a vehicle
if (!PED::IS_PED_IN_ANY_VEHICLE(playerPed, false)) return;
// Invoke keyboard
GAMEPLAY::DISPLAY_ONSCREEN_KEYBOARD(true, "", "", VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT(PED::GET_VEHICLE_PED_IS_IN(playerPed, false)), "", "", "", 9);
// Wait for the user to edit
while (GAMEPLAY::UPDATE_ONSCREEN_KEYBOARD() == 0) WAIT(0);
// Make sure they didn't exit without confirming their change, and that they're still in a vehicle
if (!GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT() || !PED::IS_PED_IN_ANY_VEHICLE(playerPed, false)) return;
// Update the licenseplate
VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT(PED::GET_VEHICLE_PED_IS_IN(playerPed, false), GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT());
default:
if (lines[activeLineIndexVeh].pState)
*lines[activeLineIndexVeh].pState = !(*lines[activeLineIndexVeh].pState);
if (lines[activeLineIndexVeh].pUpdated)
*lines[activeLineIndexVeh].pUpdated = true;
}
default:
if (lines[activeLineIndexVeh].pState)
*lines[activeLineIndexVeh].pState = !(*lines[activeLineIndexVeh].pState);
if (lines[activeLineIndexVeh].pUpdated)
*lines[activeLineIndexVeh].pUpdated = true;
}
Upvotes: 0
Reputation: 385284
It's what it says. You have a case
label that's not even on the same street as your switch
!
Did case 3:
get lost on its way back from the pub?
Upvotes: 2