gregzagk Posted February 22, 2014 Posted February 22, 2014 I would like a little help from the Script gurus :helpsmilie: We recently used a script to have air to air training.The aircrafts are set to Immortal and they will die only if they crash to the ground. The idea of the script is that it will count hits to client aircrafts in order to get them a message that they are hit and they should leave the area and RTB. The goal is to have air to air training and let the clients RTB with their wingman without being actualy destoyed by missiles. The problem is that the script is not working for hits from humans to humans. It only works when AI fighters hit a human aircraft. It works only if the aircrafts are not Immortal. -- event handlers: HitEventHandler = {}; -- function - event handler for aircraft: function HitEventHandler:onEvent(event) -- counting hits on aircrafts: if (world.event.S_EVENT_HIT == event.id) then local tgt = event.target local tgtType = tgt:getTypeName() if (tgtType == "Su-27") or (tgtType == "Su-33") or (tgtType == "F-15C") or (tgtType == "MiG-29S") or (tgtType == "Su-25") or (tgtType == "Su-25T") or (tgtType == "A-10C") then --Check if hit unit Player Controlled local player = Unit.getPlayerName(tgt) trigger.action.outText( player .. ' you are hit. Leave the area!' ,20) end end end world.addEventHandler(HitEventHandler) *We added the line : If (tgtType == "Su-27") or (tgtType == "Su-33") or (tgtType == "F-15C") or (tgtType == "MiG-29S") or (tgtType == "Su-25") or (tgtType == "Su-25T") or (tgtType == "A-10C") cause the script crashes when an AI hits another AI. So we had only human SU-27,F-15,MIG-29,SU-25T/A in the mission and the AI's are another type of aircraft. "ARGO" DCS UH-1H DLC SP Campaign 373vFS DCS World squadron (Greece) - www.buddyspike.net "ARGO 2.0 Project Phoenix" UH-1H DLC Campaign - WIP
HiJack Posted February 23, 2014 Posted February 23, 2014 I thought you had this working Greg! I always use ' in stead of " but it should work with both I think.
HiJack Posted February 23, 2014 Posted February 23, 2014 Looks like other scripters also use single ' on types.
gregzagk Posted February 23, 2014 Author Posted February 23, 2014 I thought you had this working Greg! I always use ' in stead of " but it should work with both I think. Hello.Yes we have this working but it works only with AI vs Humans. We would like to have this working with Humans vs Humans. "ARGO" DCS UH-1H DLC SP Campaign 373vFS DCS World squadron (Greece) - www.buddyspike.net "ARGO 2.0 Project Phoenix" UH-1H DLC Campaign - WIP
HiJack Posted February 23, 2014 Posted February 23, 2014 I use this code I found on the Russian part of the forum to check types. Maby this will give you an idea how to change your code ;) I also inculded a test mission. -- obtaining type names: local _zone = trigger.misc.getZone('get_types'); local _volume = { id = world.VolumeType.SPHERE, params = { point = _zone.point, radius = _zone.radius } }; local _types = { allNames = '' }; world.searchObjects(Object.Category.UNIT, _volume, function(_object, _data) _data.allNames = _data.allNames .. _object:getTypeName() .. '\n\r'; return true; end, _types); trigger.action.outText(_types.allNames, 30); Test - Display object types.miz EDIT: I have run this in both SP and MP but you get the same type on both.
HiJack Posted February 24, 2014 Posted February 24, 2014 I think you must go the way and identify if the target is human and then read the group or maybe the other way around. Can you serialize all active players (AI.Skill == 'CLIENT') and get their unitID? AI Contains constants used in Controller functions. AI.Skill = { AVERAGE, GOOD, HIGH, EXCELLENT, PLAYER, CLIENT }
gregzagk Posted February 24, 2014 Author Posted February 24, 2014 I will try these man.Thanks a lot! :) "ARGO" DCS UH-1H DLC SP Campaign 373vFS DCS World squadron (Greece) - www.buddyspike.net "ARGO 2.0 Project Phoenix" UH-1H DLC Campaign - WIP
Stuka Posted February 28, 2014 Posted February 28, 2014 Having a similar problem. By the looks of it, world.event.S_EVENT_HIT does not register gun rounds form a client. Is there a way to have it working, or an alternative ? Windows 11 | i9 12900KF | 64GB DDR4 | RTX 3090 | TM Warthog HOTAS | Saitek Combat Rudder Pedals | TM MFDs + Lilliput 8" | TIR5 Pro
Recommended Posts