Jump to content
Sign in to follow this  
boriz

_victim setHit ["hands", 1]; doesn't work on clients in multiplayer?

Recommended Posts

Hello everyone!

I am working on a multiplayer coop mission for Arma2:free where I want to injure some players in such a way that they can't aim precisely and walk, but are still alive. This is a code which should achieve what I want:

_victim setDamage ( 0.81 ); 
_victim setHit ["legs", 1];
_victim setHit ["hands", 1];

This code works when I execute it in single player however setHit command doesn't work properly in multiplayer because:

When the code is executed on a player who is a server provider, the code works as it should and it disables his ability to walk and aim precisely. However when this code is executed on any client connected to this server provider, then the victim's legs and hands are NOT damaged enough (it seems like they are not damaged at all), resulting him still having the ability to walk and aim precisely.

From this observation I assume that command setHit doesn't work correctly in multiplayer and I need to find an alternative way to achieve this feature. Currently I am out of ideas and I don't know how to solve this problem. I am making this thread in hope that someone will provide an much appreciated help. If some of you know how to solve this problem, then, please, let me know!

Edited by Boriz
Solved!

Share this post


Link to post
Share on other sites

setHit is broadcasted over the network, however it must run where _victim is local.

Share this post


Link to post
Share on other sites

You need a remote execution solution. CBA provides one, but that's an addon. the MP framework provides another, but it's clunky and not popular.

Share this post


Link to post
Share on other sites

Firstly, thank you guys for your replies! I knew I can rely on this community! Now back to topic:

The script is executed only on server's side.

I've read the wiki article you've provided and if I understand it correctly, the command setHit has to be executed on client's side to work properly.

If thats correct, then how do I execute that code locally on one particular client?

I've tried to use Remote script execution like this:

[nil, _victim, rEXECVM, "DamageLegsAndHands.sqf", 0.85, 1, 1] call RE;

DamageLegsAndHands.sqf:

hint "DAMAGE LEGS AND HANDS";

_damage=_this select 0;
_damageLegs=_this select 1;
_damageHands=_this select 2;

player setDamage ( _damage ); 
player setHit ["legs", _damageLegs];
player setHit ["hands", _damageHands];

exit;

This method executes DamageLegsAndHands.sqf on all players. I want that script to be executed only on the player who is controlling object _victim. How do I do that?

I am still confused on how to use Remote Script Execution. This is probably not the most efficient way to achieve what I want but its the best that I came up with.

Edited by Boriz

Share this post


Link to post
Share on other sites
[nil, _victim, "loc", rEXECVM, "DamageLegsAndHands.sqf", 0.85, 1, 1] call RE;

Share this post


Link to post
Share on other sites
[nil, _victim, "loc", rEXECVM, "DamageLegsAndHands.sqf", 0.85, 1, 1] call RE;

Just tested it on local multiplayer with 2 players and it seems to be working! Thanks a lot! The whole script looks as follows:

[nil, _victim, "loc", rEXECVM, "DamageLegsAndHands.sqf", _overall_damage, _damage_legs, _damage_hands] call RE; 

DamageLegsAndHands.sqf:

//This script is executed locally on player which is supposed to be hurt
_damage=_this select 0;
_damageLegs=_this select 1;
_damageHands=_this select 2;

player setDamage ( _damage ); 
player setHit ["legs", _damageLegs];
player setHit ["hands", _damageHands];

exit;

Hopefully it will be useful for someone else!

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  

×