CARRICK_IRISH 39 Posted October 23, 2013 Hey guys, i'm trying to animate an AI unit in multiplayer (dedicated server, not self hosted) but it is only working in singleplayer mode and self-hosted games. _target playActionNow "Gear"; Is playActionNow not working in MP? regards, ian Share this post Link to post Share on other sites
Ranwer135 308 Posted October 23, 2013 (edited) ... its not working because playActionNow doesnt exist. Try this: _unit playMoveNow "Gear"; If you want a player to do it: player playMoveNow "Gear"; EDIT: Also, when your previewing the mission your editing, pause it and go into animations. Because I think the script of "Gear" is longer than that. Now if you want to put it in the init of a unit, do this: this playMoveNow "Gear"; Also, the proper script to do it is this: this playMoveNow "AinvPercMstpSnonWnonDnon_G01"; Edited October 23, 2013 by Ranwer Share this post Link to post Share on other sites
CARRICK_IRISH 39 Posted October 24, 2013 I used the playActionNow function from the bi wiki and it worked. but on mp server the animation is not playing. _target = _this select 3; // the target ai forced to surrender _target SetUnitPos "UP"; _target playActionNow "Surrender"; _target disableAI "MOVE"; @ Ranwer: thank you for your answer, but playMoveNow is not working with my script in any mode *sigh* i feel like looking for a needle in a haystack right now with all these animation functions :( i thought there could be any problem with _this on the mp server. greets, ian Share this post Link to post Share on other sites
sxp2high 22 Posted October 25, 2013 (edited) playActionNow is a great command, use it whenever possible. You have to execute all these commands wherever the unit is local. Which is most likely the server in this case. I don't trust BI_fnc's, so here a PVEH method: Create a function which checks locality and then executes it: fn_unitSurrender = { private ["_unit"]; _unit = _this select 0; if (local _unit) then { _unit SetUnitPos "UP"; _unit playActionNow "Surrender"; _unit disableAI "MOVE"; }; }; Add publicvariable event handler, which will trigger that function on all clients + server: "unit_surrender" addPublicVariableEventHandler { _unit = _this select 1; [_unit] call fn_unitSurrender; }; These both blocks can go inside your init.sqf. Then inside your script: _target = _this select 3; // the target ai forced to surrender [_unit] call fn_unitSurrender; // Call locally so it works in SP aswell unit_surrender = _unit; publicVariable "unit_surrender"; // Broadcast Edited October 25, 2013 by sxp2high Share this post Link to post Share on other sites
CARRICK_IRISH 39 Posted October 25, 2013 Hey sxp2high, thanks alot for your impression and idea about the function. i tried to add it to my code and modified it your ways. the animation is playing in MP without any problem. still in MP it is not working. The addPublicVariableEventHandler seems to be inactive all the time. I added a check-hint "MP" to the event which is not shown, too. fn_unitSurrender = { private ["_unit"]; _unit = _this select 0; if (local _unit) then { _unit SetUnitPos "UP"; _unit playActionNow "Surrender"; _unit disableAI "MOVE"; }; }; "unit_surrender" addPublicVariableEventHandler { _unit = _this select 1; hint "MP"; [_unit] call fn_unitSurrender; }; _target = _this select 3; // the target ai forced to surrender [_target] call fn_unitSurrender; // Call locally so it works in SP aswell unit_surrender = _target; publicVariable "unit_surrender"; // Broadcast i guess i've done somethg wrong with the merge of your code to my variables? greets, ian Share this post Link to post Share on other sites
sxp2high 22 Posted October 25, 2013 Things to keep in mind about publicVariable event handler: - It's never executed in SP - It's never executed on the client who is broadcasting the publicVariable So, you not seeing that hint is correct. I just tested it on my dedicated and it works. You seem to have done something wrong. Make sure you put this part into your init.sqf fn_unitSurrender = { private ["_unit"]; _unit = _this select 0; if (local _unit) then { _unit SetUnitPos "UP"; _unit playActionNow "Surrender"; _unit disableAI "MOVE"; }; }; "unit_surrender" addPublicVariableEventHandler { _unit = _this select 1; [_unit] call fn_unitSurrender; }; So it is defined and added on all clients + server. The other three lines can be called from anywhere then. Share this post Link to post Share on other sites