Jump to content
Rosso777

Is player in a specific vehicle?

Recommended Posts

Goal: To ONLY activate the SIDE channel when a player is inside a comms truck (specifically THIS vehicle: "B_GEN_Offroad_01_comms_F"). If they're not inside the vehicle, only the DIRECT channel is active.

 

Attempt:

In the mission file's init.sqf, I have the following:

 

 [] spawn
    {
    if (typeOf vehicle player == "B_GEN_Offroad_01_comms_F") then 
        {
        while {true} do
            {
            1 enableChannel true;
            };
        sleep 2;
        };
    };

 

But no matter how I reconfigure this, I cannot seem to get it to work, even though it seems so simple. Any insight is greatly appreciated!

Share this post


Link to post
Share on other sites

You haven't looped your script before the condition, so it'll run once when executed and that's it. But, even if it runs when the player is in the vehicle it'll loop the enableChannel command every frame, forever (while {true} do will never return false). You're better off using a GetInMan event handler though:

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetInMan

 

Then just run the enableChannel command and wait until the player isn't in the vehicle and disable it again. 

Share this post


Link to post
Share on other sites
2 hours ago, beno_83au said:

You haven't looped your script before the condition, so it'll run once when executed and that's it. But, even if it runs when the player is in the vehicle it'll loop the enableChannel command every frame, forever (while {true} do will never return false). You're better off using a GetInMan event handler though:

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetInMan

 

Then just run the enableChannel command and wait until the player isn't in the vehicle and disable it again. 

 

Interesting. Is this possible with persistent vehicles also?

Share this post


Link to post
Share on other sites

Yes. The event handler is added to the player and will activate any time they enter a vehicle. There is another event handler, https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn, that would be used if needing to add it to vehicles themselves. But your case sounds like it'll be best to use getInMan.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×