diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index 5b977047aa..4d8fea8556 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -127,7 +127,7 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI m_pTaskManager = NULL; m_pOccupiedVehicle = NULL; m_pOccupyingVehicle = NULL; - // m_uiOccupyingSeat = 0; + m_uiOccupyingSeat = 0; m_uiOccupiedVehicleSeat = 0xFF; m_bHealthLocked = false; m_bDontChangeRadio = false; @@ -1464,7 +1464,7 @@ void CClientPed::WarpIntoVehicle(CClientVehicle* pVehicle, unsigned int uiSeat) CClientVehicle* pPrevVehicle = GetRealOccupiedVehicle(); // Eventually remove us from a previous vehicle RemoveFromVehicle(); - // m_uiOccupyingSeat = uiSeat; + m_uiOccupyingSeat = uiSeat; m_bForceGettingIn = false; m_bForceGettingOut = false; m_ucLeavingDoor = 0xFF; @@ -7279,4 +7279,15 @@ void CClientPed::RunSwimTask() const inWaterTask->SetAsPedTask(m_pPlayerPed, TASK_PRIORITY_EVENT_RESPONSE_NONTEMP, true); } - \ No newline at end of file + +bool CClientPed::IsEnteringToVehicle() +{ + int inOutState = GetVehicleInOutState(); + return inOutState == VEHICLE_INOUT_GETTING_IN || inOutState == VEHICLE_INOUT_JACKING; +} + +bool CClientPed::IsExitingFromVehicle() +{ + int inOutState = GetVehicleInOutState(); + return inOutState == VEHICLE_INOUT_GETTING_OUT || inOutState == VEHICLE_INOUT_GETTING_JACKED; +} diff --git a/Client/mods/deathmatch/logic/CClientPed.h b/Client/mods/deathmatch/logic/CClientPed.h index e4153ee5b7..5f04c01e25 100644 --- a/Client/mods/deathmatch/logic/CClientPed.h +++ b/Client/mods/deathmatch/logic/CClientPed.h @@ -254,6 +254,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule CClientVehicle* GetOccupyingVehicle() noexcept { return m_pOccupyingVehicle; }; const CClientVehicle* GetOccupyingVehicle() const noexcept { return m_pOccupyingVehicle; }; + unsigned int GetOccupyingVehicleSeat() const noexcept { return m_uiOccupyingSeat; }; + CClientVehicle* GetRealOccupiedVehicle(); CClientVehicle* GetClosestEnterableVehicle(bool bGetPositionFromClosestDoor, bool bCheckDriverDoor, bool bCheckPassengerDoors, bool bCheckStreamedOutVehicles, unsigned int* uiClosestDoor = NULL, CVector* pClosestDoorPosition = NULL, @@ -267,6 +269,9 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule void WarpIntoVehicle(CClientVehicle* pVehicle, unsigned int uiSeat = 0); CClientVehicle* RemoveFromVehicle(bool bIgnoreIfGettingOut = false); + bool IsEnteringToVehicle(); + bool IsExitingFromVehicle(); + bool IsVisible(); void SetVisible(bool bVisible); bool GetUsesCollision(); @@ -644,7 +649,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule unsigned long m_ulLastOnScreenTime; CClientVehiclePtr m_pOccupiedVehicle; CClientVehiclePtr m_pOccupyingVehicle; - // unsigned int m_uiOccupyingSeat; + unsigned int m_uiOccupyingSeat; unsigned int m_uiOccupiedVehicleSeat; bool m_bForceGettingIn; bool m_bForceGettingOut; diff --git a/Client/mods/deathmatch/logic/CClientVehicle.cpp b/Client/mods/deathmatch/logic/CClientVehicle.cpp index e47c40e2e5..12bccab460 100644 --- a/Client/mods/deathmatch/logic/CClientVehicle.cpp +++ b/Client/mods/deathmatch/logic/CClientVehicle.cpp @@ -4139,8 +4139,7 @@ void CClientVehicle::SetPedOccupyingVehicle(CClientPed* pClientPed, CClientVehic // Ped vars pClientPed->m_pOccupyingVehicle = pVehicle; - // if ( uiSeat >= 0 && uiSeat < 8 ) - // pClientPed->m_uiOccupyingSeat = uiSeat; + pClientPed->m_uiOccupyingSeat = uiSeat; if (ucDoor != 0xFF) pVehicle->AllowDoorRatioSetting(ucDoor, false); @@ -4266,7 +4265,7 @@ void CClientVehicle::UnpairPedAndVehicle(CClientPed* pClientPed, CClientVehicle* { INFO(("UnpairPedAndVehicle: pClientPed:%s from m_pOccupyingVehicle:0x%08x", GetPlayerName(pClientPed).c_str(), pVehicle)); pClientPed->m_pOccupyingVehicle = NULL; - // pClientPed->m_uiOccupyingSeat = 0xFF; + pClientPed->m_uiOccupyingSeat = NULL; } } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 68b707d14b..fc5627ad1f 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -104,6 +104,11 @@ void CLuaPedDefs::LoadFunctions() {"getPedTotalAmmo", GetPedTotalAmmo}, {"getPedOccupiedVehicle", GetPedOccupiedVehicle}, {"getPedOccupiedVehicleSeat", GetPedOccupiedVehicleSeat}, + {"isPedEnteringToVehicle", ArgumentParser}, + {"isPedExitingFromVehicle", ArgumentParser}, + {"getPedVehicleEnteringTo", ArgumentParser}, + {"getPedVehicleEnteringToSeat", ArgumentParser}, + {"getPedBonePosition", GetPedBonePosition}, {"getPedClothes", GetPedClothes}, {"getPedMoveState", GetPedMoveState}, @@ -155,6 +160,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "getMoveState", "getPedMoveState"); lua_classfunction(luaVM, "getOccupiedVehicle", "getPedOccupiedVehicle"); lua_classfunction(luaVM, "getOccupiedVehicleSeat", "getPedOccupiedVehicleSeat"); + lua_classfunction(luaVM, "getVehicleEnteringTo", "getPedVehicleEnteringTo"); + lua_classfunction(luaVM, "getVehicleEnteringToSeat", "getPedVehicleEnteringToSeat"); lua_classfunction(luaVM, "getOxygenLevel", "getPedOxygenLevel"); lua_classfunction(luaVM, "getStat", "getPedStat"); lua_classfunction(luaVM, "getTarget", "getPedTarget"); @@ -213,6 +220,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "setExitVehicle", "setPedExitVehicle"); lua_classfunction(luaVM, "setBleeding", "setPedBleeding"); lua_classfunction(luaVM, "playVoiceLine", "playPedVoiceLine"); + lua_classfunction(luaVM, "isEnteringToVehicle", "isPedEnteringToVehicle"); + lua_classfunction(luaVM, "isExitingFromVehicle", "isPedExitingFromVehicle"); lua_classvariable(luaVM, "vehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle); lua_classvariable(luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat"); @@ -232,6 +241,10 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "ducked", NULL, "isPedDucked"); lua_classvariable(luaVM, "headless", "setPedHeadless", "isPedHeadless"); lua_classvariable(luaVM, "inVehicle", NULL, "isPedInVehicle"); + lua_classvariable(luaVM, "enteringToVehicle", NULL, "isPedEnteringToVehicle"); + lua_classvariable(luaVM, "exitingFromVehicle", NULL, "isPedExitingFromVehicle"); + lua_classvariable(luaVM, "vehicleEnteringTo", NULL, "getPedVehicleEnteringTo"); + lua_classvariable(luaVM, "vehicleEnteringToSeat", NULL, "getPedVehicleEnteringToSeat"); lua_classvariable(luaVM, "onFire", "setPedOnFire", "isPedOnFire"); lua_classvariable(luaVM, "onGround", NULL, "isPedOnGround"); lua_classvariable(luaVM, "dead", NULL, "isPedDead"); @@ -2560,3 +2573,23 @@ void CLuaPedDefs::PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional< ped->Say(speechContextId, probability.value_or(1.0f)); } + +bool CLuaPedDefs::IsPedEnteringToVehicle(CClientPed* const ped) noexcept +{ + return ped->IsEnteringToVehicle(); +} + +bool CLuaPedDefs::IsPedExitingFromVehicle(CClientPed* const ped) noexcept +{ + return ped->IsExitingFromVehicle(); +} + +CClientVehicle* CLuaPedDefs::GetPedVehicleEnteringTo(CClientPed* const ped) +{ + return ped->GetOccupyingVehicle(); +} + +int CLuaPedDefs::GetPedVehicleEnteringToSeat(CClientPed* const ped) +{ + return ped->GetOccupyingVehicleSeat(); +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 20ec1aa590..a7d1b1d0e1 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -120,4 +120,8 @@ class CLuaPedDefs : public CLuaDefs static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully); static void PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional probability); + static bool IsPedEnteringToVehicle(CClientPed* const ped) noexcept; + static bool IsPedExitingFromVehicle(CClientPed* const ped) noexcept; + static CClientVehicle* GetPedVehicleEnteringTo(CClientPed* const ped); + static int GetPedVehicleEnteringToSeat(CClientPed* const ped); }; diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 1d10a05916..b3756455dd 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -48,6 +48,8 @@ void CLuaPedDefs::LoadFunctions() {"getPedOccupiedVehicle", GetPedOccupiedVehicle}, {"getPedOccupiedVehicleSeat", GetPedOccupiedVehicleSeat}, {"isPedInVehicle", IsPedInVehicle}, + {"isPedEnteringToVehicle", ArgumentParser}, + {"isPedExitingFromVehicle", ArgumentParser}, {"isPedReloadingWeapon", ArgumentParser}, // Ped set functions @@ -120,6 +122,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "isHeadless", "isPedHeadless"); lua_classfunction(luaVM, "isWearingJetpack", "isPedWearingJetpack"); // introduced in 1.5.5-9.13846 lua_classfunction(luaVM, "isReloadingWeapon", "isPedReloadingWeapon"); + lua_classfunction(luaVM, "isEnteringToVehicle", "isPedEnteringToVehicle"); + lua_classfunction(luaVM, "isExitingFromVehicle", "isPedExitingFromVehicle"); lua_classfunction(luaVM, "getArmor", "getPedArmor"); lua_classfunction(luaVM, "getFightingStyle", "getPedFightingStyle"); @@ -153,6 +157,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "setWearingJetpack", "setPedWearingJetpack"); // introduced in 1.5.5-9.13846 lua_classvariable(luaVM, "inVehicle", NULL, "isPedInVehicle"); + lua_classvariable(luaVM, "enteringToVehicle", NULL, "isPedEnteringToVehicle"); + lua_classvariable(luaVM, "exitingFromVehicle", NULL, "isPedExitingFromVehicle"); lua_classvariable(luaVM, "ducked", NULL, "isPedDucked"); lua_classvariable(luaVM, "inWater", NULL, "isPedInWater"); lua_classvariable(luaVM, "onGround", NULL, "isPedOnGround"); @@ -1555,3 +1561,13 @@ int CLuaPedDefs::TakeAllWeapons(lua_State* luaVM) lua_pushboolean(luaVM, false); return 1; } + +bool CLuaPedDefs::IsPedEnteringToVehicle(CPed* const ped) noexcept +{ + return ped->GetVehicleAction() == CPed::VEHICLEACTION_ENTERING; +} + +bool CLuaPedDefs::IsPedExitingFromVehicle(CPed* const ped) noexcept +{ + return ped->GetVehicleAction() == CPed::VEHICLEACTION_EXITING; +} diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 407a052e21..2409d50566 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -51,6 +51,8 @@ class CLuaPedDefs : public CLuaDefs LUA_DECLARE(GetPedOccupiedVehicle); LUA_DECLARE(GetPedOccupiedVehicleSeat); LUA_DECLARE(IsPedInVehicle); + static bool IsPedEnteringToVehicle(CPed* const ped) noexcept; + static bool IsPedExitingFromVehicle(CPed* const ped) noexcept; LUA_DECLARE(GetPedAmmoInClip); LUA_DECLARE(GetPedTotalAmmo); static bool IsPedReloadingWeapon(CPed* const ped) noexcept;