ToejaM 1 Posted October 4, 2014 (edited) Hey guys I found this script: limit = 2; numberOfKits = {"FirstAidKit" == _x} count (items player); if (numberOfKits > limit) then { for "_i" from 1 to (numberOfKits - limit) do { player removeItem "FirstAidKit"; }; }; Which I modified to look like this: if(typeOf player == "B_medic_F") then {limit = 3;} else {limit = 1; }; numberOfKits = {"cse_personal_aid_kit" == _x} count (magazines player); if (numberOfKits > limit) then { for "_i" from 1 to (numberOfKits - limit) do { player removeMagazine "cse_personal_aid_kit"; }; }; sleep 10; execvm "scripts\medicno.sqf"; What I want it to do is check every X seconds if players have too many of these kits on them, as I want to limit it to 3 per medic and 1 for anyone else. It just doesn't seem to work right, it sometimes removes all medickits and sometimes it doesn't, it just doesn't consistently work.. what have I done wrong? Edit: It appears I was forgetting that my init\gear.sqf I made wipes the inventory.. and thats how I was calling it (as the init is done on player join, so it sets this script up to exec every 10seconds (will increase to something like 60 later on as these kits are only available in base so a quick check isnt needed).. Proper brain fart :D Edited October 4, 2014 by ToejaM nm it does work lol Share this post Link to post Share on other sites
killzone_kid 1331 Posted October 4, 2014 nvm I see you edited it Share this post Link to post Share on other sites
ToejaM 1 Posted October 4, 2014 Just to clarify. When my mission starts, it waits for the player to be alive and then the main init.sqf runs: init\gear.sqf inside this sqf is all different types of if typeof player ==.. this is to give each player a unique loadout depending on class. I tried running it from the init in the editor but that gave me so many issues I just gave up and this is the best way I've found to do it! //Medic if(typeOf player == "B_medic_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; ... ... execvm "scripts\medkitlimit.sqf"; }; //IC if(typeOf player == "B_Soldier_TL_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; ... ... execvm "scripts\medkitlimit.sqf"; }; Then inside scripts\medkitlimit.sqf is: player sidechat "Starting Cycle"; // debug if(typeOf player == "B_medic_F") then {limit = 3;} else {limit = 1; }; numberOfKits = {"cse_personal_aid_kit" == _x} count (magazines player); if (numberOfKits > limit) then { for "_i" from 1 to (numberOfKits - limit) do { player removeMagazine "cse_personal_aid_kit"; }; }; sleep 10; execvm "scripts\medkitlimit.sqf"; I dont know if there is a better way to do this. I dont want to run the medkitlimit.sqf directly from the mission init.sqf as I dont understand if its going to globally init for all players and then run the sqf more times than needed, at least going on my learning of gear inits.. it will only run per that player. I think.. lol Thoughts? Share this post Link to post Share on other sites
iceman77 18 Posted October 4, 2014 (edited) Well you're running the script on the each player object's machine. You may want to make sure the player variable is initialized though so there's no hitches with JIPs and such. ie; if (!isDedicated) then { waitUntil {!(isNull player) && {time > 0}}; if(typeOf player == "B_medic_F") then { execvm "scripts\medkitlimit.sqf"; }; if(typeOf player == "B_Soldier_TL_F") then { execvm "scripts\medkitlimit.sqf"; }; }; // . . . more stuff . . . // Also, why not use switch instead of alot of ifs? if (!isDedicated) then { waitUntil {!(isNull player) && {time > 0}}; switch (typeOf player) do { case "B_medic_F":{execvm "scripts\medkitlimit.sqf";}; case "B_Soldier_TL_F":{execvm "scripts\medkitlimit.sqf";}; default {execvm "scripts\someScript.sqf";}; // Default value used if no matches found (good practice and safe) }; }; Edited October 4, 2014 by Iceman77 Share this post Link to post Share on other sites
ToejaM 1 Posted October 4, 2014 I see what you're saying and I think you mean this at the top of my init\gear.sqf: if(!hasInterface) exitWith {}; if(isDedicated) exitWith {}; waitUntil {!isNull player}; waitUntil {isPlayer player}; waitUntil {!isNull(findDisplay 46)}; //removeAllAssignedItems player; clearBackpackCargo player; removeAllWeapons player; removeAllItems player; removeAllContainers player; removeHeadgear player; player unassignItem "NVGoggles"; player removeItem "NVGoggles"; for[{_num = 0},{_num <= 100},{_num = _num + 1}] do { player removeAction _num; }; //RiflemanAT if(typeOf player == "B_soldier_LAT_F") then { ... ... Is that what you mean? :) With the switches, is it more efficient/better ? The init\gear.sqf is only called if a player joins the server or they respawn so its not in constant use :) Share this post Link to post Share on other sites
iceman77 18 Posted October 4, 2014 Yeah that's what I mean. A switch statement will stop evaluating the conditions once one returns true. Unlike stacking ifs. If it's only a couple conditions to check I wouldn't worry about it though. Share this post Link to post Share on other sites
ToejaM 1 Posted October 4, 2014 Yeah there isn't alot to my mission that I've written that can't be done in the editor or with other mods. Simply it stops people carrying too many medkits and the other time if statements are used is on initial gear setup and for around 10-12 people at the start of the mission its fine.. then its random throughout depending on death and respawn. Pretty simple stuff but it means I dont have to check if people are taking too many medkits with them. If anyones wondering, we're a casual group and as a small section its just not viable to keep flying back everytime someone needs a wound to be stitched up so the solution is to allow a certain amount of full heal hits (using CSE) and once those have run out, the only way to resupply is to head back.. so there is a penalty for constantly catching a bullet, it just means we dont spend as much time in a vehicle.. you could argue we should be more careful but again as one section we lack the real support either side of us that stops us being heavily outflanked and ambushed almost every engagement thanks to @ALiVE haha! I just know that people will get a little bored or sneaky and try and take more medkits with them than I'd like and tbh I'd rather not have an argument when I can simply script it out of being possible as we do try and maintain as much realism as possible without breaking the game, we also force first person. I appreciate the help people :) Share this post Link to post Share on other sites
dreadedentity 278 Posted October 4, 2014 (edited) I dont want to run the medkitlimit.sqf directly from the mission init.sqf as I dont understand if its going to globally init for all players and then run the sqf more times than needed Since all players run init.sqf (and dedicated servers), anything you put in there is "global" in the sense that everybody in the mission will run the commands. But no, it's not "truly global" in the sense that one command will affect all players, unless you use global commands. Thinking about multiplayer makes my head hurt. That said, you can just add a while loop with "true" as the condition. scripts\medkitlimit.sqf while {true} do { if(typeOf player == "B_medic_F") then { limit = 3; } else { limit = 1; }; numberOfKits = {"cse_personal_aid_kit" == _x} count (magazines player); if (numberOfKits > limit) then { hintSilent format["You are carrying %1 extra medkits, they will be removed from your inventory.", numberOfKits - limit]; //personal touch, lets players know they've been caught trying to bend the rules. for "_i" from 1 to (numberOfKits - limit) do { player removeMagazine "cse_personal_aid_kit"; }; }; sleep 10; }; init\gear.sqf execvm "scripts\medkitlimit.sqf"; //change this medkitCheck = execvm "scripts\medkitlimit.sqf"; //to this //at any time if you wish to stop checking medkits make the client's machine run: terminate medkitCheck; Hope that helps Edited October 5, 2014 by DreadedEntity Share this post Link to post Share on other sites
ToejaM 1 Posted October 5, 2014 (edited) Look at you, throwing all the pleasantries in there (letting people know that things are missing from their inventory ;)) - I didnt even think to add that, too focused on the workings of it! Appreciated! Its definitely good to future proof it.. just incase I do need to stop it for some reason. I was thinking of putting an addaction on a crate in the HQ/FOB that runs init\gear.sqf which would re-run the medic check, if I was going to do this would the best way to do it be like this or would I need another if statement instead? medkitCheck = execvm "scripts\medkitlimit.sqf"; terminate medkitCheck; medkitCheck = execvm "scripts\medkitlimit.sqf"; or could I just add: terminate medkitCheck; medkitCheck = execvm "scripts\medkitlimit.sqf"; Will this throw up an error when trying to terminate something that hasnt started? I like the information part to it, I've gone for this: hintSilent format["You are trying to carry %1 too many medkits. You are only able to carry %2! Excess medkits have been removed.", numberOfKits - limit, limit]; Edited October 5, 2014 by ToejaM Share this post Link to post Share on other sites
dreadedentity 278 Posted October 5, 2014 (edited) Will this throw up an error when trying to terminate something that hasnt started? Yes. I didn't think about that. medkitCheck = execVM "scripts\medkitlimit.sqf"; //replace this //with this if (isNil "medkitCheck) then { medkitCheck = execvm "scripts\medkitlimit.sqf"; }; Good job changing the hint to be plural, if you had left it singular, you would have to add in a check and display different text or else let quality suffer. I just realized that also and began writing one, but I checked and your wording is already pretty good. Its definitely good to future proof it.. just incase I do need to stop it for some reason. I was thinking of putting an addaction on a crate in the HQ/FOB that runs init\gear.sqf which would re-run the medic check No it wasn't for future-proofing, just good practice. I'm not sure how the other guys do it, but any time I spawn a script that will run infinitely, I always assign a handle so it's easy to terminate if I ever need/want to and it was a good thing I did because you wanted to terminate it in the very next sentence :p Unless it's a script that is never meant to be terminated/reloaded, like a hunger/thirst tracker. Edited October 5, 2014 by DreadedEntity Share this post Link to post Share on other sites
ToejaM 1 Posted October 5, 2014 (edited) I have to make everything as perfect as possible, I can't help myself.. I'm no scripter, I just pickup bits here and there and google / look at the BIS wiki when I need to learn something new but when I do it.. it has to be perfect! lol Ok so here is my full gear.sqf and I was thinking, that I won't need it to exec the script per player but rather could do it above and out of any of the if statements like this: As all of the specifics are handled within the actual medkitlimit.sqf - that should work right? if(!hasInterface) exitWith {}; if(isDedicated) exitWith {}; waitUntil {!isNull player}; waitUntil {isPlayer player}; waitUntil {!isNull(findDisplay 46)}; //removeAllAssignedItems player; clearBackpackCargo player; removeAllWeapons player; removeAllItems player; removeAllContainers player; removeHeadgear player; player unassignItem "NVGoggles"; player removeItem "NVGoggles"; for[{_num = 0},{_num <= 100},{_num = _num + 1}] do { player removeAction _num; }; if (isNil "medkitCheck") then { medkitCheck = execvm "scripts\medkitlimit.sqf"; }; //RiflemanAT if(typeOf player == "B_soldier_LAT_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; player addWeapon "ItemWatch"; player addWeapon "ItemGPS"; player addWeapon "ItemMap"; player addWeapon "Binocular"; //Backpack player addBackpack "B_Kitbag_mcamo"; //Weapon player addMagazine "30Rnd_556x45_Stanag"; player addWeapon "ej_l85a2"; player addPrimaryWeaponItem "optic_hamr"; //Backpack Contents player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "Trixie_200Rnd"; player addMagazine "mas_M136"; player addMagazine "mas_M136"; player addMagazine "mas_M136"; //Vest player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "cse_morphine"; player addItemToVest "cse_epinephrine"; player addItemToVest "cse_quikclot"; player addItemToVest "cse_packing_bandage"; player addItemToVest "cse_bandage_basic"; player addItemToVest "HandGrenade"; player addItemToVest "HandGrenade"; player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; //Launcher player addWeapon "mas_launch_m136_F"; //vehicle player addAction ['<t color=''#FF0033''>Radio:</t>', 'radio\radio.sqf']; //execvm "scripts\medkitlimit.sqf"; }; // Section 1IC if(typeOf player == "B_Soldier_SL_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; player addWeapon "ItemWatch"; player addWeapon "ItemGPS"; player addWeapon "ItemMap"; player addWeapon "Binocular"; //Backpack player addBackpack "B_Kitbag_mcamo"; //Weapon player addMagazine "30Rnd_556x45_Stanag"; player addWeapon "ej_l85a2ugl"; player addPrimaryWeaponItem "optic_hamr"; //Backpack Contents player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addItem "ALiVE_Tablet"; player addMagazine "Trixie_200Rnd"; //Vest player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addItemToVest "HandGrenade"; player addItemToVest "HandGrenade"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "cse_morphine"; player addItemToVest "cse_epinephrine"; player addItemToVest "cse_quikclot"; player addItemToVest "cse_packing_bandage"; player addItemToVest "cse_bandage_basic"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; //Uniform player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; [player, requester, provider] call BIS_fnc_addSupportLink; vehicle player addAction ['<t color=''#FF0033''>Radio:</t>', 'radio\radio.sqf']; //execvm "scripts\medkitlimit.sqf"; }; //2IC if(typeOf player == "B_Soldier_TL_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; player addWeapon "ItemWatch"; player addWeapon "ItemGPS"; player addWeapon "ItemMap"; player addWeapon "Binocular"; //Backpack player addBackpack "B_Kitbag_mcamo"; //Weapon player addMagazine "30Rnd_556x45_Stanag"; player addWeapon "ej_l85a2ugl"; player addPrimaryWeaponItem "optic_hamr"; //Backpack Contents player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addItem "ALiVE_Tablet"; player addMagazine "Trixie_200Rnd"; //Vest player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addItemToVest "HandGrenade"; player addItemToVest "HandGrenade"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "cse_morphine"; player addItemToVest "cse_epinephrine"; player addItemToVest "cse_quikclot"; player addItemToVest "cse_packing_bandage"; player addItemToVest "cse_bandage_basic"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_HE_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; player addItemToVest "1Rnd_SmokeYellow_Grenade_shell"; //Uniform player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; [player, requester, provider] call BIS_fnc_addSupportLink; vehicle player addAction ['<t color=''#FF0033''>Radio:</t>', 'radio\radio.sqf']; //execvm "scripts\medkitlimit.sqf"; }; //Medic if(typeOf player == "B_medic_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; player addWeapon "ItemWatch"; player addWeapon "ItemGPS"; player addWeapon "ItemMap"; player addWeapon "Binocular"; //Backpack player addBackpack "B_Kitbag_mcamo"; //Weapon player addMagazine "30Rnd_556x45_Stanag"; player addWeapon "ej_l85a2"; player addPrimaryWeaponItem "optic_hamr"; //Backpack Contents player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "HandGrenade"; player addMagazine "HandGrenade"; player addMagazine "cse_morphine"; player addMagazine "cse_epinephrine"; player addMagazine "cse_morphine"; player addMagazine "cse_epinephrine"; player addMagazine "cse_morphine"; player addMagazine "cse_epinephrine"; player addMagazine "cse_morphine"; player addMagazine "cse_epinephrine"; player addMagazine "cse_morphine"; player addMagazine "cse_epinephrine"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_atropine"; player addMagazine "cse_atropine"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_liquidSkin"; player addMagazine "cse_liquidSkin"; player addMagazine "cse_liquidSkin"; player addMagazine "cse_liquidSkin"; player addMagazine "cse_liquidSkin"; player addMagazine "cse_liquidSkin"; player addMagazine "cse_splint"; player addMagazine "cse_splint"; player addMagazine "Trixie_200Rnd"; //Vest player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addItemToVest "HandGrenade"; player addItemToVest "HandGrenade"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "cse_morphine"; player addItemToVest "cse_epinephrine"; player addItemToVest "cse_quikclot"; player addItemToVest "cse_packing_bandage"; player addItemToVest "cse_bandage_basic"; //Uniform player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; //vehicle player addAction ['<t color=''#FF0033''>Radio:</t>', 'radio\radio.sqf']; //execvm "scripts\medkitlimit.sqf"; }; //Marksman if(typeOf player == "B_soldier_M_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; player addWeapon "ItemWatch"; player addWeapon "ItemGPS"; player addWeapon "ItemMap"; player addWeapon "Rangefinder"; //Backpack player addBackpack "B_Kitbag_mcamo"; //Weapon player addMagazine "Trixie_20Rnd"; player addWeapon "Trixie_L129A1_HG_Bipod"; player addPrimaryWeaponItem "optic_DMS"; //Backpack Contents player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "Trixie_200Rnd"; player addMagazine "mas_M136"; //Vest player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addItemToVest "HandGrenade"; player addItemToVest "HandGrenade"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "Trixie_20Rnd"; player addItemToVest "cse_morphine"; player addItemToVest "cse_epinephrine"; player addItemToVest "cse_quikclot"; player addItemToVest "cse_packing_bandage"; player addItemToVest "cse_bandage_basic"; //Uniform player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; //vehicle player addAction ['<t color=''#FF0033''>Radio:</t>', 'radio\radio.sqf']; //execvm "scripts\medkitlimit.sqf"; }; /* case "lsw": { player addWeapon "ItemRangefinder"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "30Rnd_556x45_Stanag"; player addMagazine "Trixie_200Rnd"; player addWeapon "Trixie_L86A2"; player addPrimaryWeaponItem "optic_hamr"; player addMagazine "cse_morphine"; player addMagazine "cse_epinephrine"; player addMagazine "cse_quikclot"; player addMagazine "HandGrenade"; player addMagazine "HandGrenade"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_atropine"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_chestseal"; player addMagazine "cse_chestseal"; player addMagazine "cse_liquidSkin"; player addMagazine "cse_splint"; }; */ //Engineer if(typeOf player == "B_engineer_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; player addWeapon "ItemWatch"; player addWeapon "ItemGPS"; player addWeapon "ItemMap"; player addWeapon "Binocular"; //Backpack player addBackpack "B_Kitbag_mcamo"; //Weapon player addMagazine "30Rnd_556x45_Stanag"; player addWeapon "ej_l85a2"; player addPrimaryWeaponItem "optic_hamr"; //Backpack Contents player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_personal_aid_kit"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "Trixie_200Rnd"; player additem "MineDetector"; //Vest player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"; player addItemToVest "cse_morphine"; player addItemToVest "cse_epinephrine"; player addItemToVest "cse_quikclot"; player addItemToVest "cse_packing_bandage"; player addItemToVest "cse_bandage_basic"; player addItemToVest "HandGrenade"; player addItemToVest "HandGrenade"; player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; //Launcher player addMagazine "mas_M136"; player addMagazine "mas_M136"; player addWeapon "mas_launch_m136_F"; player addWeapon "MineDetector"; //Satchels player addMagazine "SatchelCharge_Remote_Mag"; player addMagazine "DemoCharge_Remote_Mag"; player addMagazine "DemoCharge_Remote_Mag"; //vehicle player addAction ['<t color=''#FF0033''>Radio:</t>', 'radio\radio.sqf']; //execvm "scripts\medkitlimit.sqf"; }; // LMG if(typeOf player == "B_soldier_AR_F") then { //Misc player addWeapon "ACRE_PRC148"; player addWeapon "ItemCompass"; player addWeapon "ItemWatch"; player addWeapon "ItemGPS"; player addWeapon "ItemMap"; player addWeapon "Binocular"; //Backpack player addBackpack "B_Kitbag_mcamo"; //Weapon player addMagazine "Trixie_200Rnd"; player addWeapon "Trixie_L110A1"; player addPrimaryWeaponItem "optic_hamr"; //Backpack Contents player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellYellow"; player addMagazine "SmokeShellBlue"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_bandage_basic"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_packing_bandage"; player addMagazine "cse_tourniquet"; player addMagazine "cse_tourniquet"; player addMagazine "cse_quikclot"; player addMagazine "cse_quikclot"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_bandageElastic"; player addMagazine "cse_personal_aid_kit"; player addMagazine "Trixie_200Rnd"; player addMagazine "Trixie_200Rnd"; player addMagazine "Trixie_200Rnd"; player addMagazine "Trixie_200Rnd"; //Vest player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addItemToVest "cse_morphine"; player addItemToVest "cse_epinephrine"; player addItemToVest "cse_quikclot"; player addItemToVest "cse_packing_bandage"; player addItemToVest "cse_bandage_basic"; player addItemToVest "HandGrenade"; player addItemToVest "HandGrenade"; player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; //vehicle player addAction ['<t color=''#FF0033''>Radio:</t>', 'radio\radio.sqf']; //execvm "scripts\medkitlimit.sqf"; }; Then on the init line of the crate (well the crate is spawned in through an additional script that places the crate based on marker location so I'll attach an addaction to it) I can put addaction init\gear.sqf and not have to worry about any terminate requirements, while still retaining the ability to terminate it in the future if neccessary? I think I'm understanding it correctly? Edit: Works fine, though removing all gear and replaces makes my guy fall over if he's moving lol. Small price to pay for speed when things go wrong at the start or for proper resupplies! Edited October 5, 2014 by ToejaM Share this post Link to post Share on other sites
dreadedentity 278 Posted October 5, 2014 Its definitely good to future proof it.. just incase I do need to stop it for some reason. I was thinking of putting an addaction on a crate in the HQ/FOB that runs init\gear.sqf which would re-run the medic check No it wasn't for future-proofing, just good practice. I'm not sure how the other guys do it, but any time I spawn a script that will run infinitely, I always assign a handle so it's easy to terminate if I ever need/want to. Unless it's a script that is never meant to be terminated/reloaded, like a hunger/thirst tracker. Then on the init line of the crate ... I can put addaction init\gear.sqf and not have to worry about any terminate requirements, while still retaining the ability to terminate it in the future if neccessary? I think I'm understanding it correctly? As long as you have the variable, you'll be able to easily terminate the script with whatever edits you make. It's just like any other variable, you made it, but you don't have to use it, and it's still there in case you ever do actually need it. Share this post Link to post Share on other sites
ToejaM 1 Posted October 5, 2014 (edited) I understand its good practise but it acts as future proofing it for me.. I might aswell learn that now rather than later before I make a thread saying "How do I stop a script that is on a sleep / while loop!!" ;) If I wanted to add multiple items to something with the same limits, what would be the best way to go about this? I also assume logically that if I wanted to add a different item with different limits, it would be best to have a separate script for it to keep it tidier. I'm contemplating limiting magazines possible due to the fatigue system not being overly great and being able to carry 47 stanag magazines is a bit game breaking with no negative effects on the player. Edited October 5, 2014 by ToejaM Share this post Link to post Share on other sites
dreadedentity 278 Posted October 5, 2014 If I wanted to add multiple items to something with the same limits, what would be the best way to go about this? First thing we're going to have to do is re-write parts of the script to accept variables you will pass to it during runtime. It would also be good to rename the script so you don't get confused when you look at it 6 months later. limitCheck.sqf (changes have been highlighted in blue and red //run the script with this: medkitCheck = [[color="#0000FF"]"cse_personal_aid_kit"[/color], [color="#FF0000"]"B_soldier_F"[/color]] execVM "limitCheck.sqf"; //if you run the script with those parameters, it should do exactly the same thing it currently does. [color="#0000FF"]_type = _this select 0;[/color] [color="#FF0000"]_item = _this select 1;[/color] while {true} do { if(typeOf player == [color="#0000FF"]_type[/color]) then { limit = 3; } else { limit = 1; }; numberOfKits = {[color="#FF0000"]_item[/color] == _x} count (magazines player); if (numberOfKits > limit) then { hintSilent format["You are carrying %1 extra %2, they will be removed from your inventory.", numberOfKits - limit, _item]; //personal touch, lets players know they've been caught trying to bend the rules. for "_i" from 1 to (numberOfKits - limit) do { player removeMagazine [color="#FF0000"]_item[/color]; }; }; sleep 10; }; Since this is just a private function, and you're not going to mess up when adding the parameters, we don't really need to add error-checking so we don't have to worry about BIS_fnc_param; I also assume logically that if I wanted to add a different item with different limits, it would be best to have a separate script for it to keep it tidier. Again, I'm only speaking for myself here, but if I were to do this, I would try to make only 1 script that is as versatile as possible. But I'm willing to bet most of the others would agree with me. Share this post Link to post Share on other sites
iceman77 18 Posted October 5, 2014 (edited) Looking pretty good. Although you could shorten it dramatically by using addMagazine array and using forEach (or any loop you like). You could also utilize BIS_fnc_addWeapon if you like, for a more "streamlined" approach. Anyhow, something like this: if(!hasInterface) exitWith {}; if(isDedicated) exitWith {}; waitUntil {!isNull player}; waitUntil {isPlayer player}; waitUntil {!isNull(findDisplay 46)}; clearBackpackCargo player; removeAllWeapons player; removeAllItems player; removeAllContainers player; removeHeadgear player; player unassignItem "NVGoggles"; player removeItem "NVGoggles"; for[{_num = 0},{_num <= 100},{_num = _num + 1}] do {player removeAction _num;}; if (isNil "medkitCheck") then{medkitCheck = execvm "scripts\medkitlimit.sqf";}; switch (typeOf player) do { //RiflemanAT case "B_soldier_LAT_F":{ //Containers player addBackpack "B_Kitbag_mcamo"; player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; //Magazines player addMagazine ["30Rnd_556x45_STANAG", 1]; player addMagazine ["SmokeShellYellow", 2]; player addMagazine ["SmokeShellBlue", 1]; player addMagazine ["cse_bandage_basic", 6]; player addMagazine ["cse_packing_bandage", 6]; player addMagazine ["cse_personal_aid_kit", 1]; player addMagazine ["cse_tourniquet", 2]; player addMagazine ["cse_quikclot", 2]; player addMagazine ["cse_bandageElastic", 2]; player addMagazine ["Trixie_200Rnd", 1]; player addMagazine ["mas_M136", 3]; {player addItemToVest "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5,6,7,8]; {player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"} forEach [1,2,3]; {player addItemToVest "HandGrenade"} forEach [1,2]; {player addItemToVest _x} forEach ["cse_morphine","cse_epinephrine","cse_quikclot","cse_packing_bandage","cse_bandage_basic"]; //Weapons {player addWeaponGlobal _x} forEach ["ACRE_PRC148","ItemCompass","ItemWatch","ItemGPS","ItemMap","Binocular","ej_l85a2","mas_launch_m136_F"]; player addPrimaryWeaponItem "optic_hamr"; }; // Section 1IC case "B_Soldier_SL_F":{ //Containers player addBackpack "B_Kitbag_mcamo"; player addVest "V_mas_uk_PlateCarrierGL_rgr_v"; player addUniform "U_mas_uk_B_CombatUniform_mtp"; player addHeadGear "H_mas_uk_HelmetB"; //Magazines player addMagazine ["30Rnd_556x45_STANAG", 1]; player addMagazine ["SmokeShellYellow", 2]; player addMagazine ["SmokeShellBlue", 1]; player addMagazine ["cse_bandage_basic", 6]; player addMagazine ["cse_packing_bandage", 6]; player addMagazine ["cse_personal_aid_kit", 1]; player addMagazine ["cse_tourniquet", 2]; player addMagazine ["cse_quikclot", 2]; player addMagazine ["cse_bandageElastic", 2]; player addMagazine ["Trixie_200Rnd", 1]; player addMagazine ["mas_M136", 3]; {player addItemToVest "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5,6,7,8]; {player addItemToVest "30Rnd_556x45_Stanag_Tracer_Red"} forEach [1,2,3]; {player addItemToVest "HandGrenade"} forEach [1,2]; {player addItemToVest _x} forEach ["cse_morphine","cse_epinephrine","cse_quikclot","cse_packing_bandage","cse_bandage_basic"]; //Weapons {player addWeaponGlobal _x} forEach ["ACRE_PRC148","ItemCompass","ItemWatch","ItemGPS","ItemMap","Binocular","ej_l85a2","mas_launch_m136_F"]; player addPrimaryWeaponItem "optic_hamr"; }; // . . . MORE CODE SAME FORMAT. . . // }; As a rule of thumb (if possible) if I've written the same line more than 2x, it's time to start formatting of a sort and/or using loops. ---------- Post added at 19:03 ---------- Previous post was at 19:01 ---------- Oops ninja'd over dread's post :p Edited October 5, 2014 by Iceman77 Share this post Link to post Share on other sites
ToejaM 1 Posted October 5, 2014 Alright! Thanks I'll look at changing it around after the operation tonight. Thanks a lot! Share this post Link to post Share on other sites