Greetings all
I am having difficulty getting this script to work - attached to an always active entity and after a set amount of shots fired then do whatever - in this test destroy an entity. Engine loads script without errors but the entity disappears immediately after the first shot instead of the max_shots. I have run out of ideas within my limited coding knowledge. Help would be greatly appreciated. Thanks
local max_shots = 10
local shotsfired = 0
local shots = {}
function shots_fired_init(e)
shots = 0
end
function shots_fired_main(e)
if g_PlayerHealth > 0 and g_PlayerGunFired==0 then
shotsfired = 0
shots = 0
end
if g_PlayerHealth > 0 and g_PlayerGunFired==1 then
shotsfired = 1
shots = shots + 1
if shots > max_shots then
Destroy(1)
end
else
if shots > 0 then
shots = 0
end
end
end