NaveReyem 0 Posted August 5, 2005 ok, here is the situation ive got a problem with something im making, its a script to tell when the player kills an AI, then give the player some money and fame or whatever. but the script also gives money to the player when the AI gets killed by enemy AI and things, how would i get around this?? example <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _victim = _this select 0 _killer =_this select 1 _money = _this select 2 _fame = _this select 3 removeallweapons _victim ?(side _victim == East) : goto "Eastkilled" ?(side _victim == West) : goto "Westkilled" #Eastkilled ?(side _killer == West) : goto "exit" eastFame = eastFame - _fame; westFame = westFame + _fame; Money = Money + Random(_money) Hint format ["---------------Stats--------------\n\nMoney: $%1\n\nWestFame: %2\n\nEastFame: %3",money,westfame,eastfame] goto "exit" #Westkilled ?(side _killer == East) : goto "exit" westFame = westFame - _fame; eastFame = eastFame + _fame; Money = Money + Random(_money) Hint format ["---------------Stats--------------\n\nMoney: $%1\n\nWestFame: %2\n\nEastFame: %3",money,westfame,eastfame] goto "exit" #exit ~5 deletevehicle _victim Exit well it works good, but i need to be able to goto "exit" before it gives him money if the player is not the one that killed the AI that this script is for.. you see? because ?(side _killer == East) : goto "exit" didnt work, i dont think the event handler is telling the script who is the killer, any ideas why? because im thinkin this should work, but it doesnt <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #Eastkilled ?(_victim) : goto "exit" eastFame = eastFame - _fame; westFame = westFame + _fame; Money = Money + Random(_money) Hint format ["---------------Stats--------------\n\nMoney: $%1\n\nWestFame: %2\n\nEastFame: %3",money,westfame,eastfame] goto "exit" ok, where east is killed and there is ?(_victim) : goto "exit" i need to to be able to tell if the killer was an AI or the player you see... ?(_killer == player) : goto "exit" didnt work either.... help plz. BTW in the AI that i kill the in the init it says <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> westman1 addEventHandler ["killed",{[westman1,this,20,5] exec "apkiller.sqs"}] where THIS is in there, i dont know what to put to detect who is the killer.....also, i have a feelign im giong about it the hard way help plz Share this post Link to post Share on other sites
NaveReyem 0 Posted August 5, 2005 Hey no Reply, Thanx guys! Share this post Link to post Share on other sites
.kju 3245 Posted August 6, 2005 5 hours and no reply .. i am certain noone does know the solution this word is called patience ... Share this post Link to post Share on other sites
klavan 0 Posted August 6, 2005 If westman1 is supposed to be the player, then try this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> westman1 addEventHandler ["killed",{[this,westman1,20,5] exec "apkiller.sqs"}] Because: Quote[/b] ]_victim = _this select 0 _killer =_this select 1 _money = _this select 2 _fame = _this select 3 Share this post Link to post Share on other sites
Trapper 0 Posted August 6, 2005 Eventhandlers already return important values. Quote[/b] ]"killed" (addable to men or vehicles) : _this select 0 : who's dead ; _this select 1 : whodunnit (say, the killer) ; [westman1,this,20,5] exec "apkiller.sqs" changes the original _this select 0 and _this select 1 of "killed". And maybe [westman1,this,20,5] isn't working to detect the killer. Try to add the eventhandler this way: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">westman1 addEventHandler ["killed",{_this exec "apkiller.sqs"}] Then apkiller.sqs already recieves: _victim = _this select 0 _killer =_this select 1 But you will have to select different money and fame values inside of your script. I'm not sure if its possible to combine your old script-call and the better one in a way like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> westman1 addEventHandler ["killed",{(_this + [20,5]) exec "apkiller.sqs"}] If it works you can call the script with four values also. At ofpec.com you will find an eventhandler tutorial. Share this post Link to post Share on other sites
Platoon_Patton 0 Posted August 6, 2005 I think U better not execute your script with those parameters. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">westman1 addEventHandler ["killed",{[this,westman1,20,5] exec "apkiller.sqs"}] The power of EHs is the output when activated,but you define them,so they are allways the same. Try this way: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">westman1 addEventHandler ["killed",{_this exec "apkiller.sqs"}] And now U have: _victim = _this select 0 _killer =_this select 1 _money = 20 _fame = 5 ?(side _killer == side player):exit (Exit for friendly fire) ?(_killer == _victim):exit (Suicide ) etc...etc... EDIT:Bit too late Share this post Link to post Share on other sites
NaveReyem 0 Posted August 8, 2005 thanks guys, ill have to try all these, good ideas, ive not tried to make the KILLER this select 0, some people on ofpec said it is built in as this select 1, but it may not work with other parameters in there like money and fame.... but i tried it and it didnt work, so all these may  i like ur last idea Patton Share this post Link to post Share on other sites
NaveReyem 0 Posted August 8, 2005 lol, thats gay, now that i think about it i really dont need to have money and fame in the event handler, it a random number generated up to 20 for money and 5 for fame, i could just do all of it in the script. OR does anyone know if its possible to run 2 eventhandlers on one person, there could be another like <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> westman1 addEventHandler ["killed",{_this exec "apkiller.sqs"}]; westman1 addEventHandler ["killed",{20,5 exec "apkillerfamemoney.sqs"}] or would this be too hard on the system, running two killed scripts at the same time? Share this post Link to post Share on other sites
NaveReyem 0 Posted August 10, 2005 BTW westman1 is NOT supposed to be the Player, he is supposed to be an AI, there would also be oter AI named eastman1, eastmand2 and such, so i need to make it work for both... the PLAYER would be resistance side, with NOBODy friendly to him.. Share this post Link to post Share on other sites