Jump to content
Northup

[Solved] RemoteExec on player vehicle in trigger

Recommended Posts

Have a repair trigger. Trying to figure out how to remoteExec to client (driver) of the vehicle the repair script. 

Crude example:

// Set trigger condition and statements
        _repairTrigger setTriggerStatements 
        
        [
        //"{_x isKindOf 'LandVehicle' || _x isKindOf 'Helicopter' && speed _x < 1} count thisList > 0", // Condition (testing cond. below.)
        "{(_x isKindOf 'LandVehicle' || _x isKindOf 'Helicopter') && speed _x < 1 && damage _x > 0} count thisList > 0",// Condition
        "call {_handle = [(thisList select 0), thisTrigger] call NUP_fnc_repairVehicle;}", // Activation
        "" // Deactivation (empty)
        ];



works fine in local hosted, not dedicated, obviously.

Tried:
 

" [(thisList select 0), thisTrigger] remoteExec ['NUP_fnc_repairVehicle', owner _x] ;", // Activation

I'm just a tad stumped. Any takers?
 

Share this post


Link to post
Share on other sites

thisList is for preset condition (like BLUFOR PRESENT) what is yours?

 

_x is a magic variable only working in specific iterations  . So owner _x can't work.

You can try:
owner (thisList#0)  or just:  clientOwner

 

The fact is, if you create a trigger and you want to run a code just on one PC, just make it local, on every player (client) (makeGlobal false parameter)

 

 

Share this post


Link to post
Share on other sites
8 hours ago, pierremgi said:

thisList is for preset condition (like BLUFOR PRESENT) what is yours?


_repairTrigger setTriggerActivation ["ANY", "PRESENT", true];

 

 

8 hours ago, pierremgi said:

_x is a magic variable only working in specific iterations  . So owner _x can't work.

You can try:
owner (thisList#0)  or just:  clientOwner


Tried both of those. Neither seemed to work. 
 

8 hours ago, pierremgi said:

The fact is, if you create a trigger and you want to run a code just on one PC, just make it local, on every player (client) (makeGlobal false parameter)


The mission is MP.

NUP_fnc_repairVehicle:
https://pastebin.com/hAyCkrfL

Share this post


Link to post
Share on other sites
1 hour ago, Northup said:

The mission is MP.

 

That doesn't matter.

Your preset condition "Any" "present" will be true everywhere the trigger is known (server + client or server only).

So, the code will run... and:

- if on server only, you may have to remote execute some commands (depending on locality for arguments or effects).
For example spawning a vehicle (via createVehicle) is straight (no remote execution) because the command is GE.

On the other hand, a command like playSound , which is LE, needs to be remote executed for clients (players).

I can't say for your NUP_fnc_repairVehicle  functions, because I don't know which commands are involved here. If just a setDamage, no need for remote execution, the command is  GA GE!

But I guess there are other commands like hint (LE) or else.

 

- if for everyone, (not server only) , the code will run everywhere. The reason why sometimes people ask why there are so many vehicles spawned at the same place, even without any remote execution.

This option is fine for running code everywhere (without useless broadcast), but may cause other issues.

 

Remark:

- For edited triggers, you can choose between server only / or not,   options.

- For scripted triggers, you can script where you need (server, some clients, all clients, server + clients), and you can decide if the trigger is "local" or "global" (in confusing term of makeGlobal true or false)

this option (see createTrigger syntax) has no sense in editor, but makes sense in script, especially in MP scenario.

See this post:

 

 

Two questions:
1 Where your trigger is written ( server script, initPlayerLocal.sqf... ?)
2 what your  NUP_fnc_repairVehicle  is made of  (code)?

Share this post


Link to post
Share on other sites
41 minutes ago, pierremgi said:

 

That doesn't matter.

Your preset condition "Any" "present" will be true everywhere the trigger is known (server + client or server only).

So, the code will run... and:

- if on server only, you may have to remote execute some commands (depending on locality for arguments or effects).
For example spawning a vehicle (via createVehicle) is straight (no remote execution) because the command is GE.

On the other hand, a command like playSound , which is LE, needs to be remote executed for clients (players).

I can't say for your NUP_fnc_repairVehicle  functions, because I don't know which commands are involved here. If just a setDamage, no need for remote execution, the command is  GA GE!

But I guess there are other commands like hint (LE) or else.

Yeah, a little titletext and a few of sleeps basically, in addition to rearming, repairing and refueling. 

I tried the original and had no result. Assumed it wasn't firing on player. 

 

41 minutes ago, pierremgi said:

Two questions:
1 Where your trigger is written ( server script, initPlayerLocal.sqf... ?)
2 what your  NUP_fnc_repairVehicle  is made of  (code)?


1. The trigger itself is part of a composition spawned in with Larrow's Eden Comp Spawn, which is called in zoneSelect. In initSafezone, I snag and update the trigger, and call addVehicleServices, where I apply setTriggerActivation and setTriggerStatements posted above. It's a bit complex. InitSever>zoneSelect>LARs_fnc_spawnComp>initSafezone>addVehicleServices.

//get the repair trigger

    private _triggerList = _flag nearObjects ["EmptyDetector", 150];

    // Filter only triggers with names starting with "NUP_repairTrigger_"
    private _repairTriggers = _triggerList select {
        (toLower (name _x) find "nup_repairtrigger_") isEqualTo 0
    };

    // Call NUP_fnc_addVehicleServices for each repair trigger
    {
        private _repairTrigger = _x;
        
        // Ensure the trigger name matches
        private _triggerName = toLower (name _repairTrigger);
        if (_triggerName find "nup_repairtrigger_" isEqualTo 0) then {
            
            // Call NUP_fnc_addVehicleServices passing the side and the repair trigger
            [_repairTrigger] call NUP_fnc_addVehicleServices;
        };
    } forEach _repairTriggers;

2. I added a pastebin link to a previous post maybe 30 seconds before I got the notification for this.
https://pastebin.com/hAyCkrfL

Mission Link:
https://drive.google.com/file/d/14ETgJGqbO3z3HL6CC-n4hwb-cGThFv7E/view?usp=sharing

BTW Happy Thanksgiving @pierremgi.

Share this post


Link to post
Share on other sites

Ok, so I figured it out.

I wasn't paying close enough attention to the repair script.

All of the titleTexts and hints need to be remote exec'd, and the script can just be called. 

 

[["<t color='#00ff00' size='2'>Repairing Damage...</t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];

 

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

×