Jump to content
Sign in to follow this  
darkheart232

How to set a unit to damage another when close

Recommended Posts

Im trying to get it where dogs cause damage to a player when they are within say .5 meters of someone. I saw this: "

if (player distance dog <2) then {player setDamage (getDammage palyer)-0.1} " But I don't know where to put this line. So any advice would be good.

Share this post


Link to post
Share on other sites

You could run a script from your init.sqf, like this:

[] execVM "dogdistancecheck.sqf";

dogdistancecheck.sqf:

while {true} do { 
if (player distance dog < 2) then {
player setDamage ((getDammage player) - 0.1);
sleep 2;
};

This will cause the game to constantly check if player is within range of unit named "dog", and if the player is, then he gets 0.1 damage every 2 seconds (because no dog in the world can constantly bite somebody to death without break)

Hope this helps.

Share this post


Link to post
Share on other sites

Hmmm.... this one doesn't seem to work. I put the init.sqf code in the init.sqf document, and I created a new document called dogdistancecheck.sqf and put the other code in there. But it doesn't work. If the dogs have names, would that hinder this from working? Edit: I renamed a unit dog, and input the coce in exactly as typed, and it still doesn't work. So idk what would be causing this.

Edited by darkheart232

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  

×