From d2bd9599c29f9d77a14a7381a2046585f701d4c6 Mon Sep 17 00:00:00 2001 From: Ritabrata Das Date: Mon, 17 Feb 2025 20:52:38 +0530 Subject: Add midair refueling plugin --- plugins/smoke_on_damage/Plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/smoke_on_damage') diff --git a/plugins/smoke_on_damage/Plugin.py b/plugins/smoke_on_damage/Plugin.py index 08c184b..12effc8 100644 --- a/plugins/smoke_on_damage/Plugin.py +++ b/plugins/smoke_on_damage/Plugin.py @@ -1,4 +1,4 @@ -"""TThis plugin will cause the aircraft to emit smoke if it's health is below a certain threshold. +"""This 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. 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 -- cgit v1.2.3 From 412d75439934201968a701abc043abc63f802dba Mon Sep 17 00:00:00 2001 From: Ritabrata Das Date: Wed, 19 Feb 2025 21:40:54 +0530 Subject: Fix critical bug in smoke plugin --- lib/plugin_manager.py | 7 +++++-- plugins/over_g_damage.py | 2 +- plugins/refuel.py | 4 ++++ plugins/smoke_on_damage/Plugin.py | 4 +++- proxy.py | 3 --- 5 files changed, 13 insertions(+), 7 deletions(-) (limited to 'plugins/smoke_on_damage') diff --git a/lib/plugin_manager.py b/lib/plugin_manager.py index ae4cf0b..07e28e6 100644 --- a/lib/plugin_manager.py +++ b/lib/plugin_manager.py @@ -62,8 +62,11 @@ class PluginManager: if hook_name in self.hooks: for callback in self.hooks[hook_name]: keep = callback(data, *args, **kwargs) - if keep == False: - keep_orignal = False + if type(keep) == bool: + if keep == False: + keep_orignal = False + else: + warning(f"Return value of {callback} is not a boolean") return keep_orignal def trigger_command(self, command:str, player, full_message:str, message_to_client:list, message_to_server:list): diff --git a/plugins/over_g_damage.py b/plugins/over_g_damage.py index 50c1b21..89e295b 100644 --- a/plugins/over_g_damage.py +++ b/plugins/over_g_damage.py @@ -5,7 +5,7 @@ from config import G_LIM import time # CONFIG -ENABLED = True # Enable or disable the plugin +ENABLED = False # Enable or disable the plugin INTERVAL = 0.3 # Interval of second before G Limit check is enforced class Plugin: diff --git a/plugins/refuel.py b/plugins/refuel.py index e171953..bd12a10 100644 --- a/plugins/refuel.py +++ b/plugins/refuel.py @@ -38,6 +38,8 @@ class Plugin: def on_flight_data(self, data, player, message_to_client, message_to_server): decode = FSNETCMD_AIRPLANESTATE(data) + print(player.username, decode.position) + print(refuelers, refueling) if player in refueling: for player in refuelers: refueling[player] = [decode.fuel, decode.position] @@ -57,6 +59,7 @@ class Plugin: if decode.fuel-100 > 0 and refuelers[player][2]: a = FSNETCMD_AIRCMD.set_command(player.aircraft.id, "INITFUEL", f"{decode.fuel-5}kg", True) message_to_client.append(a) + return True @staticmethod def in_range(refueler_cord:list, refueled_cord:list): @@ -64,6 +67,7 @@ class Plugin: # refueler plane, ysf sends cords in list[x, y, z] # implement this later # for now we just use distance formula in a 3d space + print(refueler_cord, refueled_cord) dist = math.sqrt((refueler_cord[0]-refueled_cord[0])**2 + (refueler_cord[1]-refueled_cord[1])**2 + (refueler_cord[2]-refueled_cord[2])**2) print(dist) if dist < REFUEL_RADIUS: diff --git a/plugins/smoke_on_damage/Plugin.py b/plugins/smoke_on_damage/Plugin.py index 12effc8..ed7fcf7 100644 --- a/plugins/smoke_on_damage/Plugin.py +++ b/plugins/smoke_on_damage/Plugin.py @@ -38,7 +38,9 @@ class Plugin: message_to_client.append(FSNETCMD_AIRCMD.set_afterburner(player.aircraft.id, False, True)) - return False + return False + else: + return True def on_weapon_config(self, data, player, message_to_client, message_to_server): if ENABLED: diff --git a/proxy.py b/proxy.py index 37af393..9a60c0c 100644 --- a/proxy.py +++ b/proxy.py @@ -117,9 +117,6 @@ async def handle_client(client_reader, client_writer): try: - if packet_type == "FSNETCMD_AIRCMD": - print(FSNETCMD_AIRCMD.decode(packet)) - if packet_type == "FSNETCMD_LOGON": # keep_message = plugin_manager.triggar_hook('on_login', packet, player, message_to_client, message_to_server) # if not keep_message: -- cgit v1.2.3