From ef8f6310745a434317ba0f17875e1cb7db59e5a9 Mon Sep 17 00:00:00 2001 From: Skipper Date: Thu, 13 Feb 2025 22:14:31 +0000 Subject: Updated Aircraft.py Updated to do the prev_life/life swap in the aircraft add_state function. --- lib/Aircraft.py | 4 ++++ plugins/smoke_on_damage/Plugin.py | 3 ++- proxy.py | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Aircraft.py b/lib/Aircraft.py index dd2bbed..5e6e24d 100644 --- a/lib/Aircraft.py +++ b/lib/Aircraft.py @@ -76,7 +76,11 @@ class Aircraft: if packet.player_id != self.id: return None + if self.life == -1: + self.life=packet.life + self.prev_life = self.life + self.life = packet.life self.set_position(packet.position) self.set_attitude(packet.atti) diff --git a/plugins/smoke_on_damage/Plugin.py b/plugins/smoke_on_damage/Plugin.py index b3b4ccd..e6c57e2 100644 --- a/plugins/smoke_on_damage/Plugin.py +++ b/plugins/smoke_on_damage/Plugin.py @@ -1,5 +1,6 @@ """TThis plugin will cause the aircraft to emit smoke if it's health is below a certain threshold. -It is also an example of a plugin as a folder/module.""" +It is also an example of a plugin as a folder/module. +This can be used as a basis for more complex plugins that may need multiple files.""" from lib.PacketManager.packets import FSNETCMD_AIRCMD, FSNETCMD_AIRPLANESTATE, FSNETCMD_TEXTMESSAGE from logging import debug from config import SMOKE_LIFE, SMOKE_PLANE diff --git a/proxy.py b/proxy.py index 58d241f..3ca6394 100644 --- a/proxy.py +++ b/proxy.py @@ -137,15 +137,11 @@ async def handle_client(client_reader, client_writer): if not keep_message: data = None - if player.aircraft.life == -1: #Uninitialised - player.aircraft.prev_life = player.aircraft.life - elif player.aircraft.prev_life < player.aircraft.life and player.aircraft.prev_life != -1 and not player.aircraft.just_repaired: cheatingMsg = YSchat.message(f"{HEALTH_HACK_MESSAGE} by {player.username}") warning(f"Health hack detected for {player.username}, Connected from {player.ip}") message_to_server.append(cheatingMsg) - player.aircraft.prev_life = player.aircraft.life player.aircraft.just_repaired = False elif packet_type == "FSNETCMD_UNJOIN": -- cgit v1.2.3