Jump to content

Recommended Posts

Posted

Hi, 

i would like to write a script to return in a variable true or false the result of an event check on S_EVENT_PILOT_DEAD and S_EVENT_CRASH in order to stop immediately the export of data toward my 6DOF motion platform driving software to prevent excessive moves.

 i know how to stop the data export so I could do if I had the information but I don’t know at all how to manage the events in DCS scripts to create this information….any help would be highly appreciated….

Posted

Hi Swson,

Here are my thoughts.  Now I am a newbie to llua, programming in general, and DCS sdripting. 

With that said, you probably want to use the world.addevent function.  The Hoggit Wiki entry that describes this event is:

https://wiki.hoggitworld.com/view/DCS_func_addEventHandler

 

And here is my attempt at modify some code I'm using to do what you want.  THIS IS NOT TESTED.

 

Good luck and hope this helps.

 

local debugFlagHotLZ = 0    --  Set to 1 to have the debug statement print to screen

local checkForEvent = {}
function checkForEvent:onEvent(event)
    local _status, _err = pcall(function(_args)
    if  ((event.id == world.event.S_EVENT_EJECTION and event.initiator ~= nil) or
        (event.id == world.event.S_EVENT_PILOT_DEAD and event.initiator ~= nil) or
        (event.id == world.event.S_EVENT_CRASH and event.initiator ~= nil) or
        (event.id == world.event.S_EVENT_DEAD and event.initiator ~= nil)) then
       local leftUnit = event.initiator
          if (debugFlagHotLZ == 1) then
            trigger.action.outText("leftUnit loop Event ID is = " .. event.id,10
          end
      
        local playerName = leftUnit:getPlayerName()
        if (playerName ~= nil) then
          if (debugFlagHotLZ == 1) then
            trigger.action.outText(playerName .. "/" .. leftUnit:getName() .. " left " .. leftUnit:getTypeName() .. " or ejected or died",5)
          end
          -- *******************   add what you want to do here.  ***********************************
        end
      
    end
    end, _arguments)

    if (not _status) then
        env.error(string.format("Helo_Transport: checkForEvent ERROR: %s", _err))
    trigger.action.outText("Helo_Transport: checkForEvent ERROR: " .. _err, 10)
    end
end
local Event_Check = world.addEventHandler(checkForEvent)

 

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

AKA_Clutter

 

Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

Posted

thanks a lot but i'm looking to code able to be working in a hook program launched at every kind of mission start and running on every frame based. Unfortunately, i've discovered that most function and particularly the world.xxx ones are not allowed in hooks scripts but only into mission environment.

So i'm now looking to different side ways like getting the getlife() fuction (not sure it works) or creating a generic mission mod into the savegame/mod/folder....

  • 1 month later...
Posted (edited)

I finally found a way to know if the human player of an aircraft is still piloting or has ejected 

first you need to get the player Plane Id from export.logetplayerplaneid() then get the object info from export.logetobjectby Id(player plane id)

if not object info then the pilot is out the aircraft

this script is working in a hook script where you can’t manage events 

 

Edited by Swson
  • Recently Browsing   0 members

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