Jump to content
Sign in to follow this  
daza

A MP script host client woe...

Recommended Posts

I need some advice about the last hurdle of getting my mission completed.

Its a MP TvT where the West side has to rescue and move 2 VIP civilians to evac point where they are to board a chopper and mission ends. The other team has to kill the VIPs.

My problem is the vip units are created via scripts, through a addaction at a point near a certain house building. And in that script another addaction is added to the newly created unit which allows another player to make the vip to join them (incase the original player acting as bodyguard is killed).

In the editor when testing this works fine, if u create a VIP, and try to create another VIP it will say that unit is already placed into Custody. And if i switch to a playable AI i can make the VIP leave the other unit and join my group. But in Multiplayer it doesnt work, only the person who activates the create vip script via addaction gets to see the extra addaction on newly created VIP.

Also another player can create the same VIP. (the remove addaction doesnt work anymore- it did when i had this line in trigger..

knock = player addaction ["Call out VIP","vip1.sqf"];

Now im using an object called dor1 that and in my script (see spoiler link below) i have the same line as used before but with dor1 replacing player and it now it doesnt remove that addaction...why is that?

knock = dor1 addaction ["Call out VIP","vip1.sqf"];

So my work around was in the script (see below) that if that unit is already created it wont create a new one. Which works in the editor but not in MP.

My script for one of the VIPs;

dor1 removeaction knock;

deleteVehicle trig1;

playSound "knocking_door";

if (alive vpciv1) exitwith

{hint "VIP1 Has already been taken into custody."};

_group = group player;

vpciv1 = _group createUnit ["sportswoman1", getpos player, [], 0, "form"];

dostop vpciv1;

vpciv1 dowatch player;

vpl1=true;

publicvariable ="vpl1";

tm1=vpciv1 addaction ["Follow me","foll1.sqf"];

All of the units on the west side is ungrouped.

..im just thinking.. do i need to put something like this at the start of the VIP script... if (!isServer) exitWith {};

Obviously the client and host seems to be in two minds. So how to do i synch this so it works like it does in the editor?

Thanks for any input and help given :)

Share this post


Link to post
Share on other sites

Using an action via action menu, the assigned scripts are running only on my own machine. So the other machines won't get the then added action to capture the VIP.

If you want the action to the VIP being available on all machines, write

<vipUnit> setVehicleInit <addaction statement>;
processInitCommands;

to dynamically put the addaction command into the vip units init line (what then will be executed globally).

Share this post


Link to post
Share on other sites

What syntax would I use for SetVehicleInit if the string has a string in it?

Would it be:

unit setVehicleInit "[unit] exec "nameofscript.sqs""

??

Share this post


Link to post
Share on other sites

Use single quotes or double double quotes in that case:

unit setVehicleInit "[unit] exec 'nameofscript.sqs'"

or

unit setVehicleInit "[unit] exec ""nameofscript.sqs"""

Both work.

Share this post


Link to post
Share on other sites
Using an action via action menu, the assigned scripts are running only on my own machine. So the other machines won't get the then added action to capture the VIP.

If you want the action to the VIP being available on all machines, write

<vipUnit> setVehicleInit <addaction statement>;
processInitCommands;

to dynamically put the addaction command into the vip units init line (what then will be executed globally).

Thankyou guys for your replies. But it seems the addaction doesnt want to work when being used with setvehicleinit command.

this is the line im using (different mission).

foot1 setVehicleInit "tk1=foot1 addaction ['Examine Tracks','exam1.sqf']";

i've tried it with just

foot1 setVehicleInit "foot1 addaction ['Examine Tracks','exam1.sqf']";

Why doesn't this work? if i place that code on an objects init line within the editor it works. But from a script it wont...

Share this post


Link to post
Share on other sites

Are you running processInitCommands; afterwards?

edit:

According to the Biki, processInitCommands is local, perhaps it needs to be run on all clients?

setVehicleInit however is global.

This is confusing me just thinking about it, I might jump in the editor and take a look.

edit2: ignore this post, I was incorrect.

Edited by bhaz

Share this post


Link to post
Share on other sites
Are you running processInitCommands; afterwards?

edit:

According to the Biki, processInitCommands is local, perhaps it needs to be run on all clients?

setVehicleInit however is global.

yes i am using processInitCommands after it.

I did a test and just had hint "This is a test" inside the setvehicleInit and that worked from the script. Just doesnt seem to like the addaction line even though it works fine if inserted into init of a object in the editor.

Share this post


Link to post
Share on other sites

I just made a quick test mission, using an empty Ural named truck and a radio command trigger, activation set as null = execVM "processInit.sqf".

processInit.sqf:

if (!isServer) exitWith {};

// SERVER ONLY CODE
truck setVehicleInit "this addAction ['test','test.sqf']";
processInitCommands;

Ran it on a dedicated server, and the test action was created and working on the client. The only difference I can see between our two lines is that I used 'this' to refer to the object instead of its global name?

Edited by bhaz

Share this post


Link to post
Share on other sites
I just made a quick test mission, using an empty Ural named truck and a radio command trigger, activation set as null = execVM "processInit.sqf".

processInit.sqf:

if (!isServer) exitWith {};

// SERVER ONLY CODE
truck setVehicleInit "this addAction ['test','test.sqf']";
processInitCommands;

Ran it on a dedicated server, and the test action was created and working on the client. The only difference I can see between our two lines is that I used 'this' to refer to the object instead of its global name?

Bingo! that did the trick, changing it to "this addaction..."

Thanks for that bhaz!

Btw wouldnt the processInitCommand broadcast to all machines on a server without the need to have the if (!isServer) exitwith {}; line?

Share this post


Link to post
Share on other sites

Seems that way, but since setVehicleInit and processInitCommands seem to be broadcasted over the network, I figured it would be cleaner just running the script once on the server rather than on every client.

Share this post


Link to post
Share on other sites

If you want it to run only on one machine anyway, what reason is there to set the init line and then processing it, rather than just executing the content normally?

Share this post


Link to post
Share on other sites
If you want it to run only on one machine anyway, what reason is there to set the init line and then processing it, rather than just executing the content normally?

if (!isServer) exitWith {};

// SERVER ONLY CODE
truck setVehicleInit "this addAction ['test','test.sqf']";
processInitCommands;

What I meant was, that this code will only run on one machine (the server), yet everything inside the setVehicleInit will end up running on all players in the game, since the server will broadcast it out to all players, including those that JIP later on. If you only want the addAction on one machine, this is exactly what not to do.

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  

×