diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index 82ba250ba5..632b65d98b 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -1641,6 +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); // Ped events m_Events.AddEvent("onPedVehicleEnter", "vehicle, seat, jacked", NULL, false); diff --git a/Server/mods/deathmatch/logic/CMainConfig.cpp b/Server/mods/deathmatch/logic/CMainConfig.cpp index ec5bf9b9d9..0ced79db22 100644 --- a/Server/mods/deathmatch/logic/CMainConfig.cpp +++ b/Server/mods/deathmatch/logic/CMainConfig.cpp @@ -1520,6 +1520,7 @@ const std::vector& CMainConfig::GetIntSettingList() {true, true, 50, 100, 400, "ped_syncer_distance", &g_TickRateSettings.iPedSyncerDistance, &CMainConfig::OnTickRateChange}, {true, true, 50, 130, 400, "unoccupied_vehicle_syncer_distance", &g_TickRateSettings.iUnoccupiedVehicleSyncerDistance, &CMainConfig::OnTickRateChange}, {true, true, 0, 30, 130, "vehicle_contact_sync_radius", &g_TickRateSettings.iVehicleContactSyncRadius, &CMainConfig::OnTickRateChange}, + {true, true, 5, 100, 500, "player_teleport_alert", &g_TickRateSettings.playerTeleportAlert, &CMainConfig::OnTickRateChange}, {false, false, 0, 1, 2, "compact_internal_databases", &m_iCompactInternalDatabases, NULL}, {true, true, 0, 1, 2, "minclientversion_auto_update", &m_iMinClientVersionAutoUpdate, NULL}, {true, true, 0, 0, 100, "server_logic_fps_limit", &m_iServerLogicFpsLimit, NULL}, diff --git a/Server/mods/deathmatch/logic/CPlayer.h b/Server/mods/deathmatch/logic/CPlayer.h index feded36e51..9f65e28c60 100644 --- a/Server/mods/deathmatch/logic/CPlayer.h +++ b/Server/mods/deathmatch/logic/CPlayer.h @@ -265,6 +265,9 @@ class CPlayer final : public CPed, public CClient void SetRedirecting(bool bRedirecting) noexcept { m_bIsRedirecting = bRedirecting; } bool IsRedirecting() const noexcept { return m_bIsRedirecting; } + bool GetTeleported() const noexcept { return m_teleported; } + void SetTeleported(bool state) noexcept { m_teleported = state; } + protected: bool ReadSpecialData(const int iLine) override { return true; } @@ -465,4 +468,6 @@ class CPlayer final : public CPed, public CClient ushort m_usPrevDimension; SString m_strQuitReasonForLog; + + bool m_teleported = false; }; diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index bd58cd8488..fec29886b9 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1274,6 +1274,12 @@ bool CStaticFunctionDefinitions::SetElementPosition(CElement* pElement, const CV assert(pElement); RUN_CHILDREN(SetElementPosition(*iter, vecPosition, bWarp)) + if (IS_PLAYER(pElement)) + { + CPlayer* player = static_cast(pElement); + player->SetTeleported(true); + } + // Update our position for that entity. pElement->SetPosition(vecPosition); diff --git a/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp b/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp index 49496f67b6..8fee7a61fb 100644 --- a/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CPlayerPuresyncPacket.cpp @@ -132,6 +132,17 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream) position.data.vecPosition += vecTempPos; } + CVector playerPosition = pSourcePlayer->GetPosition(); + float playerDistancePosition = DistanceBetweenPoints3D(playerPosition, position.data.vecPosition); + if (playerDistancePosition >= g_TickRateSettings.playerTeleportAlert) { + if (!pSourcePlayer->GetTeleported()) { + CLuaArguments arguments; + pSourcePlayer->CallEvent("onPlayerTeleport", arguments, nullptr); + } + + pSourcePlayer->SetTeleported(false); + } + pSourcePlayer->SetPosition(position.data.vecPosition); // Player rotation diff --git a/Server/mods/deathmatch/mtaserver.conf b/Server/mods/deathmatch/mtaserver.conf index 79a306fc19..1ae1c7a691 100644 --- a/Server/mods/deathmatch/mtaserver.conf +++ b/Server/mods/deathmatch/mtaserver.conf @@ -161,6 +161,10 @@ Available range: 0 to 130. Default - 30 --> 30 + + 100 + 30 + + 100 +