This post has been marked by the post author as the answer.
g_Entity is the main global list of values for entities, e_Entity[e].obj gives you the object Id value.
A quick an dirty way of reacting to player gunfire is to use the global variable g_PlayerGunFired like this:
local U = require "scriptbank\\utillib"
local function playerHeard( e, dist )
local Ent = g_Entity[ e ]
local ppx, ppz = g_PlayerPosX, g_PlayerPosZ
return U.CloserThan( Ent.x, 0, Ent.z, ppx, 0, ppz, dist ) or
( g_PlayerGunFired == 1 and
U.CloserThan( Ent.x, 0, Ent.z, ppx, 0, ppz, 1000 ) )
end
The dist value will cause this function to return true if the player is closer than that value or it will return true if the player fires and the entity is within 1000 units. Obviously you could tweak the 1000 part to suit.
To use:
if playerHeard( e, 100 ) then
--- do whatever ---
end
So in this example if the player is within 100 units or within 1000 and firing the weapon then the '-- do whatever --' part will be triggered.
Been there, done that, got all the T-Shirts!