Jump to content
Sign in to follow this  
StarvinMarvin

How to call one script from another?

Recommended Posts

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 smile_o.gif

Share this post


Link to post
Share on other sites

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

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

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

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

EUREKA!! biggrin_o.gif

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 biggrin_o.gif

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

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

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

got it even easier biggrin_o.gif

_number = 0

#loop

_number = number+1

bla bla bla

?_number >= 4 : goto "wait"

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  

×