From 481602127e08ac322c3a5369560a441c7e19ed19 Mon Sep 17 00:00:00 2001 From: sk7z-xyz Date: Fri, 3 Apr 2026 01:08:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?WebMap=E9=80=A3=E6=90=BA=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.lua | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/script.lua b/script.lua index fad13db..8d2655b 100644 --- a/script.lua +++ b/script.lua @@ -15,6 +15,9 @@ g_timer=0 g_remind_interval=3600 g_ui_reset_requested=false g_flag_radius=300 +--WebMapAddon +g_has_webmap=false +g_webMapBindings={} g_ammo_supply_buttons={ MG_K={42,50,'mg'}, @@ -614,6 +617,19 @@ function onCreate(is_world_create) registerPopup('game_time', -0.9, -0.9) setSettingsToStandby() + + --WebMapAddonDetectCheck + count = server.getAddonCount() + for addon_index=0,count-1 do + local ADDON_DATA =server.getAddonData(addon_index) + local addon_name = string.lower(ADDON_DATA.name) + if addon_name == 'webmap' then + g_has_webmap=true + announce('Webmap addon detected!',0) + break + end + end + end function onDestroy() @@ -792,6 +808,10 @@ function onPlayerSit_(peer_id, vehicle_id, seat_name) local vehicle=registerVehicle(vehicle_id) if vehicle and vehicle.alive then player.vehicle_id=vehicle_id + --WebMapAddon + if g_has_webmap then + bindVehicleTeamToWebMap(vehicle_id, player.team) + end end g_player_status_dirty=true end @@ -881,6 +901,21 @@ function join(peer_id, team, force) local vehicle=registerVehicle(vehicle_id) if vehicle and vehicle.alive then player.vehicle_id=vehicle_id + --webmapAddon + if g_has_webmap then + bindVehicleTeamToWebMap(vehicle_id, team) + end + end + else + --webmapAddon + --not sit + --Currently, it does not work because player.vehicle_id = -1 is set. + local vehicle=registerVehicle(player.vehicle_id) + if vehicle and vehicle.alive then + player.vehicle_id=vehicle_id + if g_has_webmap then + bindVehicleTeamToWebMap(vehicle_id, team) + end end end @@ -931,6 +966,13 @@ function shuffle(team_count, exec_peer_id) local team=g_default_teams[1+(i-1)%team_count] g_players[peer_id].team=team announce('You joined to '..team..'.', peer_id) + --webmapAddon + if g_has_webmap then + local vehicle=findVehicle(g_players[peer_id].vehicle_id) + if vehicle and vehicle.alive then + bindVehicleTeamToWebMap(g_players[peer_id].vehicle_id, team) + end + end table.remove(peer_ids, pick) end @@ -1090,6 +1132,11 @@ function unregisterVehicle(vehicle_id) if not vehicle then return end table.remove(g_vehicles,index) + --WebMapAddon + if g_has_webmap then + g_webMapBindings[vehicle_id]=nil + end + for peer_id,player in pairs(g_players) do if player.vehicle_id==vehicle_id then player.vehicle_id=-1 @@ -1189,6 +1236,34 @@ function updateVehicle(vehicle) g_player_status_dirty=true end +--WebMapAddon(Called from the Join/Shuffle/Sit event.) +function bindVehicleTeamToWebMap(vehicle_id, team) + + if g_has_webmap==false then + return + end + + if not vehicle_id or vehicle_id<0 then + return + end + + local TEAM_COLOR_MAP = { + red = "RED", + blue = "BLUE", + pink = "PINK", + ylw = "YELLOW", + standby = "YELLOW" + } + team = string.lower(team) + local color = TEAM_COLOR_MAP[team] + if not color then return end + + if g_webMapBindings[vehicle_id]==color then return end + g_webMapBindings[vehicle_id]=color + --?wm ct(WebMap_ChangeTeam)command + local cmd = '?wm ct ' .. vehicle_id .. ' ' .. color + server.command(cmd) +end -- System Functions -- function updateTeamStatus() From de1a3ae710909ae26ae6a92e6ddf128dc7f3b372 Mon Sep 17 00:00:00 2001 From: sk7z-xyz Date: Fri, 3 Apr 2026 01:20:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?WebMapAddon=E4=B8=80=E9=83=A8=E6=96=87?= =?UTF-8?q?=E5=AD=97=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script.lua b/script.lua index 8d2655b..5e5cb92 100644 --- a/script.lua +++ b/script.lua @@ -901,13 +901,13 @@ function join(peer_id, team, force) local vehicle=registerVehicle(vehicle_id) if vehicle and vehicle.alive then player.vehicle_id=vehicle_id - --webmapAddon + --WebMapAddon if g_has_webmap then bindVehicleTeamToWebMap(vehicle_id, team) end end else - --webmapAddon + --WebMapAddon --not sit --Currently, it does not work because player.vehicle_id = -1 is set. local vehicle=registerVehicle(player.vehicle_id) @@ -966,7 +966,7 @@ function shuffle(team_count, exec_peer_id) local team=g_default_teams[1+(i-1)%team_count] g_players[peer_id].team=team announce('You joined to '..team..'.', peer_id) - --webmapAddon + --WebMapAddon if g_has_webmap then local vehicle=findVehicle(g_players[peer_id].vehicle_id) if vehicle and vehicle.alive then