----------------------------------------------------------------------------------------------------------------------------------------------------------- -- __ __ ___ _ __ __ -- / //_/ / | __________(_)____/ /_____ _____ / /_ -- / ,< ______/ /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ -- / /| /_____/ ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ --/_/ |_| /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ -- ____ _ ______ __ _____ -- / __ \__ ______ ____ _____ ___ (_)____ / ____/___ _____ / /___ __________ /__ / ____ ____ ___ -- / / / / / / / __ \/ __ `/ __ `__ \/ / ___/ / / / __ `/ __ \/ __/ / / / ___/ _ \ / / / __ \/ __ \/ _ \ -- / /_/ / /_/ / / / / /_/ / / / / / / / /__ / /___/ /_/ / /_/ / /_/ /_/ / / / __/ / /__/ /_/ / / / / __/ --/_____/\__, /_/ /_/\__,_/_/ /_/ /_/_/\___/ \____/\__,_/ .___/\__/\__,_/_/ \___/ /____/\____/_/ /_/\___/ -- /____/ /_/ ----------------------------------------------------------------------------------------------------------------------------------------------------------- -- v 0.7.4 ----------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------- -- DEV NOTES ----------------------------------------------------------------------------------------------------------------------------------------------------------- -- RREWORKS AND UPGRADES ---- TODO - GUARD TIME SETTING -- vedi riga 76255 moose 2.7.10a - non c'è un setting apposito, potresti fregarlo settando manualmente self.HitTimeLast e self.HitTimeAttackOver -- DONE - use :GetZoneName() -- -- NEW FEATURES -- DONE - ADD CHECKS FOR MAXIMUM CAPTURE ZONES AT RUNTIME -- TODO - TEST - ADD SERVER CLEANER -- DONE - ADD INFO MESSAGES ABOUT ZONE CREATION AND DELETION - TO ALL -- DONE - TEST - MESSAGES TO UNITS WITHIN MESSAGE ZONE -- DONE - ZONE NAMING PROTOCOL -- DONE - SET MAX AND MIN CAPTURE ZONE RADIUS -- DONE - SAVE ADDITIONAL ITEMS INSIDE CAPTURE ZONE OBJECT -- DONE - TIMER TO UPDATE ZONE STATUS WITH MESSAGES -- -- FIXES -- DONE - TEST - SE MODIFICHE IL TESTO DEL MARKER LA ZONA PRECEDENTE NON VIENE ELIMINATA -- DONE - OVERLAPPED MISSION MARKS - FIX -- ************************************************************************ -- ********************* USER CONFIGURATION ***************************** -- ************************************************************************ ------------------------------- OPTIONS ----------------------------------- -- dcaz_Settings table allows you to enable/disable functions -- and configure parameters and options --------------------------------------------------------------------------- dcaz_Settings = { WecomeMessage = true, -- displays welcome message at mission start for 3 seconds Debug = true, -- debug mode - see dcs logs RefreshTime = 15, -- capture zones monitoring process refresh time - zones status will be checked every xx seconds GuardTime = 30, DrawZones = true, -- if true zones shapes will be drawed on F10 Map DrawMessageZones = true, -- if true message zones shapes will be drawed on F10 Map DefaultZoneRadius = 20000, -- default capture zone radius - if not specifyed by user MaxZoneRadius = 100000, -- limits maximum zone radius that can be set by users MinZoneRadius = 5000, -- limits minimum zone radius that can be set by users MessageZoneRadiusMultip = 1.5, -- defines the range within which players will receive zone status messages - -- e.g. = 1 : players will receave messages while they are inside capture zone -- e.g. = 2 : players will receive messages as long as they are within a distance equal to twice the radius of the capure zone ServerCleaner = true, -- enable/disable Server Cleaner that will delete all active capture zones if no active clients ServerCleanerScanTimer = 30, -- client scan interval - in minutes - if scan detects no clients connected then cleanup will be executed } -- END OF dcaz_Settings -- ************************************************************************ -- ********************* END OF USER CONFIGURATION ********************** -- ********************* DO NOT EDIT BELOW THIS LINE ********************** -- ************************************************************************ -- warn user if MOOSE not found if BASE == nil then env.info("MOOSE Framework not found! You must load MOOSE before K-Assistant!", true) end dcaz_Tags = { A2AMark = "#CAZ_AA", A2GMark = "#CAZ_AG" } -- END OF dcaz_Tags dcaz_CaptureZones ={} -- this table will store capture zones objects dcaz_CaptureZoneNames = { available = { [1] = "ONTARIO", [2] = "QUEBEC", [3] = "MANITOBA", [4] = "ALBERTA", [5] = "COLUMBIA", [6] = "YUCON", [7] = "HALIFAX", [8] = "TORONTO", [9] = "VICTORIA", [10] = "WINNIPEG", }, inUse = {} }-- END OF dcaz_CaptureZoneNames function dcaz_Mailman (messageText, messageTime, zoneMarkID, coalitionFilter) if messageText and zoneMarkID then dcaz_CaptureZones[zoneMarkID].dcaz_MessageZone:Scan({Object.Category.UNIT}, {Unit.Category.AIRPLANE, Unit.Category.HELICOPTER, Unit.Category.GROUND_UNIT}) -- scan message zone for units local scannedUnitsSet = dcaz_CaptureZones[zoneMarkID].dcaz_MessageZone:GetScannedSetUnit() -- get a set of units inside message zone if dcaz_Settings.Debug == true then local coalitionFilterName = coalitionFilter or "none" env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("Mailman : ",false) env.info("dcaz_Mailman - Coalition Filter : "..coalitionFilterName.." - UnitSet count : "..scannedUnitsSet:Count(),false) env.info("dcaz_Mailman - Message Text : "..messageText,false) end -- debug local messageDuration = messageTime or 5 scannedUnitsSet:ForEachUnit( function (unit) if coalitionFilter then local COALITION = string.upper(coalitionFilter) local unitCoalition = string.upper(unit:GetCoalitionName()) if COALITION == unitCoalition then MESSAGE:New( messageText , messageDuration):ToUnit(unit) if dcaz_Settings.Debug == true then env.info("dcaz_Mailman - Message sent to : "..unit:GetName().." Unit Coalition : "..unit:GetCoalitionName(),false) end -- debug end else MESSAGE:New( messageText , messageDuration):ToUnit(unit) if dcaz_Settings.Debug == true then env.info("dcaz_Mailman - Message sent to : "..unit:GetName().." Unit Coalition : Filter not enabled",false) end -- debug end end ) else if dcaz_Settings.Debug == true then env.info("dcaz_Mailman - no message text o unitset defined - exit",false) end -- debug return end end -- END of dcaz_Mailman -------------------------------------------------------- ---------------- REMOVE CAPTURE ZONE ------------------ -------------------------------------------------------- function dcaz_RemoveCapureZone(MarkID) if dcaz_Settings.Debug == true then env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("dcaz_RemoveCapureZone - Removing Zone with Mark ID "..MarkID,false) end -- debug local zoneName = dcaz_CaptureZones[MarkID]:GetZoneName() -- retrieve the zone name dcaz_CaptureZones[MarkID]:UndrawZone() -- remove draws form f10 map dcaz_CaptureZones[MarkID].dcaz_MessageZone:UndrawZone() if dcaz_Settings.Debug == true then env.info("dcaz_RemoveCapureZone - Zone Undrawed from F10 Map",false) end -- debug dcaz_CaptureZones[MarkID]:Stop() -- stops capture zone monitoring process if dcaz_Settings.Debug == true then env.info("dcaz_RemoveCapureZone - Capture Zone Process Stop",false) end -- debug trigger.action.removeMark( dcaz_CaptureZones[MarkID].dcaz_TextLabelID ) -- remove f10 text label if dcaz_Settings.Debug == true then env.info("dcaz_RemoveCapureZone - Zone Label Removed from F10 Map",false) end -- debug dcaz_CaptureZones[MarkID].infoScheduler:Stop() -- stop scheduler that send update messages for zone status if dcaz_Settings.Debug == true then env.info("dcaz_RemoveCapureZone - Status Messages Scheduler Stopped",false) end -- debug dcaz_CaptureZones[MarkID] = nil -- set capture zone object to nil table.insert(dcaz_CaptureZoneNames.available, dcaz_CaptureZoneNames.inUse[zoneName]) -- make zone name avalaible again dcaz_CaptureZoneNames.inUse[zoneName] = nil if dcaz_Settings.Debug == true then env.info("dcaz_RemoveCapureZone - REMOVED Zone with Mark ID "..MarkID,false) end -- debug MESSAGE:New("K-ASSISTANT: Dynamic Capture Zone" , 5):ToAll() MESSAGE:New("Zone "..zoneName.." Deleted" , 5):ToAll() end -------------------------------------------------------- ---------------- CREATE CAPTURE ZONE ------------------ -------------------------------------------------------- function dcaz_CreateCapureZone(MarkText, COALITION, MarkID, MarkCoordinate, Radius) if dcaz_CaptureZones[MarkID] ~= nil then -- if capture zone already exist remove it before continue if dcaz_Settings.Debug == true then env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("dcaz_CreateCapureZone - Zone with Mark ID "..MarkID.." already exist - removing before to continue...",false) end -- debug dcaz_RemoveCapureZone(MarkID) end local zoneNamePicker = function() -- pick a zone name from a list if available, if not available return nil local selectedZoneName = nil if #dcaz_CaptureZoneNames.available > 0 then -- if zone name list has names available pick one, insert it in zone names that are in use and remove from availables selectedZoneName = dcaz_CaptureZoneNames.available[1] dcaz_CaptureZoneNames.inUse[dcaz_CaptureZoneNames.available[1]] = dcaz_CaptureZoneNames.available[1] table.remove( dcaz_CaptureZoneNames.available, 1 ) else -- if no zone names available set it to nil selectedZoneName = nil end return selectedZoneName end -- take the zone name returned from the zoneNamePicker function and assign it to the zone, if nil stop the creation of the zone and exit local zoneName = zoneNamePicker() if zoneName == nil then MESSAGE:New("Maximum active zone limit reached - Zone creation canceled" , 5):ToAll() return end local zoneRadiusSet = function (userRadius) -- set zone radius, if not specified use default value local captureZoneRadius = nil if userRadius then captureZoneRadius = userRadius if captureZoneRadius > dcaz_Settings.MaxZoneRadius then captureZoneRadius = dcaz_Settings.MaxZoneRadius elseif captureZoneRadius < dcaz_Settings.MinZoneRadius then captureZoneRadius = dcaz_Settings.MinZoneRadius end else captureZoneRadius = dcaz_Settings.DefaultZoneRadius end return captureZoneRadius end local zoneRadius = zoneRadiusSet(Radius) local zone = ZONE_RADIUS:New(zoneName, MarkCoordinate:GetVec2(), zoneRadius) -- create zone object -- create the capture zone AA or AG if string.match(MarkText, dcaz_Tags.A2AMark) == dcaz_Tags.A2AMark then dcaz_CaptureZones[MarkID] = ZONE_CAPTURE_COALITION:New( zone, coalition.side[COALITION], {Unit.Category.AIRPLANE, Unit.Category.HELICOPTER} ) dcaz_CaptureZones[MarkID].dcaz_zoneType = "Air to Air" elseif string.match(MarkText, dcaz_Tags.A2GMark) == dcaz_Tags.A2GMark then dcaz_CaptureZones[MarkID] = ZONE_CAPTURE_COALITION:New( zone, coalition.side[COALITION], {Unit.Category.GROUND_UNIT} ) dcaz_CaptureZones[MarkID].dcaz_zoneType = "Air to Ground" end dcaz_CaptureZones[MarkID]:SetMarkZone(false) -- DISABLE AUTO CREATED MARKS -- TODO non fa smoke.. non so perchè ma sticazzi? -- dcaz_CaptureZones[MarkID]:SetSmokeZone(true) --dcaz_CaptureZones[MarkID]:Smoke( SMOKECOLOR.Blue ) --create message zone - players within this will receave status messages dcaz_CaptureZones[MarkID].dcaz_MessageZone = ZONE_RADIUS:New(MarkID, MarkCoordinate:GetVec2(), zoneRadius*dcaz_Settings.MessageZoneRadiusMultip) if dcaz_Settings.Debug == true then env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("dcaz_CreateCapureZone - Creating Capture Zone : "..zoneName,false) env.info("dcaz_CreateCapureZone - Capture Zone Type : "..dcaz_CaptureZones[MarkID].dcaz_zoneType,false) env.info("dcaz_CreateCapureZone - Capture Zone Radius : "..zoneRadius,false) env.info("dcaz_CreateCapureZone - Message Zone Radius : "..zoneRadius*dcaz_Settings.MessageZoneRadiusMultip,false) end -- debug ---------------- OnEnterGuarded ------------------ ---------------------------------------------------- dcaz_CaptureZones[MarkID].OnEnterGuarded = function ( From, Event, To ) -- code to execute when entering in guarded state -- if From ~= To then local Coalition = dcaz_CaptureZones[MarkID]:GetCoalition() -- get coalition owning the zone if dcaz_Settings.Debug == true then env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName,false) env.info("dcaz_CaptureZones["..MarkID.."] - Entering Guarded State",false) env.info("dcaz_CaptureZones["..MarkID.."] - Owned by coalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName(),false) end -- debug if Coalition == coalition.side.BLUE then -- send messages to units inside message zone dcaz_Mailman (string.format( "%s is under protection of the BLUE coalition", zoneName ), 5, MarkID) elseif Coalition == coalition.side.RED then dcaz_Mailman (string.format( "%s is under protection of the RED coalition", zoneName ), 5, MarkID) end local labelText = "Capture Zone : "..zoneName.."\nCoalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName().."\nType : "..dcaz_CaptureZones[MarkID].dcaz_zoneType.."\nStatus : "..dcaz_CaptureZones[MarkID]:GetState() trigger.action.setMarkupText(dcaz_CaptureZones[MarkID].dcaz_TextLabelID , labelText ) -- end end ---------------- OnEnterEmpty ------------------ ---------------------------------------------------- dcaz_CaptureZones[MarkID].OnEnterEmpty = function ( From, Event, To ) -- code to execute when entering in empty state if dcaz_Settings.Debug == true then env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName,false) env.info("dcaz_CaptureZones["..MarkID.."] - Entering Empty State",false) end -- debug dcaz_Mailman (string.format( "%s is unprotected, and can be captured!", zoneName ), 5, MarkID) -- send messages to units inside message zone local labelText = "Capture Zone : "..zoneName.."\nCoalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName().."\nType : "..dcaz_CaptureZones[MarkID].dcaz_zoneType.."\nStatus : "..dcaz_CaptureZones[MarkID]:GetState() trigger.action.setMarkupText(dcaz_CaptureZones[MarkID].dcaz_TextLabelID , labelText ) end ---------------- OnEnterAttacked ------------------ ---------------------------------------------------- dcaz_CaptureZones[MarkID].OnEnterAttacked = function ( From, Event, To ) -- code to execute when entering in attacked state local Coalition = dcaz_CaptureZones[MarkID]:GetCoalition() -- get coalition owning the zone if dcaz_Settings.Debug == true then env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName,false) env.info("dcaz_CaptureZones["..MarkID.."] - Entering Attacked State",false) env.info("dcaz_CaptureZones["..MarkID.."] - Owned by coalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName(),false) end -- debug if Coalition == coalition.side.BLUE then -- send messages to units inside message zone dcaz_Mailman ( string.format( "%s is under attack by RED coalition!!!", zoneName ), 5, MarkID, "blue") dcaz_Mailman ( string.format( "We are attacking %s", zoneName ), 5, MarkID, "red") elseif Coalition == coalition.side.RED then dcaz_Mailman ( string.format( "%s is under attack by BLUE coalition!!!", zoneName ), 5, MarkID, "red") dcaz_Mailman ( string.format( "We are attacking %s", zoneName ), 5, MarkID, "blue") end local labelText = "Capture Zone : "..zoneName.."\nCoalition : ".."\nType : "..dcaz_CaptureZones[MarkID].dcaz_zoneType..dcaz_CaptureZones[MarkID]:GetCoalitionName().."\nStatus : "..dcaz_CaptureZones[MarkID]:GetState() trigger.action.setMarkupText(dcaz_CaptureZones[MarkID].dcaz_TextLabelID , labelText ) end ---------------- OnEnterCaptured ------------------ ---------------------------------------------------- dcaz_CaptureZones[MarkID].OnEnterCaptured = function ( From, Event, To ) -- code to execute when entering in captured state local Coalition = dcaz_CaptureZones[MarkID]:GetCoalition() -- get coalition owning the zone if dcaz_Settings.Debug == true then env.info("K-ASSISTANT: Dynamic Capture Zone",false) env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName,false) env.info("dcaz_CaptureZones["..MarkID.."] - Entering Captured State",false) env.info("dcaz_CaptureZones["..MarkID.."] - Owned by coalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName(),false) end -- debug if Coalition == coalition.side.BLUE then -- send messages to units inside message zone dcaz_Mailman ( string.format( "We captured %s, Excellent job!", zoneName ), 5, MarkID, "blue") dcaz_Mailman ( string.format( "%s is captured by the BLUE coalition, we lost it!", zoneName ), 5, MarkID, "red") elseif Coalition == coalition.side.RED then dcaz_Mailman ( string.format( "We captured %s, Excellent job!", zoneName ), 5, MarkID, "red") dcaz_Mailman ( string.format( "%s is captured by the RED coalition, we lost it!", zoneName ), 5, MarkID, "blue") end -- TODO VA COMUNQUE IN GUARD QUANDO CAZZO GLI PARE... --dcaz_CaptureZones[MarkID]:__Guard( 120 ) local labelText = "Capture Zone : "..zoneName.."\nCoalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName().."\nType : "..dcaz_CaptureZones[MarkID].dcaz_zoneType.."\nStatus : "..dcaz_CaptureZones[MarkID]:GetState() trigger.action.setMarkupText(dcaz_CaptureZones[MarkID].dcaz_TextLabelID , labelText ) end ----------- F10 Map Marker and MArkups ------------ ---------------------------------------------------- -- create F10 map marker for capture zone and listen to remove event dcaz_CaptureZones[MarkID].dcaz_Mark = MARKER:New(MarkCoordinate, "Capture Zone : "..zoneName.."\nRadius : "..zoneRadius.."\nType : "..dcaz_CaptureZones[MarkID].dcaz_zoneType.."\n\nREMOVE THIS MARKER TO DELETE"):ToAll() -- create marker trigger.action.removeMark( MarkID ) -- remove user created f10 mark if dcaz_Settings.Debug == true then env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName.." - F10 Map Marker Created",false) end -- debug dcaz_CaptureZones[MarkID].dcaz_Mark.OnAfterRemoved = function (From, Event, To, EventData) -- listen to remove event if dcaz_Settings.Debug == true then env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName.." - F10 Map Marker Removed",false) end -- debug dcaz_RemoveCapureZone(MarkID) -- when marker is removed call function to remove the capture zone end -- create text label in F10 map dcaz_CaptureZones[MarkID].dcaz_TextLabelID = MarkID+1000 local labelText = "Capture Zone : "..zoneName.."\nCoalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName().."\nStatus : "..dcaz_CaptureZones[MarkID]:GetState() trigger.action.textToAll(-1 , dcaz_CaptureZones[MarkID].dcaz_TextLabelID , MarkCoordinate:Translate(500, 135, false):GetVec3() , {1, 1, 1, 1} , {0, 0, 0, 0.8} , 12 , false , labelText ) -- draw capture zone in F10 map if dcaz_Settings.DrawZones == true then dcaz_CaptureZones[MarkID]:DrawZone(-1, {1, 1, 1}, 0.8, {1, 1, 0.2}, 0.3, 4, true) if dcaz_Settings.Debug == true then env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName.." - Drawed on F10 Map",false) end -- debug end -- draw message zone in F10 map if dcaz_Settings.DrawMessageZones == true then -- draw capture zone in F10 map dcaz_CaptureZones[MarkID].dcaz_MessageZone:DrawZone(-1, {1, 1, 1}, 0.4, {1, 0.6, 1}, 0.2, 0, true) if dcaz_Settings.Debug == true then env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName.." - Drawed on F10 Map",false) end -- debug end --------------- Capture Zone Start --------------- ---------------------------------------------------- -- TODO VERIFICARE SE SERVE lo status empty dcaz_CaptureZones[MarkID]:__Empty( 1 ) -- set capture zone in empty state 1 second after creation dcaz_CaptureZones[MarkID]:Start( 5, dcaz_Settings.RefreshTime ) -- start capture zone monitoring process dcaz_CaptureZones[MarkID].infoScheduler = SCHEDULER:New( dcaz_CaptureZones[MarkID], function() dcaz_CaptureZones[MarkID].dcaz_MessageZone:Scan({Object.Category.UNIT}, {Unit.Category.AIRPLANE, Unit.Category.HELICOPTER, Unit.Category.GROUND_UNIT}) -- scan message zone for units local scannedUnitsSet = dcaz_CaptureZones[MarkID].dcaz_MessageZone:GetScannedSetUnit() -- get a set of units inside message zone if dcaz_Settings.Debug == true then env.info("Zone : "..dcaz_CaptureZones[MarkID]:GetZoneName().."\nCoalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName().." - Status : "..dcaz_CaptureZones[MarkID]:GetState() , dcaz_Settings.RefreshTime-1, false) end scannedUnitsSet:ForEachUnit( function (unit) -- MESSAGE:New( messageText , messageDuration):ToUnit(unit) MESSAGE:New("Zone : "..dcaz_CaptureZones[MarkID]:GetZoneName().."\nCoalition : "..dcaz_CaptureZones[MarkID]:GetCoalitionName().." - Status : "..dcaz_CaptureZones[MarkID]:GetState() , dcaz_Settings.RefreshTime-1):ToUnit(unit) if dcaz_Settings.Debug == true then env.info("dcaz_Mailman - Message sent to : "..unit:GetName().." update scheduler",false) end -- debug end ) end, {}, dcaz_Settings.RefreshTime, dcaz_Settings.RefreshTime ) MESSAGE:New("K-ASSISTANT: Dynamic Capture Zone" , 5):ToAll() -- notify all players about zone creation MESSAGE:New("Zone "..zoneName.." Created" , 5):ToAll() MESSAGE:New("Coalition : "..COALITION.." - Type : "..dcaz_CaptureZones[MarkID].dcaz_zoneType.." - Radius : "..zoneRadius , 5):ToAll() -- MESSAGE:New("Zone State : "..dcaz_CaptureZones[MarkID]:GetState() , 5):ToAll() if dcaz_Settings.Debug == true then env.info("dcaz_CaptureZones["..MarkID.."] - Zone : "..zoneName.." - Created",false) end -- debug end -- END OF dcaz_CreateCapureZone -- TODO TEST function dcaz_ServerCleaner() env.info("K-ASSISTANT: DYNAMIC CAPTURE ZONE - SERVER CLEANER", false) local clientList = net.get_player_list() if #clientList == 0 then -- is single player env.warning("DYNAMIC CAPTURE ZONE - SERVER CLEANER : SINGLE PLAYER MODE DETECTED", false) env.warning("DYNAMIC CAPTURE ZONE - SERVER CLEANER SHOULD BE ENABLED IN MULTIPLAYER ONLY!", false) dcaz_ServerCleanerTimer:Stop() env.warning("DYNAMIC CAPTURE ZONE - SERVER CLEANER KILLED ITSELF AND IS NOW DISABLED!", false) return elseif #clientList > 1 then -- clients are connected env.info("DYNAMIC CAPTURE ZONE - SERVER CLEANER : CLIENTS CONNECTED TO SERVER - CLEANING SKIPPED ", false) env.info("CONNECTED CLIENTS : "..tostring(#clientList), false) return elseif #clientList == 1 then -- only server host is connected env.info("DYNAMIC CAPTURE ZONE - CONNECTED CLIENTS : "..tostring(#clientList), false) -- TODO test for markID, captureZone in pairs(dcaz_CaptureZones) do -- dcaz_CaptureZones[markID].dcaz_Mark:Remove() captureZone.dcaz_Mark:Remove() -- trigger.action.removeMark(markID) end env.info("DYNAMIC CAPTURE ZONE - SERVER CLEANER : NO CONNECTED CLIENTS - CLEANING DONE ", false) end end -- end of Server Cleaner -- TODO TEST if dcaz_Settings.ServerCleaner == true then local TimerInSeconds = math.floor(dcaz_Settings.ServerCleanerScanTimer * 60) dcaz_ServerCleanerTimer = TIMER:New(dcaz_ServerCleaner) dcaz_ServerCleanerTimer:Start(TimerInSeconds, TimerInSeconds) env.info("K-ASSISTANT : DYNAMIC CAPTURE ZONE - SERVER CLEANER ENABLED - CHECK WILL BE PERFORMED EVERY: "..TimerInSeconds.." seconds", false) end -- end of Server Cleaner dcaz_MarkEvents = EVENTHANDLER:New() --dcaz_MarkEvents:HandleEvent(EVENTS.MarkAdded) dcaz_MarkEvents:HandleEvent(EVENTS.MarkChange) --dcaz_MarkEvents:HandleEvent(EVENTS.MarkRemoved) --function dcaz_MarkEvents:OnEventMarkAdded(EventData) --end function dcaz_MarkEvents:OnEventMarkChange(EventData) -- MESSAGE:New("EVENT CHANGE MARK" , 5):ToAll() -- debug local markText = string.upper(EventData.MarkText) -- MESSAGE:New(markText , 5):ToAll() -- debug local markCoalition = nil local zoneRadius = nil if string.match(markText, dcaz_Tags.A2AMark) == dcaz_Tags.A2AMark or string.match(markText, dcaz_Tags.A2GMark) == dcaz_Tags.A2GMark then -- MESSAGE:New("STRING MATCH" , 5):ToAll() -- debug if EventData.MarkCoalition == 1 then markCoalition = "RED" -- MESSAGE:New("RED" , 5):ToAll() -- debug elseif EventData.MarkCoalition == 2 then markCoalition = "BLUE" -- MESSAGE:New("BLUE" , 5):ToAll() -- debug end local MarkCoordinate = EventData.MarkCoordinate if string.match(markText, "%((%d+)%)") then zoneRadius = tonumber(string.match(markText, "%((%d+)%)")) -- set zone radius if defined in markText between brakets -- MESSAGE:New("RADIUS "..zoneRadius , 5):ToAll() -- debug end dcaz_CreateCapureZone(markText, markCoalition, EventData.MarkID, MarkCoordinate, zoneRadius) end end --function dcaz_MarkEvents:OnEventMarkRemoved(EventData) --end if dcaz_Settings.WecomeMessage == true then MESSAGE:New( "K-Assistant: Dynamic Capture Zone - Loaded!" , 3):ToAll() end env.info("* * * K-ASSISTANT: DYNAMIC ZONE CAPTURE LOADED * * *",false)