From 63d04d6639d2f4a36c9586bccb072437c1a7fab0 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:27:54 +0800 Subject: [PATCH] [saco] Implement/match `CPlayerPed::ExitCurrentVehicle()` --- saco/game/playerped.cpp | 21 +++++++++++++++++++++ saco/game/playerped.h | 1 + saco/game/scripting.h | 1 + 3 files changed, 23 insertions(+) diff --git a/saco/game/playerped.cpp b/saco/game/playerped.cpp index e68b3c2..72489d5 100644 --- a/saco/game/playerped.cpp +++ b/saco/game/playerped.cpp @@ -863,6 +863,27 @@ void CPlayerPed::EnterVehicle(int iVehicleID, BOOL bPassenger) } } +//----------------------------------------------------------- +// Graceful vehicle exit. + +void CPlayerPed::ExitCurrentVehicle() +{ + if(!m_pPed) return; + if(!GamePool_Ped_GetAt(m_dwGTAId)) return; + if(IN_VEHICLE(m_pPed)) { + if(GetCurrentVehicleID()) { + int iVehicleID; + VEHICLE_TYPE *pVehicle = GamePool_Vehicle_GetAt(GetCurrentVehicleID()); + if(pVehicle) { + if( pVehicle->entity.nModelIndex != TRAIN_PASSENGER && + pVehicle->entity.nModelIndex != TRAIN_PASSENGER_LOCO ) { + ScriptCommand(&make_actor_leave_car,m_dwGTAId,GetCurrentVehicleID()); + } + } + } + } +} + //----------------------------------------------------------- // Forceful removal diff --git a/saco/game/playerped.h b/saco/game/playerped.h index 332a81d..1078393 100644 --- a/saco/game/playerped.h +++ b/saco/game/playerped.h @@ -68,6 +68,7 @@ public: void PutDirectlyInVehicle(int iVehicleID, int iSeat); void EnterVehicle(int iVehicleID, BOOL bPassenger); + void ExitCurrentVehicle(); void RemoveFromVehicleAndPutAt(float fX, float fY, float fZ); BOOL IsAPassenger(); diff --git a/saco/game/scripting.h b/saco/game/scripting.h index 9c270c4..c3b08e1 100644 --- a/saco/game/scripting.h +++ b/saco/game/scripting.h @@ -79,6 +79,7 @@ const SCRIPT_COMMAND play_sound = { 0x018c, "fffi" }; const SCRIPT_COMMAND remove_actor_from_car_and_put_at = { 0x0362, "ifff" }; const SCRIPT_COMMAND send_actor_to_car_driverseat = { 0x05CB, "iii" }; const SCRIPT_COMMAND send_actor_to_car_passenger = { 0x05CA, "iiii" }; +const SCRIPT_COMMAND make_actor_leave_car = { 0x05CD, "ii" }; const SCRIPT_COMMAND enable_train_traffic = { 0x06d7, "i" };