f2k sel 164 Posted February 17, 2011 (edited) I'm spawning a group (not BIS FN) and calling it with nul=[red] execvm "spawnGRP.sqf" The code is a cut down but working sample. groupE = _this select 0; groupE = createGroup EAST; _leader = groupE createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"]; _unit = groupE createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"]; The problem is that the group isn't named red but groupE and any other groups that are spawned is given the group name groupE. How do I set the group name to that that is being passed? Edited February 18, 2011 by F2k Sel Share this post Link to post Share on other sites
Coyota 10 Posted February 17, 2011 (_this select 0) = createGroup EAST; Something like that maybe Share this post Link to post Share on other sites
fencr0c 10 Posted February 17, 2011 Your create unit line is wrong. Should be something like this _group=creategroup east; _leader="TK_INS_Soldier_TL_EP1" createUnit [_spawnPos, _group, "", 0.5, "SERGEANT"]; _unit="TK_INS_Soldier_MG_EP1" createUnit [_spawnPos, _group, "", 0.5, "CORPORAL"]; Share this post Link to post Share on other sites
f2k sel 164 Posted February 17, 2011 (_this select 0) = createGroup EAST; Something like that maybe Nope just gives an error (_this select 0) |#|= createGroup EAST; ---------- Post added at 05:34 PM ---------- Previous post was at 05:33 PM ---------- Your create unit line is wrong.Should be something like this _group=creategroup east; _leader="TK_INS_Soldier_TL_EP1" createUnit [_spawnPos, _group, "", 0.5, "SERGEANT"]; _unit="TK_INS_Soldier_MG_EP1" createUnit [_spawnPos, _group, "", 0.5, "CORPORAL"]; I changed the code and again the units spawn but still not with the right group name. Thanks for replying guys. Share this post Link to post Share on other sites
demonized 20 Posted February 17, 2011 maybe try the text command _group=creategroup east; _leader="TK_INS_Soldier_TL_EP1" createUnit [_spawnPos, _group, "", 0.5, "SERGEANT"]; _unit="TK_INS_Soldier_MG_EP1" createUnit [_spawnPos, _group, "", 0.5, "CORPORAL"]; // name group RED_leadername _naming = format["RED_%1",_leader]; _specialGrpName = text _naming; Untested but think it should work as text uses string to make stringless text.....i hope...wich you need for groupname..... Share this post Link to post Share on other sites
f2k sel 164 Posted February 17, 2011 maybe try the text command _group=creategroup east; _leader="TK_INS_Soldier_TL_EP1" createUnit [_spawnPos, _group, "", 0.5, "SERGEANT"]; _unit="TK_INS_Soldier_MG_EP1" createUnit [_spawnPos, _group, "", 0.5, "CORPORAL"]; // name group RED_leadername _naming = format["RED_%1",_leader]; _specialGrpName = text _naming; Untested but think it should work as text uses string to make stringless text.....i hope...wich you need for groupname..... I can't see how that helps, when test _specialGrpName returns "RED <null>" and even if it did work how would I later change it from RED to something else. Share this post Link to post Share on other sites
demonized 20 Posted February 17, 2011 strange, what do you get if you try hint format["%1",_leader]; ? I just used RED as example as you mentioned it, why not set it to whatever you need right at creation and then just gather it in global array or something if you cant or wont carry it over through scripts. ---------- Post added at 08:42 PM ---------- Previous post was at 08:41 PM ---------- anyway, ive never used text before, just saw it and thought you might find it useful, ah well. ---------- Post added at 08:57 PM ---------- Previous post was at 08:42 PM ---------- _group = creategroup east; _leader = "TK_INS_Soldier_TL_EP1" createUnit [getPos player, _group, "", 0.5, "SERGEANT"]; _unit = "TK_INS_Soldier_MG_EP1" createUnit [getPos player, _group, "", 0.5, "CORPORAL"]; // name group RED_leadername hint format["%1",(leader _group)]; sleep 2; _naming = format["RED_%1",(leader _group)]; hint format["%1",_naming]; sleep 2; _specialGrpName = text _naming; hint format["%1",_specialGrpName]; sleep 2; _specialGrpName = creategroup east; {[_x] joinSilent _specialGrpName} foreach units _group; sleep 2; {_x setDammage 1} foreach units _specialGrpName; hint format["%1",(count (units _specialGrpName))]; sleep 2; hint format["%1",(count (units _group))]; this works, creates a group with RED_name_of_leader you can change RED_ to whatever you want, it creates them, then shows hints on namesand group names, then kills them and counts both groups, the creating group and final group, 0 and 2, if a group is empty it is deleted so should not cause any problems i think, if so just deletegroup after all have joined the named group. Share this post Link to post Share on other sites
f2k sel 164 Posted February 17, 2011 Oddly _leader is seen as <null> unless I put this in front of it _leader = leader _group; and then I get O 1-1-d:1 If I now _specialGrpName is reporting REDO 1-1-d:1 Ok I'll Take a look at the above script a little later. Thanks.. Share this post Link to post Share on other sites
demonized 20 Posted February 17, 2011 Oddly _leader is seen as <null> unless I put this in front of it _leader = leader _group; and then I get O 1-1-d:1If I now _specialGrpName is reporting REDO 1-1-d:1 Ok I'll Take a look at the above script a little later. Thanks.. yes i got null aswell when i used _leader directly, beats me why his name isnt a name once created, but leader group worked around that so i wont give it more thought. Come to think of it: is _leader a name reserved for somthing by the game engine, try changing it to _unit1 if you are still hunting for the reason of null :) Share this post Link to post Share on other sites
shuko 59 Posted February 17, 2011 nul = "red" execvm "script.sqf" private "_group"; call compile format ["%1 = creategroup EAST; _group = %1",_this]; _leader = "TK_INS_Soldier_TL_EP1" createUnit [_spawnPos, _group, "", 0.5, "SERGEANT"]; _unit = "TK_INS_Soldier_MG_EP1" createUnit [_spawnPos, _group, "", 0.5, "CORPORAL"]; Share this post Link to post Share on other sites
rübe 127 Posted February 17, 2011 nul = "red" execvm "script.sqf" private "_group"; call compile format ["%1 = creategroup EAST; _group = %1",_this]; // ... Pardon me, but this is so friggin silly. ExecVM? Call compile format? Really? Again? :rolleyes: What you guys want to do is write a function that creates the group and returns it: _createMyGroup = { private ["_grp"]; _grp = createGroup East; // create/spawn some units // ... // return the group _grp }; red = [] call _createMyGroup; blue = [] call _createMyGroup; There. "_createMyGroup" takes no arguments (we simply pass an empty array), creates a group and some units and returns a pointer to the group (or simply the group). That functions return value (the group) gets bound to the variable "red". And now "red" points to your group (or simply is the group). And then, maybe it's a good idea to actually pass some arguments to maybe spawn groups of different sides or different compositions and maybe the spawn position, so you can maybe reuse that function on later occasions... whatever. Share this post Link to post Share on other sites
f2k sel 164 Posted February 17, 2011 (edited) Neither is working as yet. Demonized I still can't use red though. {_x setDammage 1} foreach units red; has no effect. shk that seems to have it sorted. Thanks all, I'll have to read up on call compile as it's a mystery to me. Ruebe that's even more confusing, I assume it's more efficient. Oh I see what your doing now, Ill give that a go as well. Edited February 17, 2011 by F2k Sel Share this post Link to post Share on other sites
rübe 127 Posted February 17, 2011 Ruebe that's even more confusing, I assume it's more efficient. Well, yes. But that's not really my point. My point is: if you need a function, then hell, write one! But don't try to imitate a function with a execVM/call compile format construct. That's madness. :D Share this post Link to post Share on other sites
f2k sel 164 Posted February 17, 2011 The problem I have with Function is that I don't know to access them. Share this post Link to post Share on other sites
rübe 127 Posted February 17, 2011 The problem I have with Function is that I don't know to access them. http://community.bistudio.com/wiki/function Share this post Link to post Share on other sites
f2k sel 164 Posted February 17, 2011 (edited) Cheers I searched for two hours and couldn't find much. Oh well it makes no sense to me, no matter what I do I get local variable in global space. Edited February 18, 2011 by F2k Sel Share this post Link to post Share on other sites
shuko 59 Posted February 18, 2011 init.sqf: YourTag_createMyGroup = { private ["_grp"]; _grp = createGroup East; // create/spawn some units // ... // return the group _grp }; A trigger, waypoint, script etc: red = [] call YourTag_createMyGroup; Share this post Link to post Share on other sites
f2k sel 164 Posted February 18, 2011 Thanks it was the underscore bit that had me confused, until the next thing. Share this post Link to post Share on other sites
demonized 20 Posted February 18, 2011 Neither is working as yet.Demonized I still can't use red though. {_x setDammage 1} foreach units red; has no effect. shk that seems to have it sorted. Thanks all, I'll have to read up on call compile as it's a mystery to me. Ruebe that's even more confusing, I assume it's more efficient. Oh I see what your doing now, Ill give that a go as well. Not sure what you are doing wrong but it worked in my editor before i posted it. but anyways seems you got it sorted. Share this post Link to post Share on other sites
f2k sel 164 Posted February 18, 2011 Not sure what you are doing wrong but it worked in my editor before i posted it. but anyways seems you got it sorted. But in your script there is no {_x setDammage 1} foreach units red; Share this post Link to post Share on other sites
demonized 20 Posted February 18, 2011 But in your script there is no {_x setDammage 1} foreach units red; aw man, i just reread OP, so sorry, did not catch that last night :butbut my excuse, was way to tired last night. Share this post Link to post Share on other sites
f2k sel 164 Posted February 18, 2011 Me two, even when awake I don't read all the post. Share this post Link to post Share on other sites
demonized 20 Posted February 18, 2011 i did this in trigger: redteam = createGroup EAST; _null = [redteam] execVM "test.sqf"; test.sqf: _grpName = _this select 0; _leader = "TK_INS_Soldier_TL_EP1" createUnit [getPos player, _grpName, "", 0.5, "SERGEANT"]; _unit = "TK_INS_Soldier_MG_EP1" createUnit [getPos player, _grpName, "", 0.5, "CORPORAL"]; hint format["%1",(count (units redteam))]; count of redteam group returns 2. Now i am not sure why you want to create a group with that exact name? why not not just use redteam = creategroup east in the script, why call name from trigger? better way would be to use dynamically created groupnames and either put them in a global array or something. _group = createGroup EAST; RED = []; RED = RED + [_group]; RED select 0 will always return that group.... What is the purpose, might help alot in understanding what and how. Share this post Link to post Share on other sites
f2k sel 164 Posted February 18, 2011 Well dynamically created groupnames was what I was trying to do but probably didn't ask the right question. I did test the the above code and that works. I seem to have about four ways of doing it now. Thanks. Share this post Link to post Share on other sites
f2k sel 164 Posted June 18, 2011 Sorry to drag up this old thread again but I'm still trying to get this into a function. I have an init file with this in it and a function module on the map. waitUntil { !isNil "BIS_fnc_init" }; _createMyGroup = compile preprocessFile "createMyGroup .sqf"; My function is as follows. _createMyGroup = { private ["_grp"]; _grp = createGroup East; _leader = _group createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"]; _unit = _group createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"]; _unit = _group createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"]; _unit = _group createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"]; _unit = _group createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"]; _leader = leader _group; _grp }; and called with green = [] call createMyGroup and the result is nothing. Share this post Link to post Share on other sites