Jump to content
Sign in to follow this  
darkheart232

Help me find the error in the script

Recommended Posts

So. I have two dogs in an arena, and an independant hunter, who's the exterminator. He has three minutes to kill the dogs. I'm trying to make it so the dogs can do damage to the hunter. I have this in my init.sqf file: [] execVM "dogdistancecheck.sqf";

And I created the dogdistancecheck.sqf file and put this in it:

while {true} do {

if (player distance dog < 2) then {

player setDamage ((getDammage player) - 0.1);

sleep 2;

};

But it doesn't work. One dog is named dog. But it doesn't work, and idk what could be the error. If anyone could help, it would be greatly appreciated.

Share this post


Link to post
Share on other sites

nul = [] spawn {while {true} do { if (player distance dog < 2) then {
player setDamage ((getDammage player) + 0.1);
hint "bite....ouch!";
sleep 2; 
player sidechat format["%1",getDammage player];
}; 
}; 
};

That works in the player init field - but there are better ways of writing it with nearestObjects for example

nul = [] spawn {while {alive player} do {
dgarr = nearestObjects [player, ["Fin","Pastor","Pastor_ACR"], 2]; 
dg = dgarr select 0; 
if (player distance dg < 2) then {  
player setDamage ((getDammage player) + 0.1); 
hint "bite....ouch!"; 
sleep 2;
player sidechat format["%1",getDammage player]; 
}; 
};
};

Works for all 3 dogs in game

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

I put this in the dogs field.... It kills him after saying the hint nonstop. SO I removed it and tried it in the players field. It kills the dog in about 10 seconds amaybe.

Share this post


Link to post
Share on other sites

Scratch that. If I play as the dog and nobody controls the hunter, then the dog kills itself basically. If I'm the hunter, it works fine. How would I put it so the other dog can do damage as well? One is named dog, the other is dog2.

---------- Post added at 23:04 ---------- Previous post was at 23:03 ----------

And that's what they're doing. Gathering food for their village. ;)

Share this post


Link to post
Share on other sites

put that in the hunters init - with player as dog - 10 bites will kill

nul = [this] spawn {_vic = _this select 0; while {alive _vic} do {_dgarr = nearestObjects [_vic, ["Fin","Pastor","Pastor_ACR"], 2]; _dg = _dgarr select 0; if (_vic distance _dg < 2) then {_vic setDamage ((getDammage _vic) + 0.1);  hint "bite....ouch!"; sleep 2; }; }; };

Share this post


Link to post
Share on other sites

Thanks mattar. That did it. =] You's saved my day twice, this and my artillery question.

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  

×