StarvinMarvin 0 Posted March 11, 2007 HI! Im using one script to keep spawning enemy soldiers for eternity. they are moving to the player guarding a pos. when he kills them they only keeps coming and so on.. but now i want to remove all the dead bodies and (if possible) add a gravecross there instead. I got it partly working but i need to make the Deathprocedures happen in another script cause they dont have specific unit names. they are all named "_unit" as it is now i use check if _unit is alive and if he is not then remove the body after 10sec and add a cross. first of all. it only works on the last guy i killed.. second no other soldier is respawned untill this last guy has been "burried" so i thought that if i could make the cross and body removal to work in another script for _unit then it will work for everyone of them.. suggestions please Share this post Link to post Share on other sites
kutya 0 Posted March 11, 2007 It's done with "killed" eventhandlers. I advise you to look at OFPEC for a description. That is for the body removal. This EH is simply a script which is called when the unit is killed. In that script you deletevehicle the unit. I suggest some delay before the deletion, otherwise it looks weird. Share this post Link to post Share on other sites
StarvinMarvin 0 Posted March 11, 2007 hi! im quite new to this more advanced scripting like event handlers. im not really sure what to look for could you please show me a link or tell me more specific? Share this post Link to post Share on other sites
interal 0 Posted March 11, 2007 for the grave part try <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //Grave //GraveCross1 //GraveCross2 //GraveCrossHelmet _grave = "Grave" createvehicle getpos _unit _grave setdir (getdir _unit) dont know about the other part but im looking forward to see it Share this post Link to post Share on other sites
StarvinMarvin 0 Posted March 11, 2007 hi! yeah thats sort of the same as i did for the grave. works nice except for that its only working for the last spawned guys. anyway i found this "var = execVM "sript.sqs";" thou i cant get it to work.. if i do it this way: _unit = execVM "alive.sqs"; and put hint "booh" then when he dies the "booh" shows.. great!! i thought.. but as soon a i use a variable in the script.. for ex _unit or what ever i use i get a error message. so no good.. but would have been nice.. maybe you know why its not working. Share this post Link to post Share on other sites
interal 0 Posted March 11, 2007 thats proberly because execVM is used to compile and execute sqF scripts not sure though i never use it if it still comes up with a error then what does it say? for eventhandlers : try http://community.bistudio.com/wiki/addEventHandler Share this post Link to post Share on other sites
nuxil 2 Posted March 11, 2007 example player exec "script.SQS <<- exec is for sqs player execvm "script.SQF" <<- execvm for sqf var=["player"] execvm "sqf" or var = [] execvm "script.sqf" if your not using sqf scripts, use exec.. its explained here: http://community.bistudio.com/wiki/Category:Scripting_Topics Share this post Link to post Share on other sites
StarvinMarvin 0 Posted March 11, 2007 EUREKA!! got it sorted now. i did this: _unit addEventHandler ["killed", {_this exec "alive.sqs"}] and then i put the cross in and removed the body in the alive.sqs scripts.. works for EVERY unit EXCEPT for the last one created.. but since they will be created far of the position i defend there will always be a new guy on the way when this first one dies now there is another questions thou.. Can i make the script launch and spawn like 10 guys.. then wait untill a certain var is = true and then relaunch? wouldnt be to hard i guess.. saw some note about makeing a loop work for 10 times and then start over.. but i forgot how it was done.. any clues? Share this post Link to post Share on other sites
nuxil 2 Posted March 11, 2007 for that loop to start over,, just do.. for [{_i=0},{_i<10},{_i=_i+1}] do { SOME CODE; if (_i == 10) then { _i=0} ; }; Share this post Link to post Share on other sites
StarvinMarvin 0 Posted March 11, 2007 so then if i dont want it to spawn troops untill for example the first squad reached a certain area i just put in a loop Before if (_i == 10) then { _i=0} ; to check if A = true untill it resets the loop or do you mean otherwise? Share this post Link to post Share on other sites
StarvinMarvin 0 Posted March 11, 2007 got it even easier _number = 0 #loop _number = number+1 bla bla bla ?_number >= 4 : goto "wait" Share this post Link to post Share on other sites