Belial0harvester 2 Posted May 26 Hi there, I'm really not a good coder I'm afraid. I copy/paste it from wiki or these boards and, through trial and error, I usually manage to do what I want. Thanks, by the way, for all this info. :) But this time I'm confronted with something I have no explanation for. This is a SP mission. Im trying to move the player to a location, have 5 squad members spawn around him and make this whole group move to a location. It worked fine until my group leader got shot and I found myself leading the squad, which I do not want. So, I figured the best way was to give units ranks and I tried this in console with success : player setPos (getMarkerPos "ret1"); private ["_sl","_hmg","_med","_gl","_rf6"]; private _group = createGroup [WEST, true]; _sl = "uns_men_USMC_65_SL" createUnit [getMarkerPos "ret2", _group]; _sl setUnitRank "SERGEANT"; _hmg = "uns_men_USMC_65_HMG" createUnit [getMarkerPos "ret3", _group]; _hmg setUnitRank "SERGEANT"; _med = "uns_men_USMC_65_MED" createUnit [getMarkerPos "ret4", _group]; _med setUnitRank "CORPORAL"; _med getUnitTrait "Medic"; _gl = "uns_men_USMC_65_GL" createUnit [getMarkerPos "ret5", _group]; _gl setUnitRank "CORPORAL"; _rf6 = "uns_men_USMC_65_RF6" createUnit [getMarkerPos "ret6", _group]; _rf6 setUnitRank "CORPORAL"; [player] joinSilent _group; As the lowest ranked soldier, I am never put into leader position when the squad leader dies. But this same code put in a SQF file returns the following error : |#|_gl setunitRank "CORPORAL"; _rf6 = un..." Error Undefined Variable in expression: _gl I tired this : player setPos (getMarkerPos "ret1"); private ["sl","hmg","med","gl","rf6"]; private _group = createGroup [WEST, true]; sl = "uns_men_USMC_65_SL" createUnit [getMarkerPos "ret2", _group]; sl setUnitRank "SERGEANT"; hmg = "uns_men_USMC_65_HMG" createUnit [getMarkerPos "ret3", _group]; hmg setUnitRank "SERGEANT"; med = "uns_men_USMC_65_MED" createUnit [getMarkerPos "ret4", _group]; med setUnitRank "CORPORAL"; med getUnitTrait "Medic"; gl = "uns_men_USMC_65_GL" createUnit [getMarkerPos "ret5", _group]; gl setUnitRank "CORPORAL"; rf6 = "uns_men_USMC_65_RF6" createUnit [getMarkerPos "ret6", _group]; rf6 setUnitRank "CORPORAL"; [player] joinSilent _group; And it returns pretty mcuh the same error. I am at a loss, I'm afraid. If anyone can help please? Regards, Share this post Link to post Share on other sites
JCataclisma 80 Posted May 27 The thing that I have noticed is that --on the MEDIC trait, you have an additional "getUnitTrait", which is not present at the others. Try and remove that "getUnitTrait" line to see if the error stops. Or even better: according to Wiki, you should try the other syntax: player setUnitTrait ["Medic", true]; _med = "uns_men_USMC_65_MED" createUnit [getMarkerPos "ret4", _group]; _med setUnitRank "CORPORAL"; // _med getUnitTrait "Medic"; // try changing this one as bellow or removing this one, for starters; _med setUnitTrait ["Medic", true]; You see, the error you received from the game is prior to "_gl", so it's most likely related to that medic line right before it. Share this post Link to post Share on other sites
pierremgi 4863 Posted May 27 Private is for setting local variables. private ["sl","hmg","med","gl","rf6"]; // wrong anyway private ["_sl","_hmg","_med","_gl","_rf6"]; // these variables are defined and ready for values. In your above code, you are using getUnitTrait instead of setUnitTrait for medic. 1 Share this post Link to post Share on other sites
POLPOX 778 Posted May 27 That syntax of createUnit doesn't return the spawned object. Use main syntax instead. https://community.bistudio.com/wiki/createUnit 2 Share this post Link to post Share on other sites
Belial0harvester 2 Posted May 27 Aaaah, thanks alot everyone, you solved my issue 🙂 This works like a charm : player setPos (getMarkerPos "ret1"); private ["_sl","_hmg","_med","_gl","_rf6"]; private _group = createGroup [WEST, true]; _sl = _group createUnit ["uns_men_USMC_65_SL", getMarkerPos "ret2",[], 0, "NONE"]; _sl setUnitRank "SERGEANT"; _hmg = _group createUnit ["uns_men_USMC_65_HMG", getMarkerPos "ret3",[], 0, "NONE"]; _hmg setUnitRank "SERGEANT"; _med = _group createUnit ["uns_men_USMC_65_MED", getMarkerPos "ret4",[], 0, "NONE"]; _med setUnitRank "CORPORAL"; _med setUnitTrait ["Medic", true]; _gl = _group createUnit ["uns_men_USMC_65_GL", getMarkerPos "ret5",[], 0, "NONE"]; _gl setUnitRank "CORPORAL"; _rf6 = _group createUnit ["uns_men_USMC_65_RF6", getMarkerPos "ret6",[], 0, "NONE"]; _rf6 setUnitRank "CORPORAL"; [player] joinSilent _group; One additional question though : I have to add this medic trait to this unit cause for some reason, UNSUNG USMC corpsman does not behave as such. Does anybody know why? Is this a small overlook maybe? I tried looking into the CfgVehicle entry but I can't figure the difference between this unit and another medical unit which actually does a medic job. I'm not using ACE. This aspect is all vanilla I believe. 1 Share this post Link to post Share on other sites
pierremgi 4863 Posted May 27 Probably because attendant token in not set to 1 in cfgVehicles for UNSUNG medics. attendant = 1; //for vanilla "B_Medic_F" Share this post Link to post Share on other sites
Belial0harvester 2 Posted May 27 Aaah, merci Pierre 🙂 Share this post Link to post Share on other sites