Jump to content

Recommended Posts

Posted

I made a mission with invulnerable planes to practice gunnery and a script that tells when you hit someone. The problem is that only shots by the host trigger the S_EVENT_HIT event. Hit event is registered in the debrief.log also for clients but not in SSE environment. I have attached the mission.

 

messages = {};
refreshrate = 1; --in seconds

function addMessage(msg, duration)
   table.insert(messages, msg);
   mist.scheduleFunction(RemoveMessage, {msg }, timer.getTime() + duration);
end;

function RemoveMessage(msg2)
   for i, tablemsg in ipairs(messages) do
       if tablemsg == msg2 then
           table.remove(messages, i);
           break;                
       end;
   end;    
end;

function ShowMessages()
   local messages = mist.utils.deepCopy(messages)
   local output = "";
   
   for i, val in ipairs(messages) do
       if i == 1 then
           output = val;
       else
           output = output .. "\n" .. val;
       end;
   end;
   
   if output ~= "" then
       trigger.action.outText(output, refreshrate);
   end;
   mist.scheduleFunction(ShowMessages, {}, timer.getTime() + refreshrate);
end;

ShowMessages();

customEventHandler = {};

function customEventHandler:onEvent(event)
   if (world.event.S_EVENT_HIT == event.id) then
       local target = "unknown";
       if event.target:getCategory() == Object.Category.UNIT then
           if event.target:getPlayerName() then
               target = event.target:getPlayerName();
           elseif event.target:getName() then
               target = event.target:getName();
           end;            
       end;
       addMessage(target .. " was hit", 5);
   else
       addMessage("event id = " .. event.id, 20);
   end;
   
end;
world.addEventHandler(customEventHandler);

PvP snap shot drill BFM training 4x pairs.miz

  • Thanks 1

DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community

--------------------------------------------------

SF Squadron

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...