Jump to content
Bode_DHSF

Scripts work in SP but not in MP

Recommended Posts

I have some units/soldiers doing push-ups & some standing at ease.. it works fine in single player but as soon as I export to Multiplayer they all default to original stance.. I was told it was a locality issue but I don’t how to address this.. all the ppl who responded only told me what the issue was then sent me links to the scripting forum which doesn’t help someone that’s new to scripting.. it’s good information but u still need some sort of understanding to even read it.. I have a simple script & need help finding a simple solution.. I would appreciate some help & not just a professional scripter telling me what I did wrong.. sorry if I sound like a dick but all I get from the scripting discord is an elitist attitude from others because I don’t EVERYTHING they do.. please help me with this

Share this post


Link to post
Share on other sites

That could be simple if you gave your SP code... if you want more than general considerations about MP.

Share this post


Link to post
Share on other sites

@pierremgiThank u for saying that & I apologize, those guys in discord had me so irritated I forgot to add the code I will soon as I jump in Arma.. thanks for the response, I hope u can help

  • Like 1

Share this post


Link to post
Share on other sites

Yeah easy to act like a boss when you are a thousand or more miles away...

For whatever code we are talking about you can try placing it in an initPlayerLocal.sqf file. You just create one on your mission folder and add your code there.

Although yes knowing for what kind of code we are talking about exactly will surely help :thumbsup:

 

Also in case it is in the future needed: https://forums.bohemia.net/forums/forum/154-arma-3-mission-editing-scripting/

Share this post


Link to post
Share on other sites

@pierremgi ..this is the code..

 

if (local this) then {removeVest this; removeBackpack this; removeAllAssignedItems this; removeAllWeapons this; this playMove "AmovPercMstpSnonWnonDnon_exercisePushup"; this disableAI "ANIM";}; 

 

I was told to add the "if (local this)" to get it to work in multiplayer but it still wasn't working.. I also had another to stand at ease.. 

 

this playMove "AmovPercMstpSnonWnonDnon_Ease"; this disableAI "ANIM";

 

& it also set to default in MP.. I never added the "if (local this)" because I never got the push ups to work..

 

both of theses scripts are on 2 different sets of units, in 2 different areas of the maps

 

I know they're are simple scripts that don't affect the gameplay of the campaign, but I'm trying to set a scene for the players that join. @JohnKalo Yea, if u don't know everything they know, all they do is tell u what u did wrong & then never help u get on track..I'm new to most of the scripting & they expect everyone to have a degree in Arma 3 before they talk without judging u..lol.. I will try the sqf also..thanks

Share this post


Link to post
Share on other sites

OK, so you script in init field of the unit (the reason to use this as variable). That's similar to init.sqf in term of broadcast (not in term of initialization order).

 

The problem is that the code will run for all PCs at each JIP (join in player). You need to run that on server only (like this could be done in initServer.sqf)
The local this condition seems OK to avoid that. But... not a problem if the units stay on server (AIs I presume).

If any doubt in locality (server for AIs.. client for players + their AI group...), you'd better replace by local this by isServer condition, which will do the trick, no matter who owns the unit.

 

Now, about the code:

>> removeVest is a argument global, effect global (AG EG) command, so it's fine to script straight a removeVest this coming from server and displaying the effect everywhere.

you could use removeBackpackGlobal as well

 

>> playMove is AL EG. Same for removeAllAssignedItems,  removeAllWeapons and disableAI. That means you need to run the code from the PC which owns the unit. If on server it's OK (as said some AIs staying on server), if on remote client PC (AIs in player's group), you need to remoteExec on it (as far as you run the code form server). That's seems worse but in fact you let the server remoteExec the code for JIP

 

So, what I suggest is:
 

fn_pump = {
    removeAllAssignedItems _this;
    removeAllWeapons _this;
    _this playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    _this disableAI "ANIM";
};

if (isServer) then {
  this spawn {
    removeVest _this;
    removeBackpackGlobal _this;
    [_this, fn_pump] remoteExec ["call",_this]
  }
};

 

Probably not the only way. Not tested in MP sorry. The remote execution is useless if you are sure that the units stay on server.
 

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
37 minutes ago, pierremgi said:

fn_pump = { removeAllAssignedItems _this; removeAllWeapons _this; _this playMove "AmovPercMstpSnonWnonDnon_exercisePushup"; _this disableAI "ANIM"; }; if (isServer) then { this spawn { removeVest _this; removeBackpackGlobal _this; [_this, fn_pump] remoteExec ["call",_this] } };

