Nightmare01 0 Posted January 5, 2004 Hello. "SoldierWB" createUnit [getpos Spawn1, group1] Spawn1 is an invisible H Why does this easy command dont work ? I get no error msg or anything. It happens just nothing. thanks for your help Share this post Link to post Share on other sites
bn880 5 Posted January 5, 2004 Your group is probably not defined properly. What is group1? Normally you would grab a group by placing this in a unit's init: group1=group this Share this post Link to post Share on other sites
sanctuary 19 Posted January 6, 2004 In addition to bn880 answer , if you dont want the unit used just to define the group as " group1 " to continue to exist , you can put this in its init line <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">group1=group this; deletevehicle this This way the group named group1 is defined , but the soldier you put in your mission for this is deleted just after that group definition. Can be usefull if you have no use of this soldier. Share this post Link to post Share on other sites
Nightmare01 0 Posted January 6, 2004 Thanks people, it works now  The group name (group1 in my case) has to be exist when the command is executed. So first you have to place a soldier into the mission with the init: group1=group this If you delete or keep the soldier after mission start doesnt matter. Would be very usefull if BIS add a comment about that into his comref. Share this post Link to post Share on other sites
Taurus 20 Posted January 7, 2004 another trick that might be this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _soldier = "SoldierWB" createVehicle getPos _respawn group1 = group _soldier deleteVehicle _soldier group1 can now be accessed. Share this post Link to post Share on other sites
djukel 0 Posted June 24, 2004 another trick that might be this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _soldier = "SoldierWB" createVehicle getPos _respawn group1 = group _soldier deleteVehicle _soldier group1 can now be accessed. That trick not working. Did you tested it? The group name only "valid" if you define it in soldiers init field. Share this post Link to post Share on other sites
MrZig 0 Posted June 24, 2004 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">group1=group this; deletevehicle this noooo! if you delete the guy, and if you spawn alot of guys on group1, it'll screw up. Take out the deletevehicle this part. Just put this in the spawned unit <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> "soldierwb" createunit [getpos H,Group1,"Man = this",0.5,"PRIVATE"] [man] join grpnull Share this post Link to post Share on other sites
Unnamed_ 0 Posted June 24, 2004 Sanctuary got it right, you can only create a valid group from within the editor. After that you can use the script commands to make additional groups based on what you setup in the editor. Share this post Link to post Share on other sites
Norris 0 Posted July 20, 2004 I have a question, how the hell do you access the created unit? I want to make a generic script where a soldier respawns and then when he dies I want to add +1 to casualty counter. My initial assumption was something like this: _man = "SoldierWB" createUnit [_spawn,group1,"",0.5,"CORPORAL"] @(NOT alive _man) bodyCount = bodyCount + 1 Looks fine in theory, but the stupid createUnit does not return anything. It even says so in comref. So how do I find out when that particular soldier dies? Is there a simple way to do it or do I have to name the soldier in the init ("soldier1 = this") and then use @(NOT alive soldier1)? If anyone knows a simple solution it would make my life much easier. Share this post Link to post Share on other sites
CrashnBurn 0 Posted July 20, 2004 This is simple. Use an eventhandler. Edit your createunit line like so: "SoldierWB" createUnit [_spawn,group1,"this addeventhandler [{killed},{_this exec {bodycount.sqs}}]",0.5,"CORPORAL"] Next make a new text file and name it bodycount.sqs. Put it in the folder that has your mission name. contents of bodycount.sqs: ;-------------------------------------- _unit = _this select 0 _unit removealleventhandlers "killed" bodycount = bodycount + 1 ;-------------------------------------- Now in your init.sqs, or in the players ini put: bodycount = 0 Each created unit that dies will add 1 to your bodycount. Don't put a "_man =" at the front of the createunit line. If you want to name him use the ini section of the line like so: "SoldierWB" createUnit [_spawn,group1,"man1=this; this addeventhandler [{killed},{_this exec {bodycount.sqs}}]",0.5,"CORPORAL"] Now if you want to get fancy, you can delete the created units, if you want to keep too many from piling up. Just edit the script like so: ;-------------------------------------- _unit = _this select 0 _unit removealleventhandlers "killed" bodycount = bodycount + 1 ~15 + (random 10) deletevehicle _unit ;-------------------------------------- Share this post Link to post Share on other sites
Norris 0 Posted July 20, 2004 Wow! Thanks! I'll test it today! I used event handlers before but always got an error message - probably because of "quote marks". I never realised you can use {} instead of quote marks. Thanks again! Share this post Link to post Share on other sites