Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "packets/CConsoleEchoPacket.h"
#include "packets/CChatClearPacket.h"
#include "packets/CElementRPCPacket.h"
#include "packets/CVehicleInOutPacket.h"
#include "version.h"
#include <net/rpc_enums.h>

Expand Down Expand Up @@ -4350,6 +4351,28 @@ bool CStaticFunctionDefinitions::RemovePedFromVehicle(CElement* pElement)
auto ucOccupiedSeat = static_cast<unsigned char>(pPed->GetOccupiedVehicleSeat());
if (pVehicle)
{
unsigned int uiVehicleAction = pPed->GetVehicleAction();

// Handle mid-enter/exit states
if (uiVehicleAction == CPed::VEHICLEACTION_ENTERING || uiVehicleAction == CPed::VEHICLEACTION_JACKING)
{
pVehicle->SetOccupant(nullptr, ucOccupiedSeat);
pPed->SetOccupiedVehicle(nullptr, 0);
pPed->SetVehicleAction(CPed::VEHICLEACTION_NONE);

if (uiVehicleAction == CPed::VEHICLEACTION_JACKING)
pPed->SetJackingVehicle(nullptr);

// Clean up client handshake
if (IS_PLAYER(pPed))
{
CVehicleInOutPacket Reply(pPed->GetID(), pVehicle->GetID(), ucOccupiedSeat, CGame::VEHICLE_NOTIFY_IN_ABORT_RETURN);
m_pPlayerManager->BroadcastOnlyJoined(Reply);
}

return true;
}

CLuaArguments Arguments;
Arguments.PushElement(pVehicle); // vehicle
Arguments.PushNumber(ucOccupiedSeat); // seat
Expand All @@ -4369,8 +4392,8 @@ bool CStaticFunctionDefinitions::RemovePedFromVehicle(CElement* pElement)
pVehicle->CallEvent("onVehicleExit", Arguments2);

// Remove him from the vehicle
pVehicle->SetOccupant(NULL, ucOccupiedSeat);
pPed->SetOccupiedVehicle(NULL, 0);
pVehicle->SetOccupant(nullptr, ucOccupiedSeat);
pPed->SetOccupiedVehicle(nullptr, 0);
pPed->SetVehicleAction(CPed::VEHICLEACTION_NONE);

// Tell the players
Expand Down