Jump to content

Not getting 'weapon' data for event S_EVENT_HIT on server?


Recommended Posts

Posted

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

  • 4 weeks later...
Posted

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.

  • 6 months later...
Posted

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

 

 

Posted (edited)

Thanks for the clarification. I do all my programming for MP.  

Your hoggit scripting reference is invaluable.

Edited by Zeagle

 

 

  • 1 year later...
Posted (edited)
On 2/8/2024 at 11:16 PM, Grimes said:

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. 

Encountered same problem that projectiles already don't exist as objects in MP by the time the hit event triggered. Only their runtimeIds are availiable. Which are not of a big use since there is no projectile birth event of something so you cant write them down somewhere. Using export to store and update the projectiles db seems like a bit of overkill to me.

Edited by eekz
  • Recently Browsing   0 members

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