dematti 10 Posted June 14, 2013 (edited) Hi, I'm trying to make a money system template to put extra realism into some missions. Currently I have a bank, car seller, gun seller, unit seller and a real estate agent. I am also trying to add daily salaries for bought units which I will have to pay for using my bank account. The salaries owned are defined by one number which I put in my init ( ownedsalary = 0 ) So when I go to the bank the "ownedsalary" amount can be deducted by paying for it untill it reaches 0 again. Here is my issue: 1) I am spawning the unit using one code: classname createunit [position, group, init, skill] How can I create a daily loop, adding to the ownedsalary code? I should run a script from its init but I cant figure out how to make this script. The problem is I cant name the unit because more units are spawned using the same script which means they cant have the same name? 2) I am using different skills for spawned units (0.25, 0.50, 0.75) so how can I make one unit more expensive then another? Using multiple scripts is the best solution I guess. 3) If the unit gets killed, the script should stop and no money should be added to "ownedsalary" Who can help me to get this to work? Thanks for your help edit: sorry for posting in the wrong section Edited June 14, 2013 by dematti Share this post Link to post Share on other sites
R0adki11 3945 Posted June 14, 2013 @dematti i moved your thread to the editing section as this is the correct area :) Share this post Link to post Share on other sites
dematti 10 Posted June 15, 2013 Ok I found a solution for most of this. I'm just struggling how to stop the script if the spawned unit gets killed. How do I stop a script from running if a spawned unit gets killed? (spawned by a script which respawns MULTIPLE units) The script needs to keep running for other alive units spawned by this script. to spawn my unit(s) I use this code: classname createunit [position, group, init, skill] in the init of this unit I execute the salary script, but I need it to stop if the unit dies. thx Share this post Link to post Share on other sites
xxanimusxx 2 Posted June 16, 2013 I assume your script to keep track the salary of the units uses a while/true loop, am I right? It's pretty easy if it's so, just replace the condition in the while-loop with the alive-state of the unit. In the units init-field, call your script and use this as a parameter for your script: init = "this execVM ""keepTrackOfSalary.sqf"";"; classname createunit [position, group, init, skill]; And in your script: _unit = _this; // .... while {alive _unit} do { // Well, you do know what to do here, don't you? :D }; // ... If you're here, the unit has died, do some cleanup... Whenever the unit in question dies the while-loop will be left and the script will run to the end. Share this post Link to post Share on other sites
dematti 10 Posted June 16, 2013 Ok, thx xxAnimusxx! the problem was I couldn't make the link between the unit and the script. _this (offcourse!) was the line I had to use in the loop, when naming them isn't possible. THX! Share this post Link to post Share on other sites