D.murphy man 0 Posted May 21, 2005 Hey guys i tried searching but suprisingly only came up with one or 2 vauge answers and nothing solid. My proplem is this. I want to detect what player killed another player and then hand out a reward. Somthing along the lines of: ?(man1 killed man2) : man1_reward_money=man1_reward_money+100;man2_money=man2_money-100 Of course this would not work, inless theres a killed command im not aware of? so im asking you kind lot to once again help me find a solution! Any one got an idea? Share this post Link to post Share on other sites
gandalf the white 0 Posted May 21, 2005 why not have another "if", "if" the killer is less then 5M from the killed guy he gets a reward? Share this post Link to post Share on other sites
D.murphy man 0 Posted May 21, 2005 Hmm never thought of that, but 'the guy' will be respawning as this is a MP mission so it might cause some proplems in detecting the distance of the killer to the victem when he is killed., as well as what if the killer sniped the vistem of from a long distance? Edit: Ok i have manage to script a work around for my little proplem, so thanks for the help anyway. This is what ive done, just incase itll help any one else in my posistion: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Select the Unit _deadguy = _this select 0 _timetilldelete=0 #check? _timetilldelete=_timetilldelete+1 _bandit= nearestobject [_deadguy, "SoldierGB"] ? _deadguy distance _bandit <=3 : goto "check2" ? _timetilldelete => 120 : deletevehicle _deadguy;exit ~1 goto "check?" ;--------------------------------- #check2 ?(_bandit == man1) : goto "man1reward" ?(_bandit == man2) : goto "man2reward" exit ;---------------------------------- #man1reward man1 groupchat format ["you have searched the body and found %1 scrap and %2 food", _deadguyscrap, _deadguyfood] man1food=man1food+_deadguyfood man1scrap=man1scrap+_deadguyscrap ~10 deletevehicle _deadguy ;------------------------- #man2reward man2 groupchat format ["you have searched the body and found %1 scrap and %2 food", _deadguyscrap, _deadguyfood] man2food=man2food+_deadguyfood man2scrap=man2scrap+_deadguyscrap ~10 deletevehicle _deadguy ;--------------------------- exit This is for 2 players one called 'man1' and the other called 'man2', when one of the pair is killed the body will be deleted after 2 minutes, inless the killer, or the victem returns to within 3 meters of the corpse where they will be rewarded with the mans 'scrap' and 'food'; for example man1 kills man2, walks up to man2s body and collects all of man2's food and scrap. this should be activated with a Killed eventhandeler. and require varibles set for 'man1scrap' and 'man1food' and the same again with 'man2scrap' and 'man2food'. Edit2: Darn that dosent work, strang but on further testing it fails to work, the dead guy keeps detecting himself as 'bandit' so he keeps rewarding him self scrap... Share this post Link to post Share on other sites
TeRp 1 Posted May 21, 2005 You should use the killed-eventhandler. A description of how it must be used should be found by searching. Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 21, 2005 Quote[/b] ]man1 addEventHandler [{killed},{man1 exec {killdetect.sqs}}] Put that into the init of the unit, or exec it from init.sqs or something so all players have the eventhandler added properly to whichever unit is supposed to have it. Â Then have this script: Quote[/b] ];;begin killdetect.sqs _shooter = _this select 1 _shot = _this select 0 ;;For MP publicvar it if you want everyone to know who shot what ;;You can also add points this way Shooter = _shooter; publicVariable {Shooter} ?(_shooter == _shot): exit ;;you can do other stuff here exit ;;end killdetect.sqs The Killed eventhandler is local to the shooter and the shootee, i.e. they're the only two who automatically get the info when it happens. Share this post Link to post Share on other sites
D.murphy man 0 Posted May 21, 2005 Ah i never knew you could do that with the kill event handeler, i just thought it could only be used to detect 'who got shot' and not 'who he was shot by' thanks for the info its cleared a lot of things up for me. Share this post Link to post Share on other sites
General Barron 0 Posted May 21, 2005 Event handler tutorial That will tell you what data each EH passes to its code. Share this post Link to post Share on other sites
D.murphy man 0 Posted May 22, 2005 Thanks big GB! thatll come in handy im sure. Share this post Link to post Share on other sites
col_kurtz1979 0 Posted July 18, 2005 I get 'unknown operator' when I run the following code from the unit's init, and also from the init.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">man1 addEventHandler [{killed},{man1 exec {killdetect.sqs}}] What am I doing wrong? Is it because im running on 1.46? Share this post Link to post Share on other sites
Espectro (DayZ) 0 Posted July 18, 2005 I get 'unknown operator' when I run the following code from the unit's init, and also from the init.sqs<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">man1 addEventHandler [{killed},{man1 exec {killdetect.sqs}}] What am I doing wrong? Is it because im running on 1.46? Yes, event handlers was introduced in 1.90 if im not mistaken? Share this post Link to post Share on other sites
col_kurtz1979 0 Posted July 18, 2005 Thanks for the reply Share this post Link to post Share on other sites
col_kurtz1979 0 Posted July 19, 2005 Ok working in 1.96 and using KaRRiLLioN's example... What would be the correct way to write the following code? <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format ["%1 was killed by %2", name _shot, name _shooter] I've already set _shot and _shooter as public variables, but how do I get the names displayed in the hint box? Share this post Link to post Share on other sites
Metal Heart 0 Posted July 20, 2005 In Karillion's example Shooter = _shooter, the public variable is Shooter not _shooter. So: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format ["%1 was killed by %2", name shot, name shooter] Share this post Link to post Share on other sites