Jump to content
Sign in to follow this  
Linderoth

Executing a script globally with an addaction

Recommended Posts

Hi there, I'm very noob with this.
I have searched on google, and I know that this topic has been answered before, but not exactly what I want. Or maybe yes, but as I say, i'm very noob, so I need that somebody explain me this better.
I have created a mission with some scripts. Let me show an example:
There is an object (suitcase) with this in the initbox

this addaction ["Conseguir la informacion","info.sqf"];

info.sqf

_marouanepos = createMarker ["marouanepos", position marouane];
_marouanepos SetMarkerType "hd_objective";
_marouanepos setMarkercolor "ColorRed";
_marouanepos setMarkerText "Marouane";

 
[] spawn {
		titleText ["Posicion de Marouane localizada","PLAIN DOWN"];
		titleFadeOut 10;
	};

Then, when I play the mission with my friends on our server, when I click the action "Conseguir la informacion", the marker appears on the map for all players, but not the text "Posicion de Marouane localizada", which it only appears to me.

 

I know that tthe problem is that I am the "caller" of the script and it executes locally. I know that I have to do another thing to the script executes globally. Obviously, I have the same problem with other scripts called from an addaction in the mission...

How can I do this??
Please answer, and remember that I'm still a noob, please be patient :) :) :)

Thank you!!

 

PS: English is not my first language, and this is a bit difficult for me, sorry if my english isn't good!

 

Share this post


Link to post
Share on other sites

As I said, I'm noob, so I asked for someone to explain me. I know that command, but i don't know or i don't understand how to use it.

Please, can anybody help? Thanks!! :) :)

Share this post


Link to post
Share on other sites


fnc_ttext = {

titleText ["Posicion de Marouane localizada","PLAIN DOWN"];

titleFadeOut 10;

};

[] remoteExec ["fnc_ttext"]

Share this post


Link to post
Share on other sites

Scripting commands differ in that some have global impact and some have local. E.g. setMarkerColor have global impact, so all players see the result, no matter which machine the script executes on. The command setMarkerColorLocal on the other hand only have local impact.

A few more examples: createVehicle is a command with global impact, and titleText only have local impact. So for each command you will nees to know.

You seem to have found out that you also need to know on which machine(s) a script is executed on. Many scripts are best to only execute on the server.

Remember that if you e.g. put a trigger in the editor, that trigger is then on all machines in the MP-game, as many triggers as there are players. So if you are five players and executes a createVehicle commnd in the trigger there will be five vehicles spawned. Solve that by only having the server execute the command, e.g. condition isServer, or a first line in the script that ends the script if it's not the server: if (!isServer) exitWith {};

  • Like 1

Share this post


Link to post
Share on other sites
fnc_ttext = {
  titleText ["Posicion de Marouane localizada","PLAIN DOWN"]; 
  titleFadeOut 10; 
 };

[] remoteExec ["fnc_ttext"]

Hi! Thanks for the answer.

But it doesn't work :(. The marker is created, but the text is only shown for me. My mates can't see it.

I paste the whole script:

_marouanepos = createMarker ["marouanepos", position marouane];
_marouanepos SetMarkerType "hd_objective";
_marouanepos setMarkercolor "ColorRed";
_marouanepos setMarkerText "Marouane";

fnc_ttext = {
			titleText ["Posicion de Marouane localizada","PLAIN DOWN"];
			titleFadeOut 10;
		};
	
[] remoteExec ["fnc_ttext"];
sleep 5;
//{"Posicion de Marouane localizada","PLAIN DOWN"} remoteExec ["titletext"]; //not working either

_tsk2ok = ["task2", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
_mt3 = getpos marouane;
_tsk3 = ["task3",[west],["Marouane esta escondido esperando","Habla con Marouane"],_mt3,"ASSIGNED",5,true,true,""] call BIS_fnc_setTask;

Please help me!

 

 

#engima Thanks for your comments!! Yes, I noticed that, the scripts called from triggers are executed globally! It would be a solution for my problem, but I want to learn to do it "right".

I had seen "if (!isServer) exitWhit {}" in other scripts, I wondered what was that for, finally you showed me! Thanks!

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  

×