Skip to content

Commit

Permalink
Add arguments to onPlayerTeleport and fix the false positive caused b…
Browse files Browse the repository at this point in the history
…y setElementInterior using x, y, z parameters.
  • Loading branch information
imfelipedev authored Feb 4, 2025
1 parent d18d7d3 commit b633dcf
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

0 comments on commit b633dcf

Please sign in to comment.