Jump to content
iV - Ghost

CreateVehicle & addAction by using addAction on server

Recommended Posts

I wanna create a wreck (Land_Wreck_Heli_Attack_01_F) on a random position and add them a addAction.

All by using a addAction on a server. Ctreate the wreck works fine and adding a addAction only in a local situation.

But on my server the addAction isn't there.

 

I have tried some ways. My last looks like this:

[[], {

    private ["_taskID", "_taskStateX", "_secondMarker"];

    _taskID = "AgiaM_T4";
    _taskStateX = [_taskID] call BIS_fnc_taskState;
  
    if (_taskStateX != "Succeeded") then {
      
        // CREATE AREA MARKER
        _secondMarker = createMarker ["Wreck_AgiaM_1", [2954, 5990]];
        _secondMarker setMarkerSize [100, 100];
        _secondMarker setMarkerShape "ELLIPSE";
        _secondMarker setMarkerBrush "FDiagonal";
        _secondMarker setMarkerColor "colorOPFOR";
			
    };
		
		
    // CREATE WRECK AND ADDACTION
    private ["_wreck", "_wreckArea"];
		
    _wreck = "Land_Wreck_Heli_Attack_01_F";
    _wreckArea = getMarkerPos "Wreck_AgiaM_1";
		
		
    // RUN ON DEDICATED SERVER OR PLAYER HOST
    if (isServer) then {
      
        // CREATE WRECK
        _wreck = createVehicle [_wreck, _wreckArea, [], 100, "CAN_COLLIDE"];
        _wreck setDir (random 360);
	
    };
		
  
    // ADD ADDACTION
    {
        if (typeOf _x isEqualTo _wreck && _x inArea "Wreck_AgiaM_1") then {
			
            _x addAction [
		
                localize "STR_iV_TakeBlackbox",                              // Title
                "scripts\misc\TakeBlackbox1_AgiaM.sqf",                      // Script
                nil,                                                         // Arguments
                2.5,                                                         // Priority
                true,                                                        // showWindow
                true,                                                        // hideOnUse
                "",                                                          // Shortcut
                "true",                                                      // Condition
                2.5,                                                         // Radius
                false                                                        // Unconscious
			
            ];
				
        };
		
    } forEach vehicles;
		
    sleep 3;
		
}] remoteExec ["spawn", 0, true];

 

Share this post


Link to post
Share on other sites

At least, your "Land_Wreck_Heli_Attack_01_F" is not a vehicle (recognized as is by vehicles command). It's an object that you can detect by:

 (getMarkerPos "Wreck_AgiaM_1") nearObjects ["wreck_base",100]

 

If you want a vehicle you need to place a true helo and setDamage [1,false] on it. (these wrecks are OK for vehicles).

 

You don't need to remoteExec a task. All is parameter inside bis_fnc_setTask.

Share this post


Link to post
Share on other sites

"Land_Wreck_Heli_Attack_01_F" should it be. But thx for the info.

And with the remoteExec. You've telling me that but if I don't remoteExec them I don't get my notification.

 

But my problem is adding the addAction on the wreck because the script is local (addAction).

But I think I must bring them all to every client and the server. But I'm not sure how.

 

 

2 hours ago, pierremgi said:

It's an object that you can't detect by:

 (getMarkerPos "Wreck_AgiaM_1") nearObjects ["wreck_base",100]

I can or I can't detect by this code?

 

 

 

This was another way I've tested:

// ADD ADDACTION
_wreckObject = getMarkerPos "Wreck_Girna_1" nearestObject "Land_Wreck_Heli_Attack_01_F";
_wreckObject addAction [localize "STR_iV_TakeBlackbox", "scripts\misc\TakeBlackbox1_Girna.sqf"];

 

Share this post


Link to post
Share on other sites
2 hours ago, iV - Ghost said:

And with the remoteExec. You've telling me that but if I don't remoteExec them I don't get my notification.

 

But my problem is adding the addAction on the wreck because the script is local (addAction).

