matte54 10 Posted October 16, 2013 (edited) Been getting a little out of my own league in scripting last few days and i know this is possible and ive seen some examples wich i really cant understand myself. But lets say i want this code run 10 times and change variables each time so each "box" is a diffrent one. Running it like this only places one for me, so im just ASSUMING that its conflicting the variables? for "_i" from 1 to 10 do { _randomPos = [getMarkerPos "area", 5000] call fnc_randomPos; _box = "Box_NATO_Ammo_F" createVehicle (_randomPos); _mrk = "box"; createMarkerLocal [_mrk,_randomPos]; _mrk setMarkerType "mil_dot"; _mrk setMarkerShape "ICON"; _mrk setMarkerColor "ColorRed"; }; anyone care to explain and i would be deeply greatful, i feel like im diving out on the deep end with my scripting now lol. Edited October 19, 2013 by Matte54 Share this post Link to post Share on other sites
cuel 25 Posted October 16, 2013 _mrk = format ["box%1",_i]; ---------- Post added at 05:00 PM ---------- Previous post was at 04:59 PM ---------- It inserts the value of _i into %1 Share this post Link to post Share on other sites
blackmamb 2 Posted October 16, 2013 Well, the idea is here. It should create multiple boxes, but you do have some syntax issues. for "_i" from 1 to 10 do { _randomPos = [getMarkerPos "area", 5000] call fnc_randomPos; _box = "Box_NATO_Ammo_F" createVehicle (_randomPos); _mrk = createMarkerLocal [_mrk,_randomPos]; _mrk setMarkerType "mil_dot"; _mrk setMarkerShape "ICON"; _mrk setMarkerColor "ColorRed"; }; Should work, assuming that fnc_randomPos is defined somewhere. Share this post Link to post Share on other sites
matte54 10 Posted October 16, 2013 _mrk = format ["box%1",_i]; ---------- Post added at 05:00 PM ---------- Previous post was at 04:59 PM ---------- It inserts the value of _i into %1 This is exactly what i was scratching my head over, thank you cuel! I've been looking for some explantion for the "%1" usage. Share this post Link to post Share on other sites
matte54 10 Posted October 19, 2013 im continuing on the same script here asking for some help i seem to have som locality issue i can't resolve. this script runs once thru the initilization of a game logic stashes = [] execvm "stashes.sqf"; Works as intended, but when i host multiplayer the boxes are placed out BUT only me as server gets the randomized content, the others only get a standard Nato Ammo box with standard content. sleep 10; if(!isServer) exitWith{}; _weapons = ["hgun_P07_F", "arifle_MX_F", "arifle_MX_SW_F", "arifle_MXM_F", "arifle_TRG20_F", "srifle_EBR_F", "LMG_Mk200_F", "SMG_01_F", "launch_RPG32_F", "launch_NLAW_F", "Binocular"]; _items = ["NVGoggles", "Medikit", "FirstAidKit", "acc_flashlight", "muzzle_snds_B", "muzzle_snds_L", "optic_Aco", "optic_Arco", "optic_Hamr", "optic_Holosight", "optic_SOS"]; _xpl = ["ClaymoreDirectionalMine_Remote_Mag", "APERSTripMine_Wire_Mag", "SatchelCharge_Remote_Mag", "HandGrenade", "SmokeShell", "UGL_FlareWhite_F", "UGL_FlareRed_F"]; _ammo = ["30Rnd_45ACP_Mag_SMG_01", "RPG32_F", "NLAW_F", "200Rnd_65x39_cased_Box", "30Rnd_556x45_Stanag", "20Rnd_762x51_Mag", "30Rnd_65x39_caseless_mag", "30Rnd_65x39_caseless_mag", "30Rnd_65x39_caseless_mag", "16Rnd_9x21_Mag"]; _backpacks = ["B_AssaultPack_Base", "B_AssaultPack_blk", "B_AssaultPack_khk", "B_AssaultPack_mcamo", "B_FieldPack_Base", "B_AssaultPack_dgtl"]; for "_i" from 1 to 14 do { _randomPos = [getMarkerPos "area", 5000] call fnc_randomPos; _box = "Box_NATO_Ammo_F" createVehicle (_randomPos); clearMagazineCargo _box; clearWeaponCargo _box; clearItemCargo _box; _weapon = _weapons select (floor (random (count _weapons))); _item1 = _items select (floor (random (count _items))); _item2 = _items select (floor (random (count _items))); _explo1 = _xpl select (floor (random (count _xpl))); _explo2 = _xpl select (floor (random (count _xpl))); _am1 = _ammo select (floor (random (count _ammo))); _am2 = _ammo select (floor (random (count _ammo))); _am3 = _ammo select (floor (random (count _ammo))); _am4 = _ammo select (floor (random (count _ammo))); _bp = _backpacks select (floor (random (count _backpacks))); _box addWeaponCargo [_weapon,1]; _box addItemCargo [_item1,1]; _box addItemCargo [_item2,1]; _box addMagazineCargo [_explo1,1]; _box addMagazineCargo [_explo2,1]; _box addMagazineCargo [_am1,1]; _box addMagazineCargo [_am2,1]; _box addMagazineCargo [_am3,1]; _box addMagazineCargo [_am4,1]; _box addBackPackCargo [_bp,1]; _mrk = format ["box%1",_i]; createMarkerLocal [_mrk,_randomPos]; _mrk setMarkerType "mil_dot"; _mrk setMarkerShape "ICON"; _mrk setMarkerColor "ColorRed"; }; Share this post Link to post Share on other sites
Larrow 2822 Posted October 19, 2013 All your cargo commands need to be of the GLOBAL type e.g clearMagazineCargoGlobal, addWeaponCargoGlobal etc Share this post Link to post Share on other sites
austin_medic 109 Posted October 19, 2013 This is exactly what i was scratching my head over, thank you cuel!I've been looking for some explantion for the "%1" usage. You use %X to insert variables into another command. the %NUMBER increases by one if theres two or more variables being put into it. hint format ["number 1 = %1 \n number 2 = %2",round(random 5),round(random 5)]; probably not the best explaination of it but the example should explain it a bit... Share this post Link to post Share on other sites