Skip to content

Commit 0fc4abb

Browse files
committed
Implement getPedOccupiedVehicleEnteringTo & fixes
1 parent be3959b commit 0fc4abb

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

Client/mods/deathmatch/logic/luadefs/CLuaCompatibilityDefs.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ void CLuaCompatibilityDefs::LoadFunctions()
7171
{"getControlState", ArgumentParserWarn<false, CLuaPedDefs::GetPedControlState>},
7272
{"setCameraShakeLevel", ArgumentParserWarn<false, CLuaCameraDefs::SetCameraDrunkLevel>},
7373
{"getCameraShakeLevel", ArgumentParserWarn<false, CLuaCameraDefs::GetCameraDrunkLevel>},
74-
{"isPedEnteringToVehicle", ArgumentParserWarn<false, CLuaPedDefs::IsPedEnteringToVehicle>},
75-
{"isPedExitingFromVehicle", ArgumentParserWarn<false, CLuaPedDefs::IsPedExitingFromVehicle>},
7674
};
7775

7876
// Add functions

Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ void CLuaPedDefs::LoadFunctions()
104104
{"getPedTotalAmmo", GetPedTotalAmmo},
105105
{"getPedOccupiedVehicle", GetPedOccupiedVehicle},
106106
{"getPedOccupiedVehicleSeat", GetPedOccupiedVehicleSeat},
107+
{"isPedEnteringToVehicle", ArgumentParser<IsPedEnteringToVehicle>},
108+
{"isPedExitingFromVehicle", ArgumentParser<IsPedExitingFromVehicle>},
109+
{"getPedOccupiedVehicleEnteringTo", ArgumentParser<GetPedOccupiedVehicleEnteringTo>},
110+
107111
{"getPedBonePosition", GetPedBonePosition},
108112
{"getPedClothes", GetPedClothes},
109113
{"getPedMoveState", GetPedMoveState},
@@ -155,6 +159,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
155159
lua_classfunction(luaVM, "getMoveState", "getPedMoveState");
156160
lua_classfunction(luaVM, "getOccupiedVehicle", "getPedOccupiedVehicle");
157161
lua_classfunction(luaVM, "getOccupiedVehicleSeat", "getPedOccupiedVehicleSeat");
162+
lua_classfunction(luaVM, "getOccupiedVehicleEnteringTo", "getPedOccupiedVehicleEnteringTo");
158163
lua_classfunction(luaVM, "getOxygenLevel", "getPedOxygenLevel");
159164
lua_classfunction(luaVM, "getStat", "getPedStat");
160165
lua_classfunction(luaVM, "getTarget", "getPedTarget");
@@ -234,6 +239,9 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
234239
lua_classvariable(luaVM, "ducked", NULL, "isPedDucked");
235240
lua_classvariable(luaVM, "headless", "setPedHeadless", "isPedHeadless");
236241
lua_classvariable(luaVM, "inVehicle", NULL, "isPedInVehicle");
242+
lua_classvariable(luaVM, "enteringToVehicle", NULL, "isPedEnteringToVehicle");
243+
lua_classvariable(luaVM, "exitingFromVehicle", NULL, "isPedExitingFromVehicle");
244+
lua_classvariable(luaVM, "occupiedVehicleEnteringTo", NULL, "getPedOccupiedVehicleEnteringTo");
237245
lua_classvariable(luaVM, "onFire", "setPedOnFire", "isPedOnFire");
238246
lua_classvariable(luaVM, "onGround", NULL, "isPedOnGround");
239247
lua_classvariable(luaVM, "dead", NULL, "isPedDead");
@@ -2563,12 +2571,17 @@ void CLuaPedDefs::PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<
25632571
ped->Say(speechContextId, probability.value_or(1.0f));
25642572
}
25652573

2566-
bool CLuaPedDefs::IsPedEnteringToVehicle(CClientPed* const ped)
2574+
bool CLuaPedDefs::IsPedEnteringToVehicle(CClientPed* const ped) noexcept
25672575
{
25682576
return ped->IsEnteringToVehicle();
25692577
}
25702578

2571-
bool CLuaPedDefs::IsPedExitingFromVehicle(CClientPed* const ped)
2579+
bool CLuaPedDefs::IsPedExitingFromVehicle(CClientPed* const ped) noexcept
25722580
{
25732581
return ped->IsExitingFromVehicle();
25742582
}
2583+
2584+
CClientVehicle* CLuaPedDefs::GetPedOccupiedVehicleEnteringTo(CClientPed* const ped)
2585+
{
2586+
return ped->GetOccupyingVehicle();
2587+
}

Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class CLuaPedDefs : public CLuaDefs
120120
static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully);
121121

122122
static void PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<float> probability);
123-
static bool IsPedEnteringToVehicle(CClientPed* const ped);
124-
static bool IsPedExitingFromVehicle(CClientPed* const ped);
123+
static bool IsPedEnteringToVehicle(CClientPed* const ped) noexcept;
124+
static bool IsPedExitingFromVehicle(CClientPed* const ped) noexcept;
125+
static CClientVehicle* GetPedOccupiedVehicleEnteringTo(CClientPed* const ped);
125126
};

Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ void CLuaPedDefs::LoadFunctions()
4848
{"getPedOccupiedVehicle", GetPedOccupiedVehicle},
4949
{"getPedOccupiedVehicleSeat", GetPedOccupiedVehicleSeat},
5050
{"isPedInVehicle", IsPedInVehicle},
51-
{"isPedReloadingWeapon", ArgumentParser<IsPedReloadingWeapon>},
5251
{"isPedEnteringToVehicle", ArgumentParser<IsPedEnteringToVehicle>},
5352
{"isPedExitingFromVehicle", ArgumentParser<IsPedExitingFromVehicle>},
53+
{"isPedReloadingWeapon", ArgumentParser<IsPedReloadingWeapon>},
5454

5555
// Ped set functions
5656
{"setPedArmor", ArgumentParserWarn<false, SetPedArmor>},
@@ -157,6 +157,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
157157
lua_classfunction(luaVM, "setWearingJetpack", "setPedWearingJetpack"); // introduced in 1.5.5-9.13846
158158

159159
lua_classvariable(luaVM, "inVehicle", NULL, "isPedInVehicle");
160+
lua_classvariable(luaVM, "enteringToVehicle", NULL, "isPedEnteringToVehicle");
161+
lua_classvariable(luaVM, "exitingFromVehicle", NULL, "isPedExitingFromVehicle");
160162
lua_classvariable(luaVM, "ducked", NULL, "isPedDucked");
161163
lua_classvariable(luaVM, "inWater", NULL, "isPedInWater");
162164
lua_classvariable(luaVM, "onGround", NULL, "isPedOnGround");

Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ class CLuaPedDefs : public CLuaDefs
8080
LUA_DECLARE(SetPedHeadless);
8181
LUA_DECLARE(SetPedFrozen);
8282
static bool ReloadPedWeapon(lua_State* vm, CPed* const ped) noexcept;
83-
bool IsPedEnteringToVehicle(CPed* const ped) noexcept;
84-
bool IsPedExitingFromVehicle(CPed* const ped) noexcept;
83+
static bool IsPedEnteringToVehicle(CPed* const ped) noexcept;
84+
static bool IsPedExitingFromVehicle(CPed* const ped) noexcept;
8585
};

0 commit comments

Comments
 (0)