Jump to content

Kanelbolle

Members
  • Posts

    213
  • Joined

  • Last visited

2 Followers

Personal Information

  • Flight Simulators
    DCS
  • Location
    Norway
  • Interests
    Gaming and Scripting
  • Occupation
    IT
  • Website
    https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. You can delete it your self by pressing Hide in the "Moderation Action" meny on top of this post.
  2. Here is an example that does the following: 1. Checks all airfields what coalition it is 2. Draws a circle at the airbase according to the coalition color 3. Changes the color if it changes coalition between Blue and Red. It does not, change if the airfields go Natural after it has been captured. You need a scheduled function to check this in a loop. Added a example mission and the script. Here is it raw. It's messy and old, but it an working example. ebc = ebc or {} -- do not remove function ebc.loadStartingBases() local baseCheckLoadeed = world.getAirbases() local myBaseLoadedTbl = {} for i = 1, #baseCheckLoadeed do local infoLoaded = {} infoLoaded.id = Airbase.getID(baseCheckLoadeed[i]) infoLoaded.desc = Airbase.getDesc(baseCheckLoadeed[i]) infoLoaded.point = Airbase.getPoint(baseCheckLoadeed[i]) infoLoaded.callsign = Airbase.getCallsign(baseCheckLoadeed[i]) infoLoaded.afcoa = Airbase.getCoalition(baseCheckLoadeed[i]) infoLoaded.afbase = baseCheckLoadeed[i] if (Object.getCategory(baseCheckLoadeed[i]) == 4) and (infoLoaded.desc.category == 0 ) then -- Creates circle on map with same id as Airfiled ID (If you have other drawings on map, you should change what id the drawing gets if (infoLoaded.afcoa == 0 ) then trigger.action.circleToAll(-1 , infoLoaded.id , infoLoaded.point , 6000 , {1,1,1,1} , {0,0,0,0} , 5) elseif (infoLoaded.afcoa == 1 ) then -- RED AIRBASE trigger.action.circleToAll(-1 , infoLoaded.id , infoLoaded.point , 6000 , {1,0,0,1} , {0,0,0,0} , 5) elseif (infoLoaded.afcoa == 2 ) then -- BLUE AIRBASE trigger.action.circleToAll(-1 , infoLoaded.id , infoLoaded.point , 6000 , {0,0,1,1} , {0,0,0,0} , 5) end end -- of if (Object.getCategory(baseCheckLoadeed[i]) == 4) and (infoLoaded.desc.category == 0 ) then end -- of for i = 1, #baseCheckLoadeed do end -- of function ebc.loadStartingBases() ebc.captureHandler = {}; function ebc.captureHandler:onEvent(event) if (world.event.S_EVENT_BASE_CAPTURED == event.id) then if event.place ~= nil then --trigger.action.outText("event not nil radiocargo!",20) local CapPlaceDesc =Airbase.getDesc(event.place) local CapPlaceId = Airbase.getID(event.place) local CapPlaceName = Airbase.getName(event.place) local CapAirbaseName if (CapPlaceDesc.category == 1) then CapAirbaseName = CapPlaceName else CapAirbaseName = CapPlaceDesc.displayName end local targetCoord = Airbase.getByName(CapAirbaseName):getPoint() -- Red Capped base if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 1) then trigger.action.outText("Airbase was captured by Red coalition: " ..CapAirbaseName,20) -- local msg = string.format("Airbase ID : %i", CapPlaceId) --trigger.action.outText(msg , 10) -- Smoke trigger.action.smoke(targetCoord, trigger.smokeColor.Red) --Change Color of circle trigger.action.setMarkupColor(CapPlaceId , {1,0,0,1} ) -- Logg _airbaseIDString = string.format("%i", CapPlaceId) env.info('- Airbase was captured by Red coalition: ' .. CapAirbaseName .. ' - AirbaseID: ' .. _airbaseIDString) end -- of if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 1) then -- Blue capped airbase if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 2) then --CapAirbaseName = CapPlaceDesc.displayName trigger.action.outText("Airbase was captured by Blue coalition: " ..CapAirbaseName,20) -- local msg = string.format("Airbase ID : %i", CapPlaceId) --trigger.action.outText(msg , 10) -- Smoke trigger.action.smoke(targetCoord, trigger.smokeColor.Blue) --Change Color of circle trigger.action.setMarkupColor(CapPlaceId , {0,0,1,1} ) -- Logg _airbaseIDString = string.format("%i", CapPlaceId) env.info('- Airbase was captured by Blue coalition: ' .. CapAirbaseName .. ' - AirbaseID: ' .. _airbaseIDString) end -- of if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 2) then -- Does not work since there is no event running on neutral -- Need to check this with a schedual or something if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 0) then trigger.action.outText("Airbase is Neutral: " ..CapAirbaseName,20) env.info("Airbase is Neutral: " ..CapAirbaseName) end -- of if (CapPlaceDesc.category == 0 ) and (Object.getCategory(event.place) == 4) and (Airbase.getCoalition(event.place) == 0) then end --if event.place ~= nil end --if (world.event.S_EVENT_BASE_CAPTURED == event.id) then end --end ebc.captureHandler -- Run the first function to make the markers ebc.loadStartingBases() -- Start the monitoring of the event world.addEventHandler(ebc.captureHandler) env.info('EBC loaded!') test_ebc_v001.miz ebc-Example_001.lua
  3. Can see if i can get one of my scripts cleaned up to post this weekend
  4. To do Color you just use the color variable for the command: https://wiki.hoggitworld.com/view/MIST_markerAdd Example: vd.color = {1,1,1,1}
  5. Not that i know of, maybe look at all the available commands: https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation You have to keep track of the id's you crate if you want to delete them, as i showed you before, but you can put them all in a table instead of individual strings. See here: https://www.tutorialspoint.com/lua/lua_tables.htm I would highly recommend you start taking a LUA tutorial if you are going to code for DCS
  6. This is the getGroupPoints that gets this points from the waypoints of the group. It only seam to make polygons, not lines. Here is a quick and dirty example to make a drawing using a loop that gets a units route : function makeLineFromUnitRoute(_unitName) local test = {} local posTbl = {} local _last = nil test.pos = mist.getGroupPoints(_unitName) for k,v in pairs(test.pos) do env.info(v) if (k == 1) then _last = test.pos[k] env.info("Adding First off all pos: " .. test.pos[k].x) elseif (k ~= _last) then env.info("Pos: " .. k) env.info("Adding new pos: " .. test.pos[k].x) posTbl = { [1] = _last, [2] = { ["x"] = test.pos[k].x, ["y"] = test.pos[k].y, }, } local vd = {} vd.id = mist.marker.getNextId() vd.pos = posTbl vd.lineType = 1 vd.mType = 'line' mist.marker.add(vd) env.info("Made Line from point " .. k .. posTbl[1].x .. " to " .. posTbl[2].x) trigger.action.outText("Made Line to point " .. k , 10) _last = test.pos[k] end posTbl = {} end end makeLineFromUnitRoute('Ground-1')
  7. "Wargames - Test Server" is up with a new concept i am testing. Helicopter and Combined Arms PvPvE mission with capture the zone. You are welcome to join if you fly helicopters. Running on the PG map now.
  8. Ah.. your still trying to use the markers in the ME with code. As i said already, it seam to be bugged.. Just do it with code as i showed before.. See attached mission test-DrawingLines-.miz
  9. Can't seam to open your mission file. But do you have a unique id for all the markers ? Example if you do this: _mId1 =mist.marker.getNextId() _mId2 =mist.marker.getNextId() They will both get the same id. The getNextId() actively gets the existing id's and gets the next, so you have to create a drawing before calling it again.... You have to do it like this: -- Create Trigger Zones and get them by name here local _tZone1 = trigger.misc.getZone("L1Start") local _tZone2 = trigger.misc.getZone("L1End") local _tZone3 = trigger.misc.getZone("L2") -- Save the marker id to a variable for later _mId1 =mist.marker.getNextId() -- Create the line trigger.action.lineToAll(-1 , _mId1 , _tZone1.point , _tZone2.point , {1,0,0,1} , 1 , false) -- Save the marker id to a variable for later _mId2 =mist.marker.getNextId() -- Create the line trigger.action.lineToAll(-1 , _mId2 , _tZone2.point , _tZone3.point , {1,0,0,1} , 1 , false) You could also just put the ID's manually: -- Create Trigger Zones and get them by name here local _tZone1 = trigger.misc.getZone("L1Start") local _tZone2 = trigger.misc.getZone("L1End") local _tZone3 = trigger.misc.getZone("L2") -- Save the marker id to a variable for later _mId1 = 90001 -- Create the line trigger.action.lineToAll(-1 , _mId1 , _tZone1.point , _tZone2.point , {1,0,0,1} , 1 , false) -- Save the marker id to a variable for later _mId2 = 90002 -- Create the line trigger.action.lineToAll(-1 , _mId2 , _tZone2.point , _tZone3.point , {1,0,0,1} , 1 , false) But i would just do a integer variable that you count up every time. _midCounter = 90000 _midCounter = _midCounter + 1 _mId1 = _midCounter _midCounter = _midCounter + 1 _mId2 = _midCounter
  10. Yea, have been trying for some hours now to remove markers from ME but seam to be bugged... But if you want to do it by code you can just set out Trigger zones in ME where the lines should go and make them like this: -- Create Trigger Zones and get them by name here local _tZone1 = trigger.misc.getZone("L1Start") local _tZone2 = trigger.misc.getZone("L1End") -- Save the marker id to a variable for later _mId =mist.marker.getNextId() -- Create the line trigger.action.lineToAll(-1 , _mId , _tZone1.point , _tZone2.point , {1,0,0,1} , 1 , false) -- Remove the line later trigger.action.removeMark(_mId)
  11. Hi Right place to ask is here : https://forum.dcs.world/forum/1160-scripting-tips-tricks-issues/ Use this example : local u = mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'KutaisiBattle'}) for i = 1, #u do local _uName = Unit.getName(u[i]) trigger.action.outText("checking ".. _uName, 2, false) end Se here : https://wiki.hoggitworld.com/view/MIST_getUnitsInZones
  12. Here is an example miz and the code: local _var = {} -- Create a drawing 1 _var.id = mist.marker.getNextId() _var.pos = mist.getGroupPoints('Ground-1') _var.mType = 'freeform' -- Add to a global variable or a table while you create the marker shapeinfo1 = mist.marker.add(_var) -- Create a drawing 2 _var.id = mist.marker.getNextId() _var.pos = mist.getGroupPoints('Ground-2') _var.mType = 'freeform' -- Add to a global variable or a table while you create the marker shapeinfo2 = mist.marker.add(_var) -- Run this where you want to delete the drawing mist.marker.remove(shapeinfo1) mist.marker.remove(shapeinfo2) From examples here: https://wiki.hoggitworld.com/view/MIST_markerAdd https://wiki.hoggitworld.com/view/MIST_markerRemove You could also use markerGet to get the drawping info if you have a name, but have not tried this. https://wiki.hoggitworld.com/view/MIST_markerGet test-Mist-CreateDeleteDrawing-.miz
  13. Not sure what you mean. Works just fine for me. See example mission and code -- Activation happens in the mission editor, but you could add it to the code. _GpName = "Ground-1" if (Group.getByName(_GpName):getUnit(1):isActive() == false) then trigger.action.outText("Group was not active, activating group :" .. _GpName , 10) elseif (Group.getByName(_GpName):getUnit(1):isActive() == true) then trigger.action.outText("Group is allready active :" .. _GpName , 10) end test-checkactivegroup.miz
  14. Sounds like you need to make a script that monitors the event kill : https://wiki.hoggitworld.com/view/DCS_event_kill And sends a text to the unit that is the killer with: https://wiki.hoggitworld.com/view/DCS_func_outTextForUnit You can search the forum for examples, but here is one:
  15. Think you are looking for CTLD for MOOSE. flightcontrol-master.github.io/MOOSE_DOCS/Documentation/Ops.CTLD.html
×
×
  • Create New...