RonnieJ 10 Posted February 15, 2010 Hey guys im trying this: if (playerSide == west) then { execVM "scripts\stand_weap_all.sqf"; switch (player) do { case s1: { execVM "scripts\stand_weap_gf.sqf"; }; case s2: { execVM "scripts\stand_weap_at.sqf"; }; case s3: { execVM "scripts\stand_weap_san.sqf"; }; case s4: { execVM "scripts\stand_weap_lmg.sqf"; }; case s5: { execVM "scripts\stand_weap_rifle.sqf"; }; case s6: { execVM "scripts\stand_weap_smaw.sqf"; }; case s7: { execVM "scripts\stand_weap_gf.sqf"; }; case s8: { execVM "scripts\stand_weap_at.sqf"; }; case s9: { execVM "scripts\stand_weap_san.sqf"; }; case s10: { execVM "scripts\stand_weap_lmg.sqf"; }; case s11: { execVM "scripts\stand_weap_rifle.sqf"; }; case s12: { execVM "scripts\stand_weap_smaw.sqf"; }; }; }; But not all players are there so the switch crashed cause its trying to ask on an object that dosent exist... any ideas? :confused: Share this post Link to post Share on other sites
dmarkwick 259 Posted February 15, 2010 In the stand_weap_gf.sqf etc scripts try something like if !(isNull _soldier) then.... etc. Share this post Link to post Share on other sites
shuko 45 Posted February 15, 2010 Could just use command typeof to check player units class and make it give weapons based on classes instead of nonflexible unit names. Share this post Link to post Share on other sites
RonnieJ 10 Posted February 15, 2010 But if im not interestet in using typeof since I allready know which players is what... then what would you surgest shk... the script fails because the players dosent exist... if im trying s11 it tries s1 first and fails... I think its because s1 isent an object Share this post Link to post Share on other sites
dmarkwick 259 Posted February 15, 2010 (edited) Then you will need to sort out which units exist prior to processing them. Use a loop using isNull as I showed before to weed out the non-objects, placing the remaining objects into an array or something. Then process everything in the array. Edited February 15, 2010 by DMarkwick Share this post Link to post Share on other sites
shuko 45 Posted February 15, 2010 Change it to a string? _str = str player; switch _str do { case "s1" :{}; case "s2" :{}; Share this post Link to post Share on other sites
RonnieJ 10 Posted February 15, 2010 strange im still having some issues... it looks like it helped: if (playerSide == west) then { _str = str player; execVM "scripts\stand_weap_all.sqf"; switch (_str) do { case "s1": { hint "1"; execVM "scripts\stand_weap_gf.sqf"; }; case "s2": { hint "2"; execVM "scripts\stand_weap_at.sqf"; }; case "s3": { hint "3"; execVM "scripts\stand_weap_san.sqf"; }; case "s4": { hint "4"; execVM "scripts\stand_weap_lmg.sqf"; }; case "s5": { hint "5"; execVM "scripts\stand_weap_rifle.sqf"; }; case "s6": { hint "6"; execVM "scripts\stand_weap_smaw.sqf"; }; case "s7": { hint "7"; execVM "scripts\stand_weap_gf.sqf"; }; case "s8": { hint "8"; execVM "scripts\stand_weap_at.sqf"; }; case "s9": { hint "9"; execVM "scripts\stand_weap_san.sqf"; }; case "s10": { hint "10"; execVM "scripts\stand_weap_lmg.sqf"; }; case "s11": { hint "11"; execVM "scripts\stand_weap_rifle.sqf"; }; case "s12": { hint "12"; execVM "scripts\stand_weap_smaw.sqf"; }; }; }; now I get the "10" hint and the player name is "s10"... running the mission in editor mode gives me all the weapons and items that the script should... but as hosted server I dont... the script is: hint "running"; player addWeapon "DDAM_MG62_optic"; player addMagazine "100Rnd_762x51_M240"; player addMagazine "100Rnd_762x51_M240"; player addMagazine "100Rnd_762x51_M240"; player addMagazine "100Rnd_762x51_M240"; player addWeapon "ACE_GLOCK18"; player addMagazine "ACE_33RND_9X19_G18"; player addMagazine "ACE_33RND_9X19_G18"; player addMagazine "ACE_33RND_9X19_G18"; player addMagazine "ACE_33RND_9X19_G18"; player addMagazine "ACE_BANDAGE"; player addMagazine "ACE_MORPHINE"; hint "done"; now I get the hint "done" så the file is run but the items dosent get added... does it need a sleep or something? ---------- Post added at 10:36 PM ---------- Previous post was at 10:16 PM ---------- Hmm tried with waitUntil { alive player }; but that still didnt work but the sleep 1; did :S Share this post Link to post Share on other sites
shuko 45 Posted February 16, 2010 When switching weapons, it always needs to be done "in the game", not in briefing. Thus sleep 1 or waituntil {time>0} is needed. Share this post Link to post Share on other sites