Worked perfect, thank u.. Im assuming its not interchangeable with the at ease pose. I tried to replace the "Amov" portion from "exercisePushup" to "Ease" & the guy is still doing push ups lol.. Is that related to the fn_pump? thanks again tho, if nothing else I got my guys doing push ups.. also, to clarify..the units doing pushups are AI & the units at ease are playable characters which will be used by anyone jumping in the game, but If the slots don't fill up I wanted them to stand at ease in there original position.. the players who join have a spawn point they will start from..

Share this post


Link to post
Share on other sites

Yes, I was on one anim only. For course, if you want the "ease" one you need to create another function fn_ease or else and call it by the remote execution.

 

Share this post


Link to post
Share on other sites

ok, thanks for your help @pierremgi not only did u help me fix it but u explained it so I can learn from it..

  • Like 2

Share this post


Link to post
Share on other sites

:exclamation: Can only add one detail. Extra care should be taken when players play animations. So as for them not to get stuck in the animation and hence be unable to move. With playMove  (or switchMove which is the only one working for some animations) the player will only be able to move once the animation is complete. If that is a loop animation which never ends the player will be stuck.

Share this post


Link to post
Share on other sites
4 hours ago, JohnKalo said:

:exclamation: Can only add one detail. Extra care should be taken when players play animations. So as for them not to get stuck in the animation and hence be unable to move. With playMove  (or switchMove which is the only one working for some animations) the player will only be able to move once the animation is complete. If that is a loop animation which never ends the player will be stuck.

 

In fact, you can break the loop if you hold a key like "forward" while the animation ends. (Tested with the codes above)

But it's better to add a player switchMove ""   in the initPlayerLocal.sqf for example.

  • Thanks 1

Share this post


Link to post
Share on other sites

@JohnKalo@pierremgiok, I will keep this in mind,but for me it's working perfect.. The pushup units can stay on loop they're just there to give the scene some life & the units at ease (which are playable units) seem to allow me to use them, no problem.. Only issue I'm running into is, when I use one of the "at ease" units they spawn at my spawn point (as they should) but the unit stays where I placed it in editor, duplicating the unit. I was hoping to have it replace the unit like it does with the "player" unit I created.. when I choose that one it disappears from where I placed it & I spawn at the spawn point like it should.

Share this post


Link to post
Share on other sites

Only issue I'm running into is, when I use one of the "at ease" units they spawn at my spawn point (as they should) but the unit stays where I placed it in editor, duplicating the unit.

Could you elaborate? What script are you using? I can't understand the duplication, simply using an animation.  Replacement?? Do you teleport the player at start? Sync problem between server and client?

Share this post


Link to post
Share on other sites
16 minutes ago, pierremgi said:

Could you elaborate? What script are you using? I can't understand the duplication, simply using an animation.  Replacement?? Do you teleport the player at start? Sync problem between server and client?

Sure, I have set up a MP mission & in order to have the open slot for all the players needed for mission, I have to put the physical unit in the editor. So I have 20 units set as "playable" in editor & I've scripted them to "at ease" so they're not just standing around.. I also have a unit set as "player", which the one I use.. If I enter the mission using the "player" unit, the physical unit I set in the editor disappears & I spawn at my spawn point which I have designated for ALL players in the mission, BUT if I choose any of the other "playable" units I've set in editor, the unit persist mission as well as spawning at the spawn point.. So the unit duplicates itself, the one I choose from the available slots & the one I spawn into.. So, if I were to fill up all the slots with players, I would have 20 players spawning in at spawn point & still have the 20 unit standing at ease at the position I set them. Doubling the amount of assets in the mission.. Only scripts I'm using are the ones above, but only the at ease applies here. I do not teleport anyone, I just have a respawn point for players when they get in game or die.. So they join mission, hit respawn & pop up at base

Share this post


Link to post
Share on other sites

Sorry, I can't reproduce this problem. Try with: player switchMove ""  in initPlayerLocal.sqf.  No other clue so far.

  • Like 1

Share this post


Link to post
Share on other sites

@pierremgi that did it! just switched from playmove to switch move & any player slot I choose deletes the unit & lets me spawn in its place(at my player spawn).. u have help me out immensely.. I appreciate u taking the time to do that

  • Like 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

×