Jump to content

Player "skill" not triggering S_EVENT_PLAYER_ENTER_UNIT or S_EVENT_BIRTH events


Recommended Posts

Posted (edited)

I have a simple event handler loaded in MISSION START / do script file to load a menu , using S_EVENT_PLAYER_ENTER_UNIT  or S_EVENT_BIRTH  (tested with both)

If the mission contains only one flyable aircraft with its skill set to "Player", neither of those events triggers. If the skill is changed to "client" or if another flyable is added (as "player" or "client") everything works as it should.

Is this a known issue? Any workaround to be able to use "player" with only one flyable a/c in the mission?

 

Edit: test mission added... Just flip the su-25t skills between "player" and "client" and observe the events that trigger

Quote

TEST  = {}
TEST.eventHandler = {}
trigger.action.outText( 'Test Script loaded', 2 )
--############################################################################################################################################
function TEST.eventHandler:onEvent(_eventDCS)

    if _eventDCS == nil or _eventDCS.initiator == nil then
        return true
    end

    local status, err = pcall(function(_event)

        trigger.action.outText(_event.id,30)

        if _event.id == world.event.S_EVENT_BIRTH  then  
            trigger.action.outText("Birth",30)
        elseif _event.id == world.event.S_EVENT_PLAYER_ENTER_UNIT  then  
            trigger.action.outText("Enter",30)    
        end 

        return true
    end, _eventDCS)

    if (not status) then
        env.error(string.format(" Error while handling event %s", err),false)
        trigger.action.outText( string.format("Error while handling event %s", err), 30 )
    end
end
--############################################################################################################################################

world.addEventHandler(TEST.eventHandler)

 

test.miz

Edited by Draken35
Posted

With Player Unit, you are already in control at start. Only spawning in a client slot should trigger S_EVENT_PLAYER_ENTER_UNIT (detecting player taking control of a unit).

S_EVENT_BIRTH works for any unit spawning.

Posted
11 minutes ago, Draken35 said:

So, you are saying that this behavior is WAD (Working As Designed)?  If so, it leaves a huge gap in capability when starting as "player". 

It depends on what you need. In your example "Mission start" seems to be enough as event (as Player exists at start).

If you want S_EVENT_PLAYER_ENTER_UNIT to be detected with a Player unit, you need to late activate it (2 seconds for example), so "control taken" is detected during mission.

Posted

Not sure I follow you (looooong day, sorry)... I'm loading the event handler in Mission Start already and S_EVENT_PLAYER_ENTER_UNIT  is definitely not triggering when using player. I'm working on a generic script that loads a menu and perform some initializations based in the player/client unit which are used by other events (SHOT, hit, etc) ... Of course, manually launching that initialization on a Once trigger with a delay of  second or two and using a tailored  method for it would work for me. I still think that ED left a gap here... I really appreciated you taking the time to answer!

Posted
29 minutes ago, Draken35 said:

Not sure I follow you (looooong day, sorry)... I'm loading the event handler in Mission Start already and S_EVENT_PLAYER_ENTER_UNIT  is definitely not triggering when using player. I'm working on a generic script that loads a menu and perform some initializations based in the player/client unit which are used by other events (SHOT, hit, etc) ... Of course, manually launching that initialization on a Once trigger with a delay of  second or two and using a tailored  method for it would work for me. I still think that ED left a gap here... I really appreciated you taking the time to answer!

I mean S_EVENT_PLAYER_ENTER_UNIT occures at the moment a player takes control of a unit. If you start as active Player there is no event (no control taken during mission because you have control at start already).

Only being a late activated Player (for example 2 sec after start) or entering a client slot triggers this event.

If you want to be able to refer to Player Unit, as it is done with 'initiator' of S_EVENT_PLAYER_ENTER_UNIT, you can use for example : PlayerUnit = world.getPlayer(). It will return Player's Unit that you can use for any other event. (ex : during S_EVENT_SHOT, if initiator == PlayerUnit then ....)

  • Recently Browsing   0 members

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