Jump to content
Diaverso Carrasco

How can I make an addAction run for everyone?

Recommended Posts

I am trying to make an addAction call a script and display the script for everyone on the server.

I am trying with these 2 scripts:

0 = this addAction ["Vehiculoos Quietos", "Examenes\AT\mision1.sqf"];
[monitor,["Vehiculos en movimiento2","Examenes\AT\mision1.sqf"]] remoteExec ['addAction',0,monitor];

When you click to run the script, it only runs the person who gives it, instead of everyone.

This is what it contains mision1.sqf

hintSilent parseText format["<t size='1' font='Zeppelin33' color='#ff0000'>Cargando Examen Vehiculos quietos!</t>"];
sleep 2;
hint "Puedes utilizar 1 misil por Vehiculo. Tienes 4 Vehiculos";
sleep 5;
hint "Examen empieza en 5s";
sleep 2;
hint "Examen empieza en 3s";
sleep 1;
hint "Examen empieza en 2s";
sleep 1;
hint "Examen empieza en 1s";
sleep 1;
hintSilent parseText format["<t size='1' font='Zeppelin33' color='#ff0000'>COMIENZA EL EXAMEN!</t>"];
sleep 1;
_veh1 = "rhs_uaz_open_vmf" createVehicle [9716.91,4424.07,0];
_veh2 = "rhs_uaz_vmf" createVehicle [9856.53,4259.5,0];
_veh3 = "rhs_tigr_vmf" createVehicle [9791.37,4427.55,1.90735e-006];
_veh4 = "rhs_gaz66_ammo_vmf" createVehicle [9760.5,4256.07,0];
sleep 80;

Is there a way to make it work?

Thank you

Share this post


Link to post
Share on other sites

trust me, u dont like to send ur script to all clients because it would run createVehicle there and you would have 4 created vehicles for every connected client. on a 10 player session you would create 40 vehicles this way.

 

the easiest way is to execute the script on the client which started the addAction and use remoteExec as described in wiki example 2 for every hint message of your script.

Share this post


Link to post
Share on other sites

this addAction ["Vehiculoos Quietos", "Examenes\AT\mision1.sqf"];

is workable into an init field of an object (vehicle, unit, crate...) because this applies to the edited object.

On the other hand, this code runs everywhere as any init field of edited objects. So at this statge, you don't need to remoteExec (broadcast) something. That's an edited object, not a spawned one from server.

You code sqf will run on the caller PC (player who triggers action) , and the caller PC only. Here you need to remoteExec what is local (effect) for making it global (public).

The addAction is scheduled (so like execVM or spawn). Good point.

 

The problem with an sqf is that's a whole code. In MP, several lines should be public (hint shared for example), but some other not (createVehicle will create your vehicle globally on each PC if you remoteExec the code, i.e. you'll obtain vehicle X nbr of players (and server possibly). Big mess and vehicle crash guaranted

 

So, let the code local. You can create vehicle on a client PC. That works, this vehicle is shared and, if not used by player as driver, the server will be owner finally.

But, usually, for performance, this kind of spawning vehicle/unit is remoteExecuted to server.

For your hint, say you want to share the info, you can remoteExec everywhere.

 

Now, the sqf code should look like:

parseText format["<t size='1' font='Zeppelin33' color='#ff0000'>Cargando Examen Vehiculos quietos!</t>"] remoteExec ["hintSilent",0];
uiSleep 2;
"Puedes utilizar 1 misil por Vehiculo. Tienes 4 Vehiculos" remoteExec ["hint",0];
uiSleep 5;
"Examen empieza en 5s" remoteExec ["hint",0];
uiSleep 2;
"Examen empieza en 3s" remoteExec ["hint",0];
uiSleep 1;
"Examen empieza en 2s" remoteExec ["hint",0];
uiSleep 1;
"Examen empieza en 1s" remoteExec ["hint",0];
uiSleep 1;
parsetext format["<t size='1' font='Zeppelin33' color='#ff0000'>COMIENZA EL EXAMEN!</t>"] remoteExec ["hintSilent",0];
uiSleep 1;
private _veh1 = ["rhs_uaz_open_vmf", [9716.91,4424.07,0]] remoteExec ["createVehicle",2];  comment "remote execution not mandatory";
private _veh2 = "rhs_uaz_vmf" createVehicle [9856.53,4259.5,0];
private _veh3 = "rhs_tigr_vmf" createVehicle [9791.37,4427.55,0];
private _veh4 = "rhs_gaz66_ammo_vmf" createVehicle [9760.5,4256.07,0];

 

sleep 80 is useless (at the end of a scheduled code). If you want to cooldown the addAction you must read all subtleties  of addAction and parameters.

 

 

 

 

  • Like 3

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

×