ked Posted December 5, 2017 Posted December 5, 2017 (edited) 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 endThe 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 December 5, 2017 by ked
ked Posted December 5, 2017 Author Posted December 5, 2017 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]
Bailey Posted June 10, 2022 Posted June 10, 2022 (edited) Thank you. Something to note is that onGameEvent only works on a MP server, not SP. Edited June 10, 2022 by Bailey 1 DCS VoiceAttack Profiles | My Mods and Utilities on ED User Files | DiCE: DCS Integrated Countermeasure Editor DCS Update Witching Utility | DCS-ExportScripts for Stream Deck Community Github Library | Kiowa Integrated Overlays
Recommended Posts