Jump to content

Recommended Posts

Hello,

I am trying to get a simple hostage script to work on a dedicated multiplayer server, but it does not seem to work properly. I can see the "Free Hostage" option on the "hostage" AI, but the AI does not do anything after I select the option. While testing in the editor, the hostage is able to go to his next waypoint, but on the dedicated server, he is still stuck in place as if the script did not execute.

 

The code I have to setup the hostage in "hostageSetup.sqf":

hostage disableAI "move";  
hostage setcaptive true;  
removeallweapons hostage;  
removebackpack hostage;  
removeGoggles hostage;  
removeHeadgear hostage;  
hostage unassignitem "nvgoggles";  
hostage removeitem "nvgoggles";   
removeVest hostage;  
hostage setunitpos "middle";

The code in "hostageAction.sqf":

hostage setcaptive false;  
hostage setunitpos "auto";  
hostage enableAI "Move";   

And then finally the code in "init.sqf":

execVM "hostageSetup.sqf";

hostage addaction ["Free Hostage",{ 
execVM "hostageAction.sqf"
},nil,6,true,true,"","true",2,false,"",""];

Is there something I should add?

Share this post


Link to post
Share on other sites

Try this as first line in hostageAction.sqf:

[hostage, clientOwner] remoteExec ["setOwner", 2];

this orders the server to move the locality of the hostage to the client.

It may take some time to change locality and therefore you should execute a sleep after it. A sleep for a second should be enough.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you, I changed the "hostageAction.sqf" to:
 

[hostage, clientOwner] remoteExec ["setOwner", 2];

sleep 2;

hostage setcaptive false;  
hostage setunitpos "auto";  
hostage enableAI "Move";   

but in the editor I got an error message saying "Script command setOwner cannot be used for object 'C_man_polo_1_F'. Use setGroupOwner instead. And when tested on the dedicated server, I have the same result as before, where the AI does not move. However, I do not get the error message on the server.

So I also tried to change it to "setGroupOwner" instead of "setOwner", which gave me the error in the editor: " '(_this select 0) |#|setGroupOnwer (_this select 1)' Error  setGroupOwner: Type Object, expected Group". And on the dedicated server I had the same result as before.

Is there a different way that this can be done maybe?

Share this post


Link to post
Share on other sites

In this case try:

[(group hostage), clientOwner] remoteExec ["setGroupOwner", 2];

 

  • Like 1

Share this post


Link to post
Share on other sites

Thank you, that seems to have worked. Hostages now move to their first waypoint after they are freed.

  • 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

×