But I think I must bring them all to every client and the server. But I'm not sure how.

 

 

I can or I can't detect by this code?

 

It's fine to addAction on the wreck but the code must be read by any player. So, yes remoteExec it. If not, as you create the vehicle on server, you just add the addAction on server. You need to make difference between an edited vehicle with its init field which will run on every player at start, and a spawned vehicle/object which will be displayed on every PC but not the addAction.

If you read in BIKI, addAction is AG EL, that means, the argument (wreck) can be anywhere, but the addAction (then the code) will be available locally (if player exists).

The reason why I didn't mentioned the addAction on my previous message.

If you run the code, it will be locally. That means you can have to to remoteExec it on all PC also, if it's the intended behavior, regardless of the first remoteExec (for the addAction command). I don't know what is your script, but it must be compatible with the commands also.

For example, say you remoteExec an addAction everywhere (forget the fact a dedicated server can't run it, that doesn't generate error).

Now you want:

- say hello at everyone: you need to remoteExec the hint "hello" inside the code, as you did for the addAction itself;

- set a score to the player: use addScore, but you need to remoteExec it from server (as addScore must run on server);

- push a vehicle (not wrecked) with setVelocity (AL EG command). To be effective, this code must run on the PC where the vehicle is. If spawned on server, remoteExec on server.   But... if vehicle is owned by a player (someone jumping into it as driver), you need to remoteExec on the PC of the owner.

 

You should look at twice the bis_fnc_setTask . I often use it on server and it's fine. You don't need taskCreate, just this function. You have all you need at once.

 

And yes. can't was a typo, read can, of course.

Share this post


Link to post
Share on other sites
On 12/01/2018 at 3:12 AM, iV - Ghost said:

So it's possible to use remoteExec inside remoteExec?

 

You remoteExec the addAction (the fact the players can see the menu and call the code), then the code is local. So, yes, you can (and sometimes have to) remoteExec the code itself, or more exactly, the part of the code which have to be remote executed in case of many commands/functions.

Always pay a sharp attention for Arguments and Effects, Local or Global , and the comments also.

Roughly:

 

- don't remoteExec AG EG commands/functions, except for SE to be remote on server; For example, it's wrong and network consuming to remote exec setDamage or addBackPackGlobal, but mandatory to remote exec on server addScore, or even enableSimulationGlobal !

 

-  remote exec AL EG, on the local PC for any code application on objects not belonging to the caller (the guy who fired the addAction). That's mandatory for all BI commands where it's specified: The vehicle must be local to the computer where command is executed. (see setFuel, but I experienced that also for setVelocity). But It's useless to remote exec setUnconscious;

 

- you can remoteExec as you like, everywhere or on specific PC, all the EL commands/functions (like setFace or hideObject).

 

NOTE: AG EG are your best friends most of the time. You can apply them without remote execution, in SP MP sessions. Some of them needs the be fired on server,as for a unique reference (score) or for localization consideration (simulation).

BI added some AG EG  "global" version of some old commands like addBackPack. Use them.

These AG EG commands are fine in addAction because the code run once, from the PC which fired the code.

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot. Now it works. The code is smaller now too.

I remoteExec the whole file to every client and server and inside the file I'm using this:

 

if (isServer) then {
	
    // VARIABLES
    private ["_wreck"];
		
		
    // CREATE WRECK
    _wreck = createVehicle ["Land_Wreck_Heli_Attack_01_F", getMarkerPos "Wreck_Girna_1", [], 160, "CAN_COLLIDE"];
    _wreck setDir (random 360);
		
		
    // ADD ADDACTION
    [_wreck, [localize "STR_iV_TakeBlackbox", "scripts\misc\TakeBlackbox1_Girna.sqf", nil, 2, true, true, "", "true", 3.5, false]] remoteExec ["addAction", -2, true];
		
};

 

Only my localization "Recover blackbox" is now in english and not in german.

But this isn't very worse. I can live with.

 

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

×