Skip to content

Commit

Permalink
Hide 'copilot' help text when exiting
Browse files Browse the repository at this point in the history
So unnecessary, but a nice detail
  • Loading branch information
yugecin committed Jan 17, 2021
1 parent 975fff8 commit f1830d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions fly-plugin/basdonfly_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ cell AMX_NATIVE_CALL B_OnPlayerStateChange(AMX *amx, cell *params)
const int playerid = PARAM(1);
const int newstate = PARAM(2), oldstate = PARAM(3);

copilot_on_player_state_change(playerid, oldstate, newstate);
missions_on_player_state_change(playerid, oldstate, newstate);
panel_on_player_state_change(playerid, oldstate, newstate);
veh_on_player_state_change(playerid, oldstate, newstate);
Expand Down
17 changes: 16 additions & 1 deletion fly-plugin/copilot.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ struct COPILOT_ENTER_EXIT_OFFSET {
char dz;
};

#define COPILOT_HELPTEXT_SHOW_DURATION 5000

static struct COPILOT_ENTER_EXIT_OFFSET copilot_enter_exit_offset[MAX_PLAYERS];
static int copilot_helptext_showtime[MAX_PLAYERS];

static
void copilot_handle_onfoot_fire(int playerid, struct vec3 playerpos)
Expand Down Expand Up @@ -57,10 +60,11 @@ void copilot_handle_onfoot_fire(int playerid, struct vec3 playerpos)
if (GetPlayerInVehicleSeat(found_vehicle, seat) == INVALID_PLAYER_ID) {
natives_PutPlayerInVehicle(playerid, found_vehicle, seat);
if (seat > number_passengerseats) {
GameTextForPlayer(playerid, 5000, 3,
GameTextForPlayer(playerid, COPILOT_HELPTEXT_SHOW_DURATION, 3,
"~w~entered as co-pilot~n~"
"press ~b~~k~~VEHICLE_BRAKE~~w~ to exit~n~~n~"
"do not press ~r~~k~~VEHICLE_ENTER_EXIT~~w~~n~or your game will crash");
copilot_helptext_showtime[playerid] = time_timestamp();
}
return;
}
Expand Down Expand Up @@ -93,3 +97,14 @@ void copilot_handler_passenger_brake(int playerid, int vehicleid)
SetPlayerPosRaw(playerid, &pos);
}
}

static
void copilot_on_player_state_change(int playerid, int from, int to)
{
/*Hide help text when player exits and it's still shown (so unnecessary but a nice detail).*/
if (from == PLAYER_STATE_PASSENGER &&
time_timestamp() - copilot_helptext_showtime[playerid] < COPILOT_HELPTEXT_SHOW_DURATION)
{
HideGameTextForPlayer(playerid);
}
}

0 comments on commit f1830d5

Please sign in to comment.