Jump to content
Sign in to follow this  
Wozny

Executing simple commands in MP

Recommended Posts

So - my main problem creating any kind of MP Missions is that my triggers or simple scripts just work different on MP. For example: Lets say that Unit1 and Unit2 are the players. All i want to do is spawn them on the airport, let them take the weapons and all the stuff and then, when they are ready, let leader choose the action on whiteboard object which will teleport them to the car on different part of the map. I place both units on the airport, car somewhere else, make them as playable, then put somewhere whiteboard object. In the init tab of the whiteboard i put:

 

this addAction ["Teleport", {_null = execVM "TP1.sqf"};


Then in my TP1.sqf i put only something like that:

Unit1 moveInCargo Car1;
Unit2 moveInCargo Car2;
skipTime -2;

And when i try to test it (On SP or alone on local server) it works great. Then, when i play it with my friend it only teleport the player, who has interacted with the whiteboard. I guess im just stupid, but i can't get my mates to help me testing every little thing i create, so im looking for some help.

Share this post


Link to post
Share on other sites

Well, that is the IMHO the most complicated part of programming in Arma. What is executed where and when.

 

https://community.bistudio.com/wiki/remoteExec

 

the following code is from https://community.bistudio.com/wiki/addAction .

 

Read that carefully and if you have further questions fire it up :-)

 

if (isDedicated) then { 
	_obj = "some_obj_class" createVehicle [1234, 1234, 0]; 
	[_obj, ["Greetings!", {hint "Hello!"}]] remoteExec ["addAction", -2, _obj]; 
	};

 

  • Thanks 1

Share this post


Link to post
Share on other sites

That pretty much explains everything, but i'm worried about that little piece:
 

Quote

While any function can be used, only commands and functions defined in CfgRemoteExec will be executed.

As far as I understand it - every little command i want to execute globally has to be defined in Description.ext? That sounds a little bit goofy and awkward. Even when I create simple mission like go from A to B and destroy C in the meantime, there are tons of functions and commands

And at the end, is there any tutorial that sums up where and how should I execute specified commands, or i just have to find it out by myself?

Share this post


Link to post
Share on other sites

Hm, you can use all script commands, write own functions and whatever in the sqf file you opened with the addAction command. So no worries about that.

Normally you find in the upper section in the BI Biki some Icons and if you hover over these icons you find out if the command is global or local.

 

https://community.bistudio.com/wiki/createVehicle

 

directly under CreateVehicle you find two icons. The first tells you since when this command is available and the second tells you that the command is global and the effects are global. That means if you use the create vehicle command on any computer whether its the server or any player computer the vehicle you created is available on every computer.

 

https://community.bistudio.com/wiki/addAction

Here you find that the effects of that command is local but the arguments are not necessary local.

Explanation:
1. You create an addAction with a simple hint for player p1. Player 1 use the addAction and get a hint saying something. Player 2 (and all other players even the server) is not seeing the hint.

2. You create an addAction with a createVehicle inside. Player 1 use the addAction and create the vehice which is also visible to Player 2 (and of course all other players including the server)

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, commanderx said:

Here you find that the effects of that command is local but the arguments are not necessary local.

Explanation:
1. You create an addAction with a simple hint for player p1. Player 1 use the addAction and get a hint saying something. Player 2 (and all other players even the server) is not seeing the hint.

And then, if I want this hint to be visible for everyone, i have to do it the long way by remoteExec, right? 

Share this post


Link to post
Share on other sites

Yes, but the hint is somewhat easy to create. The following executes a hint on all computers except the server (where a hint is obviously not necessary :D )

 

"hello" remoteExec ["hint", -2];

 

The first steps are not easy but if you understand what is where and why executed it gets easier :-)

Share this post


Link to post
Share on other sites

Thank you very much, that's huge.

And last one thing - can I just put that into a trigger, or do I have to create a .sqf file, then make it like:

if (isDedicated) then {
"hello" remoteExec ["hint", -2];}
;

and then execute that file?

Share this post


Link to post
Share on other sites

no, just put this inside the trigger.

 

"hello" remoteExec ["hint", -2];}

 

Whereever and whenever this code is executed it will send the hint command to all computers except the server.

 

EDIT: The "-2" in the code example means the following. If you would like to execute something on the server you would write just "2" (without the minus). Because "2" is always the server! The Minus in Front of the 2 means that it will be executed everywhere except the the server.

  • Like 1
  • Thanks 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
Sign in to follow this  

×