Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arguments to onPlayerTeleport and fix the false positive caused by setElementInterior using x, y, z parameters. #4001

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading