moggel Posted June 27, 2023 Posted June 27, 2023 I wrote some logic that tracks hits (listening to S_EVENT_HIT event) for scoring purposes and that logic also records weapon type, mainly to filter out anything that's not bullets. But I later realized that when I run the script on a server the `weapon` field is missing from the event. Is that by design and, if so, why? Is there a way to work around that, or ensure the data gets sent? i7-3930K CPU @ 3.20GHz; 16Gb DDR3; GeForce GTX 1070; Windows 10; TM Warthog HOTAS
Death Merchant Posted July 24, 2023 Posted July 24, 2023 How are you trying to get the weapon info? Weapon = Event.weapon:getCategory() Should return the value of the category. https://wiki.hoggitworld.com/view/DCS_Class_Weapon Do you mind sharing your code? I have built something similar using S_EVENT_HIT to record kills. Sometimes you need to do some error handling such as: if Event.initiator.country ~= nil then [PC] ASUS X570E - Ryzen 9 5950X - RX 6900 XT - 32GB 3600Mhz Hornet, A-4E-C, Huey, Ka-50, Mi-8, F-15E, F-14 Join us on Death Dealers PvE server.
Zeagle Posted February 8, 2024 Posted February 8, 2024 It appears that S_EVENT_HIT returns a table with a key labelled "weapon". However, that key has a value of nil. It does return a key labelled "weapon_name" with a string value equal to the name of the weapon. Maybe @Grimes or whoever maintains the hoggit ref can update it. You can do a simple check on the "event" table with the Lua pairs function to see what is returned by the event. elseif event.id == world.event.S_EVENT_HIT then trigger.action.outText("S_EVENT_HIT\n", 10, true) for k,v in pairs(event) do trigger.action.outText(string.format("%s\n", k), 10, false) end
Grimes Posted February 8, 2024 Posted February 8, 2024 You need to check for its existence first. It is inconsistent in returning in MP, but it can return. In SP it is much more consistent. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Zeagle Posted February 9, 2024 Posted February 9, 2024 (edited) Thanks for the clarification. I do all my programming for MP. Your hoggit scripting reference is invaluable. Edited February 9, 2024 by Zeagle
Recommended Posts