Jump to content
omri2050

Help: Distance command from player, on dedicated

Recommended Posts

Hello!
I'm trying to solve this annoying issue but no success..

What I'm trying to achieve is: When a player get close to a civilian (distance < 5), he can point the gun to his face to "make him talk"..

I don't want it to be connected to some trigger area, as I want the player to search him.

In SP, the trigger condition goes as follows: 

((toUpperANSI cameraView == "GUNNER") && (cursorTarget == civ1) && (player distance civ1 < 5))

So this way, only when a player gets within those 5m, and look at his optics, the civ1 starts to talk (and play animation)

The problem? 
I can't get it to work on dedicated server, as `player` is unknown..
How can I make it work?

Wanted outcome - ANY blufor live player can trigger it when pointing the gun and being within 5m of civ1


This is what I mean in case needed, once I pull the gun out and point it to his face

Thanks a lot
 

Share this post


Link to post
Share on other sites

You just gave the condition, so I can't guarantee the good result, especially for the remote execution of codes which could be applied on AIs belonging to server.

You need to run your code in initPlayerLocal.sqf (and probably on respawn sqf or EH, depending on your loop)

  • Like 1

Share this post


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

You just gave the condition, so I can't guarantee the good result, especially for the remote execution of codes which could be applied on AIs belonging to server.

You need to run your code in initPlayerLocal.sqf (and probably on respawn sqf or EH, depending on your loop)

`initPlayerLocal.sqf` Did the job. Thanks a lot!

Any idea though why it executes only the first animation and ignore the `surrender` one?
 

while { true } do {
if ((toUpperANSI cameraView == "GUNNER") && (cursorTarget == civ1) && (player distance civ1 < 5)) then {
  [civ1, "Act_Alien_Gesture"] remoteExec ["switchMove", 0];
  sleep 5;
  [civ1, ""] remoteExec ["switchMove", 0];
  civ1 action ["surrender", civ1];
   };
sleep 2;
};

And yes it's probably not a very good way of doing a while loop..I'm learning..

 

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, omri2050 said:

Any idea though why it executes only the first animation and ignore the `surrender` one?

It may be that the "action" command is local and needs to remoteExeced somehow.

 

An alternative would be to RemoteExec the playAction "Surrender", which should be the same animation:

[civ1, "Surrender"] remoteExec ["playActionNow", 0];

 

  • Like 4

Share this post


Link to post
Share on other sites
58 minutes ago, johnnyboy said:

It may be that the "action" command is local and needs to remoteExeced somehow.

 

An alternative would be to RemoteExec the playAction "Surrender", which should be the same animation:


[civ1, "Surrender"] remoteExec ["playActionNow", 0];

 

Yup, that was it, 
Thanks man 

Cheers!

 

  • Like 3

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

×