Jump to content
Sign in to follow this  
speeder

Createvehile MASH in MP

Recommended Posts

The general idea is to have a medic unit being able to "build" a MASH in Multiplayer.

However, as this is my first attemt to create in MP I'm having some difficulties.

As the script is now, it runs, but only the one playing the medic can see the MASH getting build. It seems like the createvehicle command isn't passed over the network.

I've been messing around witht hes for some days now, and I'd appreciate some help in finishing the script.

As said I'm a bit of a novice in making scripts run on server/local machines, so please explain it well to me, or even better, ajust and repost my code so that it may work.

I'd really appreciate the help.

setupmash.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0;

_id = _this select 2;

_unit removeAction _id;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 1;

_mash = createVehicle ["MASH",[0,0,0], [], 0, "NONE"];

_mash setDir ((direction _unit) -180);

_mash setdammage 0.8;

sleep 2;

_mash setPos (_unit modelToWorld [0,6,((position _unit) select 2)]);

_mash setdammage 0.5;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 2;

_mash setdammage 0.2;

sleep 2;

_mash setdammage 0;

sleep 2;

_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];

takedownmash.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0;

_id = _this select 2;

_mash = _this select 3;

_unit removeAction _id;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 1;

_mash setdammage 0.2;

sleep 2;

_mash setdammage 0.5;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 2;

_mash setdammage 0.8;

sleep 2;

_mash setdammage 1;

sleep 2;

deleteVehicle _mash;

sleep 2;

_unit addAction ["Deploy MASH", "setupmash.sqf","",1,false];

medics INIT line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addAction ["Deploy MASH","setupmash.sqf","",1,false]

Share this post


Link to post
Share on other sites

Im gonna go with the "setpos" command you have in the setup script. I have a feeling MASH is one of the objects it cannot move in MP.

Share this post


Link to post
Share on other sites

But the medic can see it - it's created moved infront of him, but no other playrs can see it.

Share this post


Link to post
Share on other sites

What Shuko is saying is that it is created on all clients fine... it's just that only the person building it sees it because on all the other clients, it is at positon [0,0,0].

Reason: setPos is bugged in MP

Share this post


Link to post
Share on other sites
So what would my solution be??

createVehicle it in the spot where you want it to be when it's fully setup.

Share this post


Link to post
Share on other sites

Btw, I dont think setDir works in MP either. Not that its breaking the code.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0;

_id = _this select 2;

_unit removeAction _id;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

_mash = createVehicle ["MASH",(position _unit), [], 0, "NONE"];

_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];

So you would suggest it like this? or do I have to make a select 0,1,2 on the post _unit?

Share this post


Link to post
Share on other sites
So you would suggest it like this? or do I have to make a select 0,1,2 on the post _unit?

Try that, selecting x,y,z isnt needed unless you need to move it abit incase its created right onto of the player and not next to him.

Share this post


Link to post
Share on other sites

you guys are the best. thanks for the help. the setpos thingy sorted out the problem I had.

For future reference to people who search for this I will repost the code I got working:

setupmash.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0;

_id = _this select 2;

_unit removeAction _id;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

_mash = createVehicle ["MASH",(position _unit), [], 0, "NONE"];

sleep 10;

_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];

takedownmash.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0;

_id = _this select 2;

_mash = _this select 3;

_unit removeAction _id;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 1;

_mash setdammage 0.2;

sleep 2;

_mash setdammage 0.5;

_unit playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 2;

_mash setdammage 0.8;

sleep 2;

_mash setdammage 1;

sleep 2;

deleteVehicle _mash;

sleep 2;

_unit addAction ["Deploy MASH", "setupmash.sqf","",1,false];

Unit's initline:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addAction ["Deploy MASH","setupmash.sqf","",1,false]

Share this post


Link to post
Share on other sites

when i use this and preview mission in editor i get an error screen with "Invalid number in expression", what do you think it could be from?

Share this post


Link to post
Share on other sites

Check out x_mash.sqf in Domination. Has a good example on how to do it. Deals with everything you have afaik: Setting up with direction, removal action, multiplayer support etc.

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  

×