SmileyCat Posted June 20, 2011 Share Posted June 20, 2011 My first example would have made just fine when changing 201 to 200 and making the script a quest and setting the processing delay to 0.0015. Link to comment Share on other sites More sharing options...
pitvenin Posted June 21, 2011 Author Share Posted June 21, 2011 (edited) Finally! Here it is ref rTarget ref rClosestRef float Distance float maxdistance begin GameMode if iEnableSearch == 1 ;this is a global variable (make sure to define it) set maxdistance to 1000 ;define de maxium range for searching set rTarget to GetFirstRef 200 0 0 set rClosestRef to rTarget set Distance to rTarget.GetDistance player set iActorCount To GetNumRefs 200 0 ;this is a global variable (make sure to define it) Label 1 if rTarget.getDead == 1 && iActorCount >=1 set rTarget to Pencil01 set rTarget to GetNextRef set rClosestRef to rTarget set Distance to rTarget.GetDistance Player set iActorCount to iActorCount - 1 goto 1 endif if rTarget && Distance <= maxdistance && iActorCount >= 1 if rTarget.GetDistance Player < Distance set rClosestRef to rTarget set Distance to rClosestRef.GetDistance Player endif set rTarget to Pencil01 set rTarget to GetNextRef set iActorCount to iActorCount - 1 goto 1 endif if rClosestRef ;do something to the closest actor rClosestRef.killActor ; Die *censored*, your in my space! endif if iActorCount <= 0 set iEnableSearch to 0 endif endif end Each time iEnableSearch is set to 1, this code will get you the closest alive actor in a 1000 range units...and kill it :P Special thanks to rickerhk, it's based on he's script. Also thanks to the rest for making things clear :P Edited June 21, 2011 by pitvenin Link to comment Share on other sites More sharing options...
Recommended Posts