Jump to content

Recommended Posts

Hello. I am doing a multiplayer mission where a record of destroyed (lost) aircraft is kept. For this counter, I need a check at:

Crash - it hit the ground (Client)

Pilot dead - The pilot died (Client)

Pilot ejected - The pilot ejected (Client)

 

How to do it through the lua script?

 

 

I fulfill the condition for the destruction of the plane with the destruction triggers. But so that it does not work when changing roles, I set a condition: the altitude of the object is more than 5 meters. But then the trigger does not work if the player crashed himself (hit the ground).

Edited by Hollander
Link to post
Share on other sites

what is wrong here?

 

 

 

Handler = {}

function Handler:onEvent(event)

if event.id == world.event.S_EVENT_CRASH and event.initiator == Unit.getByName('RED1') then

return true

else

return false

end

end

world.addEventHandler(Handler)

Link to post
Share on other sites

Only clients/players return a value (string) for getPlayerName(), so you could try something like this:

 

function Handler:onEvent(event)
if event.id == world.event.S_EVENT_CRASH then		
	local ei = event.initiator
	if ei == nil then			
		return
	end
	local playerName = ei:getPlayerName()		
	-- ...
	if playerName ~= nil then 
		-- ...
	end
	-- ...
end
end

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...