somethingcool 0 Posted February 13, 2008 Hi, I have written this script, arm.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _user = _this select 0; _type = _this select 1; ;hint format["%1", _type]; ({_user removeMagazine _x} forEach magazines _user); Removeallweapons _user; _user addweapon "NVGoggles"; _user addWeapon "Binocular"; _user addMagazine "SmokeShellGreen"; if (_type == 0) then {goto "AT"}; if (_type == 1) then {goto "JAV"}; if (_type == 2) then {goto "GPMG"}; if (_type == 3) then {goto "LMG"}; if (_type == 4) then {goto "LRR"}; if (_type == 5) then {goto "INF"}; if (_type == 6) then {goto "CREW"}; #INF _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "1rnd_he_m203"; _user addMagazine "1rnd_he_m203"; _user addMagazine "1rnd_he_m203"; _user addMagazine "1rnd_he_m203"; _user addWeapon "ukf_l85a2ag36"; _user selectWeapon "ukf_l85a2ag36"; _user addMagazine "ukf_sigP226_mag"; _user addMagazine "ukf_sigP226_mag"; _user addWeapon "ukf_sigP226"; exit #AT _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addWeapon "UKF_L85A2_susat"; _user selectWeapon "UKF_L85A2_susat"; _user addMagazine "ukf_law80"; _user addWeapon "ukf_law80launcher"; _user addMagazine "ukf_sigP226_mag"; _user addMagazine "ukf_sigP226_mag"; _user addMagazine "ukf_sigP226_mag"; _user addWeapon "ukf_sigP226"; exit #JAV _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addMagazine "30rnd_556x45_stanag"; _user addWeapon "UKF_L85A2_susat"; _user selectWeapon "UKF_L85A2_susat"; _user addMagazine "ukf_javelinmag"; _user addWeapon "ukf_javelinlauncher"; _user addMagazine "ukf_sigP226_mag"; _user addMagazine "ukf_sigP226_mag"; _user addMagazine "ukf_sigP226_mag"; _user addWeapon "ukf_sigP226"; exit #LRR _user addMagazine "ukf_10Rnd_762x51_mag"; _user addMagazine "ukf_10Rnd_762x51_mag"; _user addMagazine "ukf_10Rnd_762x51_mag"; _user addMagazine "ukf_10Rnd_762x51_mag"; _user addMagazine "ukf_10Rnd_762x51_mag"; _user addWeapon "ukf_l96a1"; _user selectWeapon "ukf_l96a1"; _user addMagazine "ukf_sigP226_SDmag"; _user addMagazine "ukf_sigP226_SDmag"; _user addMagazine "ukf_sigP226_SDmag"; _user addWeapon "ukf_sigP226_sd"; exit #CREW _user addMagazine "20rnd_556x45_stanag"; _user addMagazine "20rnd_556x45_stanag"; _user addMagazine "20rnd_556x45_stanag"; _user addMagazine "20rnd_556x45_stanag"; _user addWeapon "ukf_l85a2k_susat"; _user selectWeapon "ukf_l85a2k_susat"; exit #LMG _user addMagazine "200rnd_556x45_m249"; _user addMagazine "200rnd_556x45_m249"; _user addMagazine "200rnd_556x45_m249"; _user addMagazine "200rnd_556x45_m249"; _user addWeapon "ukf_lmg_susat"; _user selectWeapon "ukf_lmg_susat"; exit #GPMG _user addMagazine "100rnd_762x51_m240"; _user addMagazine "100rnd_762x51_m240"; _user addMagazine "100rnd_762x51_m240"; _user addMagazine "100rnd_762x51_m240"; _user addWeapon "ukf_gpmg"; _user selectWeapon "ukf_gpmg"; exit exit When I activate it using [this, 3] exec "arm.sqs"; in either the soldiers init line or [s1, 3] exec "arm.sqs" in the init.sqs/f file the script only works if there is only one human in the group, or the group is entirely AI based. For example if I have 8 AI down all with different numbers for weapons they spawn on the dedicated server with the correct weapons, however if I put a player as the lead of that squad none of the script runs on the leader, or the AI in the group, everyone just has M4's. I have tried with and without the exit if server line, thinking it may have had something to do with locality, but I cannot for the life of me make this work. So in short, the script works if there is a single human on his own in a group, or on a group entirely made up for AI. If a human is in the group, the script does not get executed. Does anyone know why this is happening? It all works fine on my own machine, its just once it is uploaded to the dedicated box. Cheers, Share this post Link to post Share on other sites
sickboy 13 Posted February 13, 2008 ... Hey, plz try this sqf: http://www.pastebin.ca/902603 exec with ExecVM instead of Exec. Try adding a sleep 1; Â before you execVM the script. You might want to add a: if (!(local _unit)) exitWith {}; Â under _unit = _this select 0; Â in the script. Altough it might just aswell be as handy to do it directly at every line in init.sqf: if (local s5) then { [s5, 3] execVM "arms.sqf" }; Don't use isServer, because the commands need to be executed where the object is local afaik Share this post Link to post Share on other sites
somethingcool 0 Posted February 13, 2008 Cheers for that mate, as far as I can tell it now works. Heres the final debugged code for anyone that wants it <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> sleep 1; private ["_user", "_type", "_mags", "_weaps"]; _user = _this select 0; // if (!(local _user)) exitWith {}; _type = _this select 1; switch _type do { case 0: { // AT _mags = [ ["30rnd_556x45_stanag", 5], ["ukf_law80", 1], ["ukf_sigP226_mag", 3] ]; _weaps = [ "UKF_L85A2_susat", "ukf_law80launcher", "ukf_sigP226" ]; }; case 1: { // JAV _mags = [ ["30rnd_556x45_stanag", 4], ["ukf_javelinmag", 1], ["ukf_sigP226_mag", 3] ]; _weaps = [ "UKF_L85A2_susat", "ukf_javelinlauncher", "ukf_sigP226" ]; }; case 2: { // GPMG _mags = [ ["100rnd_762x51_m240", 4] ]; _weaps = [ "ukf_gpmg" ]; }; case 3: { // LMG _mags = [ ["200rnd_556x45_m249", 4] ]; _weaps = [ "ukf_lmg_susat" ]; }; case 4: { // LPR _mags = [ ["ukf_10Rnd_762x51_mag", 5], ["ukf_sigP226_SDmag", 3] ]; _weaps = [ "ukf_l96a1", "ukf_sigP226_sd" ]; }; case 5: { // INF _mags = [ ["30rnd_556x45_stanag", 5], ["1rnd_he_m203", 4], ["ukf_sigP226_mag", 2] ]; _weaps = [ "ukf_l85a2ag36", "ukf_sigP226" ]; }; case 6: { // CREW _mags = [ ["20rnd_556x45_stanag", 4] ]; _weaps = [ "ukf_l85a2k_susat" ]; }; }; removeAllWeapons _user; _weaps = _weaps + ["NVGoggles","Binocular"]; _mags = _mags + [ ["SmokeShellGreen", 1 ] ]; { for "_y" from 1 to (_x select 1) do { _user addMagazine (_x select 0) } } forEach _mags; { _user addWeapon _x} forEach _weaps; _user selectWeapon (_weaps select 0); You will note I commented out the "// if (!(local _user)) exitWith {};" because with it on it worked for players, but then not for AI under the players command, with it un commented it works for everyone. So cheers! Share this post Link to post Share on other sites
sickboy 13 Posted February 13, 2008 Cool mate, unsure atm if you need that sleep still, but I guess you tested that aswell. Glad to hear it's working fine. No idea about your SQF, but if you were wondering about the wonders of SQF I guess you got a kickstart Share this post Link to post Share on other sites