Jump to content

*GameUI.lua onGameEvent


ked

Recommended Posts

Hey guys, i'm looking to export some game events via the GameGUI system and a socket. It works great so far but when i looked at the documentation i saw this in the DCS_ControlAPI.txt file

 

function onGameEvent(eventName,arg1,arg2,arg3,arg4) 
--"friendly_fire", playerID, weaponName, victimPlayerID
--"mission_end", winner, msg
--"kill", killerPlayerID, killerUnitType, killerSide, victimPlayerID, victimUnitType, victimSide, weaponName
--"self_kill", playerID
--"change_slot", playerID, slotID, prevSide
--"connect", playerID, name
--"disconnect", playerID, name, playerSide, reason_code
--"crash", playerID, unit_missionID
--"eject", playerID, unit_missionID
--"takeoff", playerID, unit_missionID, airdromeName
--"landing", playerID, unit_missionID, airdromeName
--"pilot_death", playerID, unit_missionID
end

The problem is about the arguments, i guess arg1 is playerId for "friendly_fire", winner for "mission_end".

If i try to do this

[color=#d4d4d4][font=Consolas][color=black]DcsStats.update(eventName..":"..arg1..":"..arg2..":"..arg3)[/color][/font][/color]

i will only have the "change_slot" event showing up, if i do

[color=#d4d4d4][font=Consolas][color=Black]DcsStats.update(eventName..":"..arg1..":"..arg2)[/color][/font][/color]

i only have the events with 2 arguments showing up. Which makes sense because the arg4 variable would be nil(or not declared i don't know tbh). i wonder how i can work around with that ? Documentation isn't really clear about that.

 

I also wonder how the kill event works because you should have 7 arguments and have only 4 variables

 

If anyone that can help me with that

 

Cheers

 

PS: my update function just sends a mesage to a local server

[font=Consolas]function DcsStats.update(message)
   socket.try(DcsStats.UDPSendSocket:sendto(DcsStats.JSON:encode(message).." \n", DcsStats.host, DcsStats.port))
end

[/font]


Edited by ked
Link to comment
Share on other sites

I found a way if anybody's interested

 

[font=Consolas]function DcsStats.onGameEvent(eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7) 
--"friendly_fire", playerID, weaponName, victimPlayerID
--"mission_end", winner, msg
--"kill", killerPlayerID, killerUnitType, killerSide, victimPlayerID, victimUnitType, victimSide, weaponName
--"self_kill", playerID
--"change_slot", playerID, slotID, prevSide
--"connect", playerID, name
--"disconnect", playerID, name, playerSide, reason_code
--"crash", playerID, unit_missionID
--"eject", playerID, unit_missionID
--"takeoff", playerID, unit_missionID, airdromeName
--"landing", playerID, unit_missionID, airdromeName
--"pilot_death", playerID, unit_missionID
if DCS:isServer() then
   local message = eventName
   if arg1 ~= nil then
       message = message..":"..arg1
   end
   if arg2 ~= nil then
       message = message..":"..arg2
   end
   if arg3 ~= nil then
       message = message..":"..arg3
   end
   if arg4 ~= nil then
       message = message..":"..arg4
   end
   if arg5 ~= nil then
       message = message..":"..arg5
   end
   if arg6 ~= nil then
       message = message..":"..arg6
   end
   if arg7 ~= nil then
       message = message..":"..arg7
   end

   DcsStats.update(message)
   DcsStats.log(message)
end
end

[/font]

Link to comment
Share on other sites

  • 4 years later...
  • Recently Browsing   0 members

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