Vegatry 10 Posted November 28, 2013 I'm not familiar with switch statement before, and i just get a head start about switch statement . It's seem like switch statement is very similar to if statement but more simplified, but it still struggles me that how do I declare my variables to let computer know what to executed? Should it be something in the unit init like: nul = ["co",this] execVM "blah.sqf"; ? if (isServer) then { //waitUntil {!isNull player && {time > 1}}; //thanks for iceman77, solved JIP issue. _riflemag = "30Rnd_65x39_caseless_mag"; _gl= "1Rnd_HE_Grenade_shell"; switch (_class) do { case "CO": { removeweapons this; this addweaponGlobal "arifle_MX_F"; "this addmagazineGlobal ["_riflemag",15]; hint "This is a CO"; //test if executed }; case "FTL": { removeweapons this; this addweaponGlobal "arifle_MX_GL_F"; this addmagazineGlobal ["_riflemag",13]; this addmagazineGlobal ["_gl",8]; hint "This is a FTL"; //testif executed }; }; Share this post Link to post Share on other sites
big_wilk 12 Posted November 28, 2013 Hi, This should work: _class = _this select 0; if (isServer) then { //waitUntil {!isNull player && {time > 1}}; //thanks for iceman77, solved JIP issue. _riflemag = "30Rnd_65x39_caseless_mag"; _gl= "1Rnd_HE_Grenade_shell"; switch (_class) do { case "CO": { removeweapons this; this addweaponGlobal "arifle_MX_F"; "this addmagazineGlobal ["_riflemag",15]; hint "This is a CO"; //test if executed }; case "FTL": { removeweapons this; this addweaponGlobal "arifle_MX_GL_F"; this addmagazineGlobal ["_riflemag",13]; this addmagazineGlobal ["_gl",8]; hint "This is a FTL"; //testif executed }; }; Share this post Link to post Share on other sites
Vegatry 10 Posted November 28, 2013 Hi,This should work: _class = _this select 0; if (isServer) then { //waitUntil {!isNull player && {time > 1}}; //thanks for iceman77, solved JIP issue. _riflemag = "30Rnd_65x39_caseless_mag"; _gl= "1Rnd_HE_Grenade_shell"; switch (_class) do { case "CO": { removeweapons this; this addweaponGlobal "arifle_MX_F"; "this addmagazineGlobal ["_riflemag",15]; hint "This is a CO"; //test if executed }; case "FTL": { removeweapons this; this addweaponGlobal "arifle_MX_GL_F"; this addmagazineGlobal ["_riflemag",13]; this addmagazineGlobal ["_gl",8]; hint "This is a FTL"; //testif executed }; }; :D thanks, will test it. Seem like just need an array. ---------- Post added at 03:58 ---------- Previous post was at 03:12 ---------- Hi,This should work: _class = _this select 0; if (isServer) then { //waitUntil {!isNull player && {time > 1}}; //thanks for iceman77, solved JIP issue. _riflemag = "30Rnd_65x39_caseless_mag"; _gl= "1Rnd_HE_Grenade_shell"; switch (_class) do { case "CO": { removeweapons this; this addweaponGlobal "arifle_MX_F"; "this addmagazineGlobal ["_riflemag",15]; hint "This is a CO"; //test if executed }; case "FTL": { removeweapons this; this addweaponGlobal "arifle_MX_GL_F"; this addmagazineGlobal ["_riflemag",13]; this addmagazineGlobal ["_gl",8]; hint "This is a FTL"; //testif executed }; }; :( well...the code failed to executed...something's wrong... Share this post Link to post Share on other sites
big_wilk 12 Posted November 28, 2013 (edited) Yeah sorry I did not look very hard at anything but your top line. There are quite a few errors. Here is a script I made once upon a time its virtually identical to yours: ////////////////////////////////////////////////////////////////////////////////////////////////////////////// // by Big_Wilk(armaholic)/Chris2(www.volcbat.com) // // Examples: // nul = [this,"l85susat","brit_normal","ilaw","no","yes","yes"] execVM "LoadOutChanger.sqf"; // nul = [this,"l85susat","brit_lmg","no","yes","no","no"] execVM "LoadOutChanger.sqf"; // goes in units init. // // Options: // nul = [unit,"uniform","weapon?","AT?","medic?","laser designator?","gps?"] execVM "LoadOutChanger.sqf"; // // unit = this // Weapon = l85susat / l85acog / sharpshot / GPMG / lmg / lmgsusat / lmgacog / m4 / m4acog / hk // uniform = brit_normal / brit_lmg / brit_sl / sbs1 / sbs2 // AT? = no / ilaw / nlaw // Medic? = yes / no // Laser Designator? = yes / no // GPS? = yes / no / uav // // nul = [this, "", "", "", "", "", ""] execVM "LoadOutChanger.sqf"; //////////////////////////////////////////////////////////////// Script Starts /////////////////////////////// _player = _this select 0; _units = _this select 1; _uni = _this select 2; _hasat = _this select 3; _ismedic = _this select 4; _designator = _this select 5; _gps = _this select 6; // Removes Everything removeAllWeapons _player; removeGoggles _player; removeHeadgear _player; removeVest _player; removeUniform _player; removeAllAssignedItems _player; sleep .1; // Uniforms switch (_uni) do { case "brit_normal": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "STKR_Osprey_R"; _player addUniform "STKR_UBACS_KNEE"; _player addbackpack "B_Bergen_sgg"; }; case "brit_lmg": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "STKR_Osprey_MG"; _player addUniform "STKR_UBACS_KNEE"; _player addbackpack "B_Bergen_sgg"; }; case "brit_sl": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "STKR_Osprey_SL"; _player addUniform "STKR_UBACS_KNEE"; _player addbackpack "B_Bergen_sgg"; }; case "sbs1": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "V_PlateCarrierL_CTRG"; _player addUniform "U_B_CTRG_1"; _player addbackpack "B_TacticalPack_oli"; }; case "sbs2": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "V_PlateCarrierH_CTRG"; _player addUniform "U_B_CTRG_3"; _player addbackpack "B_TacticalPack_oli"; }; }; sleep .1; // Medic? switch (_ismedic) do { case "no": { _player addItem "FirstAidKit"; }; case "yes": { _player addItem "FirstAidKit"; (unitBackpack _player) additem ["FirstAidKit", 10]; //(unitBackpack _player) additem ["Medikit", 10]; }; }; sleep .1; // Misc Gear - added to all // Grenades {_player addMagazine "HandGrenade"} foreach [1,2,3,4]; {_player addMagazine "smokeshell"} foreach [1,2,3,4]; {_player addMagazine "smokeshellgreen"} foreach [1,2,3,4]; {_player addMagazine "Chemlight_green"} foreach [1,2]; {_player addMagazine "Chemlight_red"} foreach [1,2]; {_player addMagazine "Chemlight_yellow"} foreach [1,2]; sleep .1; // Misc / Items _player additem "ItemMap"; _player assignItem "ItemMap"; _player additem "ItemCompass"; _player assignItem "ItemCompass"; _player additem "ItemWatch"; _player assignItem "ItemWatch"; _player additem "ItemRadio"; _player assignItem "ItemRadio"; _player additem "STKR_HMNVS"; _player assignItem "STKR_HMNVS"; _player addweapon "Binocular"; sleep .1; switch (_units) do { case "l85susat": { {_player addMagazine "30Rnd_556x45_Stanag"} foreach [1,2,3,4]; // Mags on body _player addweapon "VCB_L85A2"; // Weapon _player addPrimaryWeaponItem "VCB_SUSAT"; // Scope _player addPrimaryWeaponItem "acc_pointer_IR"; (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 8]; // Mags in Bag }; case "l85acog": { {_player addMagazine "30Rnd_556x45_Stanag"} foreach [1,2,3,4,5,6,7]; // Mags on body _player addweapon "VCB_L85A2"; // Weapon //_player addPrimaryWeaponItem ""; }; case "sharpshot": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "gpmg": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "lmg": { {_player addMagazine "VCB_L110A1"} foreach [1,2,3]; // Mags on body _player addweapon "VCB_L110A1"; // Weapon (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 3]; // Mags in Bag }; case "lmgsusat": { {_player addMagazine "VCB_L110A1"} foreach [1,2,3]; // Mags on body _player addweapon "VCB_L110A1"; // Weapon _player addPrimaryWeaponItem "VCB_SUSAT"; (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 3]; // Mags in Bag }; case "lmgacog": { {_player addMagazine ""} foreach [1,2,3]; // Mags on body _player addweapon "VCB_L110A1"; // Weapon _player addPrimaryWeaponItem ""; (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 3]; // Mags in Bag }; case "m4": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "m4acog": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "hk": { {_player addMagazine "R3F_20Rnd_762x51_HK417"} foreach [1,2,3]; // Mags on body _player addweapon "R3F_HK417M"; // Weapon _player addPrimaryWeaponItem "R3F_EOTECH"; (unitBackpack _player) addMagazineCargo ["R3F_20Rnd_762x51_HK417", 8]; // Mags in Bag // R3F_20Rnd_762x51_TRACER_HK417 }; case "SOMETHING": { {_player addMagazine "MAG"} foreach [1,2,3]; // Mags on body _player addweapon "GUN"; // Weapon _player addPrimaryWeaponItem "SCOPE"; (unitBackpack _player) addMagazineCargo ["MAG", 8]; // Mags in Bag }; }; sleep .1; // At switch (_hasat) do { case "no": { // end }; case "ilaw": { _player addMagazine "R3F_AT4CS_Mag"; _player addWeapon "R3F_AT4CS"; }; case "nlaw": { _player addMagazine "M_NLAW_AT_F"; _player addWeapon "VCB_MBT_LAW"; }; case "SOMETHING": { _player addMagazine "MAGCODE"; _player addWeapon "GUNCODE"; }; }; sleep .1; // At switch (_designator) do { case "no": { // end }; case "yes": { _player addMagazine "Laserbatteries"; _player addWeapon "Laserdesignator"; }; }; sleep .1; // At switch (_gps) do { case "no": { // end }; case "yes": { _player additem "ItemGPS"; _player assignItem "ItemGPS"; }; }; Just copy and paste. There are few options in there like do you want them to have gps and what not as well. Note some of the class names are mods so change them to whatever you need obv. Weapons, NVG and some uniforms are all mods class names. Try this in your units Init feild (you will get a few not found errors without editing it rember): nul = [this,"l85susat","sbs1","nlaw","no","yes","yes"] execVM "LoadOutChanger.sqf"; Edited November 28, 2013 by Big_Wilk Share this post Link to post Share on other sites
Vegatry 10 Posted November 28, 2013 Yeah sorry I did not look very hard at anything but your top line. There are quite a few errors. Here is a script I made once upon a time its virtually identical to yours: ////////////////////////////////////////////////////////////////////////////////////////////////////////////// // by Big_Wilk(armaholic)/Chris2(www.volcbat.com) // // Examples: // nul = [this,"l85susat","brit_normal","ilaw","no","yes","yes"] execVM "LoadOutChanger.sqf"; // nul = [this,"l85susat","brit_lmg","no","yes","no","no"] execVM "LoadOutChanger.sqf"; // goes in units init. // // Options: // nul = [unit,"uniform","weapon?","AT?","medic?","laser designator?","gps?"] execVM "LoadOutChanger.sqf"; // // unit = this // Weapon = l85susat / l85acog / sharpshot / GPMG / lmg / lmgsusat / lmgacog / m4 / m4acog / hk // uniform = brit_normal / brit_lmg / brit_sl / sbs1 / sbs2 // AT? = no / ilaw / nlaw // Medic? = yes / no // Laser Designator? = yes / no // GPS? = yes / no / uav // // nul = [this, "", "", "", "", "", ""] execVM "LoadOutChanger.sqf"; //////////////////////////////////////////////////////////////// Script Starts /////////////////////////////// _player = _this select 0; _units = _this select 1; _uni = _this select 2; _hasat = _this select 3; _ismedic = _this select 4; _designator = _this select 5; _gps = _this select 6; // Removes Everything removeAllWeapons _player; removeGoggles _player; removeHeadgear _player; removeVest _player; removeUniform _player; removeAllAssignedItems _player; sleep .1; // Uniforms switch (_uni) do { case "brit_normal": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "STKR_Osprey_R"; _player addUniform "STKR_UBACS_KNEE"; _player addbackpack "B_Bergen_sgg"; }; case "brit_lmg": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "STKR_Osprey_MG"; _player addUniform "STKR_UBACS_KNEE"; _player addbackpack "B_Bergen_sgg"; }; case "brit_sl": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "STKR_Osprey_SL"; _player addUniform "STKR_UBACS_KNEE"; _player addbackpack "B_Bergen_sgg"; }; case "sbs1": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "V_PlateCarrierL_CTRG"; _player addUniform "U_B_CTRG_1"; _player addbackpack "B_TacticalPack_oli"; }; case "sbs2": { _player addheadgear "STKR_MK7_ScrimB"; _player addvest "V_PlateCarrierH_CTRG"; _player addUniform "U_B_CTRG_3"; _player addbackpack "B_TacticalPack_oli"; }; }; sleep .1; // Medic? switch (_ismedic) do { case "no": { _player addItem "FirstAidKit"; }; case "yes": { _player addItem "FirstAidKit"; (unitBackpack _player) additem ["FirstAidKit", 10]; //(unitBackpack _player) additem ["Medikit", 10]; }; }; sleep .1; // Misc Gear - added to all // Grenades {_player addMagazine "HandGrenade"} foreach [1,2,3,4]; {_player addMagazine "smokeshell"} foreach [1,2,3,4]; {_player addMagazine "smokeshellgreen"} foreach [1,2,3,4]; {_player addMagazine "Chemlight_green"} foreach [1,2]; {_player addMagazine "Chemlight_red"} foreach [1,2]; {_player addMagazine "Chemlight_yellow"} foreach [1,2]; sleep .1; // Misc / Items _player additem "ItemMap"; _player assignItem "ItemMap"; _player additem "ItemCompass"; _player assignItem "ItemCompass"; _player additem "ItemWatch"; _player assignItem "ItemWatch"; _player additem "ItemRadio"; _player assignItem "ItemRadio"; _player additem "STKR_HMNVS"; _player assignItem "STKR_HMNVS"; _player addweapon "Binocular"; sleep .1; switch (_units) do { case "l85susat": { {_player addMagazine "30Rnd_556x45_Stanag"} foreach [1,2,3,4]; // Mags on body _player addweapon "VCB_L85A2"; // Weapon _player addPrimaryWeaponItem "VCB_SUSAT"; // Scope _player addPrimaryWeaponItem "acc_pointer_IR"; (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 8]; // Mags in Bag }; case "l85acog": { {_player addMagazine "30Rnd_556x45_Stanag"} foreach [1,2,3,4,5,6,7]; // Mags on body _player addweapon "VCB_L85A2"; // Weapon //_player addPrimaryWeaponItem ""; }; case "sharpshot": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "gpmg": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "lmg": { {_player addMagazine "VCB_L110A1"} foreach [1,2,3]; // Mags on body _player addweapon "VCB_L110A1"; // Weapon (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 3]; // Mags in Bag }; case "lmgsusat": { {_player addMagazine "VCB_L110A1"} foreach [1,2,3]; // Mags on body _player addweapon "VCB_L110A1"; // Weapon _player addPrimaryWeaponItem "VCB_SUSAT"; (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 3]; // Mags in Bag }; case "lmgacog": { {_player addMagazine ""} foreach [1,2,3]; // Mags on body _player addweapon "VCB_L110A1"; // Weapon _player addPrimaryWeaponItem ""; (unitBackpack _player) addMagazineCargo ["30Rnd_556x45_Stanag", 3]; // Mags in Bag }; case "m4": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "m4acog": { //{_player addMagazine ""} foreach [1,2,3,4,5,6,7]; // Mags on body //_player addweapon ""; // Weapon //_player addPrimaryWeaponItem ""; }; case "hk": { {_player addMagazine "R3F_20Rnd_762x51_HK417"} foreach [1,2,3]; // Mags on body _player addweapon "R3F_HK417M"; // Weapon _player addPrimaryWeaponItem "R3F_EOTECH"; (unitBackpack _player) addMagazineCargo ["R3F_20Rnd_762x51_HK417", 8]; // Mags in Bag // R3F_20Rnd_762x51_TRACER_HK417 }; case "SOMETHING": { {_player addMagazine "MAG"} foreach [1,2,3]; // Mags on body _player addweapon "GUN"; // Weapon _player addPrimaryWeaponItem "SCOPE"; (unitBackpack _player) addMagazineCargo ["MAG", 8]; // Mags in Bag }; }; sleep .1; // At switch (_hasat) do { case "no": { // end }; case "ilaw": { _player addMagazine "R3F_AT4CS_Mag"; _player addWeapon "R3F_AT4CS"; }; case "nlaw": { _player addMagazine "M_NLAW_AT_F"; _player addWeapon "VCB_MBT_LAW"; }; case "SOMETHING": { _player addMagazine "MAGCODE"; _player addWeapon "GUNCODE"; }; }; sleep .1; // At switch (_designator) do { case "no": { // end }; case "yes": { _player addMagazine "Laserbatteries"; _player addWeapon "Laserdesignator"; }; }; sleep .1; // At switch (_gps) do { case "no": { // end }; case "yes": { _player additem "ItemGPS"; _player assignItem "ItemGPS"; }; }; Just copy and paste. There are few options in there like do you want them to have gps and what not as well. Note some of the class names are mods so change them to whatever you need obv. Weapons, NVG and some uniforms are all mods class names. Try this in your units Init feild (you will get a few not found errors without editing it rember): nul = [this,"l85susat","sbs1","nlaw","no","yes","yes"] execVM "LoadOutChanger.sqf"; Perfect! Works like charms. Many thanks for your patient. Share this post Link to post Share on other sites
big_wilk 12 Posted November 28, 2013 Cool Stuff. I might one day get round to finishing it off lol... Share this post Link to post Share on other sites
iceman77 18 Posted November 28, 2013 if (isServer) then { //waitUntil {!isNull player && {time > 1}}; //thanks for iceman77, solved JIP issue. _riflemag = "30Rnd_65x39_caseless_mag"; _gl= "1Rnd_HE_Grenade_shell"; switch (_class) do { case "CO": { removeweapons this; this addweaponGlobal "arifle_MX_F"; "this addmagazineGlobal ["_riflemag",15]; hint "This is a CO"; //test if executed }; case "FTL": { removeweapons this; this addweaponGlobal "arifle_MX_GL_F"; this addmagazineGlobal ["_riflemag",13]; this addmagazineGlobal ["_gl",8]; hint "This is a FTL"; //testif executed }; }; Just so you know, the player variable doesn't exist on a dedicated server. So that isNull player check within the server wrap will do nothing except for halt the script as the player will never be valid on the server. Share this post Link to post Share on other sites
big_wilk 12 Posted November 28, 2013 Yar, I don't see any reason for if (isServer) then {}; Hence I never used it since we are working in the init of a unit and are defineing what _player is. Share this post Link to post Share on other sites
iceman77 18 Posted November 28, 2013 Check your mail :) Share this post Link to post Share on other sites