Skip to content

Commit

Permalink
Fix and extend new event onPlayerTeleport (PR #4001)
Browse files Browse the repository at this point in the history
  • Loading branch information
imfelipedev authored Feb 4, 2025
1 parent c2b7948 commit 13c35f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ void CGame::AddBuiltInEvents()
m_Events.AddEvent("onPlayerTriggerInvalidEvent", "eventName, isAdded, isRemote", nullptr, false);
m_Events.AddEvent("onPlayerChangesProtectedData", "element, key, value", nullptr, false);
m_Events.AddEvent("onPlayerChangesWorldSpecialProperty", "property, enabled", nullptr, false);
m_Events.AddEvent("onPlayerTeleport", "", nullptr, false);
m_Events.AddEvent("onPlayerTeleport", "previousX, previousY, previousZ, currentX, currentY, currentZ", nullptr, false);

// Ped events
m_Events.AddEvent("onPedVehicleEnter", "vehicle, seat, jacked", NULL, false);
Expand Down
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,12 @@ bool CStaticFunctionDefinitions::SetElementInterior(CElement* pElement, unsigned
BitStream.pBitStream->Write(static_cast<unsigned char>((bSetPosition) ? 1 : 0));
if (bSetPosition)
{
if (IS_PLAYER(pElement))
{
CPlayer* player = static_cast<CPlayer*>(pElement);
player->SetTeleported(true);
}

BitStream.pBitStream->Write(vecPosition.fX);
BitStream.pBitStream->Write(vecPosition.fY);
BitStream.pBitStream->Write(vecPosition.fZ);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream)
if (!pSourcePlayer->GetTeleported())
{
CLuaArguments arguments;
arguments.PushNumber(playerPosition.fX);
arguments.PushNumber(playerPosition.fY);
arguments.PushNumber(playerPosition.fZ);
arguments.PushNumber(position.data.vecPosition.fX);
arguments.PushNumber(position.data.vecPosition.fY);
arguments.PushNumber(position.data.vecPosition.fZ);
pSourcePlayer->CallEvent("onPlayerTeleport", arguments, nullptr);
}

Expand Down

1 comment on commit 13c35f8

@derxgbb
Copy link

@derxgbb derxgbb commented on 13c35f8 Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the six params :)

But you forgot to fix the issue where the player can just get into a vehicle and teleport with that.

Please sign in to comment.