adg Posted February 5, 2014 Report Share Posted February 5, 2014 This is my first tutorial, so please bear with me. Any changes, improvements and comments are welcome. After this tutorital you can click bloodbag to give it to yourself. You can configure limitations like: being able to use it in a vehicle time between 2 uses infection chance only able to use near hospital/medical vehicles blood amount etc. Giving bloodbag to other players will be unchanged! Requirements: * Basic knowledge of unpacking pbo's * Custom compiles * Common sense Edit:// Follow this for epoch 1.0.5: 1) Copy this file from dayz_code.pbo to your MPMissions\...Your Mission Folder...\custom folder: dayz_code\compile\ui_selectSlot.sqf 2) Open your custom compiles.sqf and change this line from: player_selectSlot = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\ui_selectSlot.sqf"; to player_selectSlot = compile preprocessFileLineNumbers "custom\ui_selectSlot.sqf"; 3) Create a new file in your custom folder called extra_rc.hpp and paste this code into it OR download the file from attachment and unzip: (NB if you already have followed maca134 tutorial http://epochmod.com/forum/index.php?/topic/4834-add-right-click-options-to-items/ then you need to edit your current files) class ExtraRc { class ItemBloodbag { class Use { text = "Use Bloodbag"; script = "execVM 'custom\SelfBB.sqf'"; }; }; }; 4) Open your description.ext (in your MPMissions folder). To the end add: #include "custom\extra_rc.hpp" 5) Open custom\ui_selectSlot.sqf Search for the loop in spoilers: //Populate Menu for "_i" from 0 to (_numActions - 1) do { _menu = _parent displayCtrl (1600 + _i); _menu ctrlShow true; _config = (_cfgActions select _i); _type = getText (_config >> "text"); _script = getText (_config >> "script"); _outputOriented = getNumber (_config >> "outputOriented") == 1; _height = _height + (0.025 * safezoneH); _compile = format["_id = '%2' %1;",_script,_item]; uiNamespace setVariable ['uiControl', _control]; if (_outputOriented) then { /* This flag means that the action is output oriented the output class will then be transferred to the script and the type used for the name */ _array = getArray (_config >> "output"); _outputClass = _array select 0; _outputType = _array select 1; _name = getText (configFile >> _outputType >> _outputClass >> "displayName"); _compile = format["_id = ['%2',%3] %1;",_script,_item,_array]; }; _menu ctrlSetText format[_type,_name]; _menu ctrlSetEventHandler ["ButtonClick",_compile]; }; right after the loops closing bracket and semicolon add this code: // Add extra context menus _erc_cfgActions = (missionConfigFile >> "ExtraRc" >> _item); _erc_numActions = (count _erc_cfgActions); if (isClass _erc_cfgActions) then { for "_j" from 0 to (_erc_numActions - 1) do { _menu = _parent displayCtrl (1600 + _j + _numActions); _menu ctrlShow true; _config = (_erc_cfgActions select _j); _text = getText (_config >> "text"); _script = getText (_config >> "script"); _height = _height + (0.025 * safezoneH); uiNamespace setVariable ['uiControl', _control]; _menu ctrlSetText _text; _menu ctrlSetEventHandler ["ButtonClick",_script]; }; }; 6) Create a new file in your custom folder called SelfBB.sqf and paste this code into it OR download the file from attachment and unzip: //------------------------------------------\\ // Clickable self bloodbag by adg \\ // Version: 2.0 \\ // \\ //------------------------------------------\\ private ["_started","_finished","_animState","_isMedic","_num_removed","_lastUsed","_infectionChance","_disallowinVehicle","_bloodAmount","_useTime","_giveHumanity","_humanityAmount","_hospitalDistance","_ambulanceDistance","_hospitalEnable","_ambulanceEnable","_anywhereEnable"]; disableserialization; //------------------------------------------------------------------------------------------------------------------------------------------------------------------\\ // CONFIG START \\ //------------------------------------------------------------------------------------------------------------------------------------------------------------------\\ _useTime = 180; //Time in seconds before being able to use again. _bloodAmount = 4000; //Amount of blood the bloodbag gives to player (gets multiplied in hosp/ambulance, so 4000 = 8000 in hospital and 6000 near ambulance) _infectionChance = 30; //Chance of getting infected while using the bloodbag (0 = disabled, 40 = 40%, 100 = 100% etc) _disallowinVehicle = true; //Do not allow usage in a vehicle. true = cannot use, false = can use in vehicle _giveHumanity = false; //Give players humanity for self bloodbag. true = give humanity, false = do not give _humanityAmount = 50; //Amount of humanity to give, if _giveHumanity = true _hospitalDistance = 21; //Max distance within Hospital _ambulanceDistance = 5; // Max. distance from ambulance (medical hmmwv, medical vodnik or medic van) _hospitalEnable = 1; // 1 enables SelfBloodbag in hospitals (leave as 1 if you have _anywhereEnable = 1; and want to get bonuses near hospital) _ambulanceEnable = 1; // 1 enables SelfBloodbag near ambulances (leave as 1 if you have _anywhereEnable = 1; and want to get bonuses near med vehicles) _anywhereEnable = 0; // 1 enables SelfBloodBag anywhere (turns automatically on if _hospitalEnable = 0 and _ambulanceEnable = 0;) //------------------------------------------------------------------------------------------------------------------------------------------------------------------\\ // CONFIG END \\ // Do not change below unless you know what you are doing!!! \\ //------------------------------------------------------------------------------------------------------------------------------------------------------------------\\ if (dayz_combat == 1) exitwith { cutText [format["You are in combat and cannot perform that action!"], "PLAIN DOWN"]}; if (_disallowinVehicle && vehicle player != player) exitWith {cutText [format["You cannot use the bloodbag in a vehicle!"], "PLAIN DOWN"]}; if (r_player_blood == r_player_bloodTotal) exitwith {cutText ["You are not injured!","PLAIN DOWN"]}; private ["_nearHospital","_bloodMultiplier","_infectionMultiplier","_decke","_hospitalFound","_ambulanceFound","_display"]; _nearHospital = false; _bloodMultiplier = 1; // Blood amount multiplier (Anywhere 1, Hospital 2, Ambulance 1.5, The Multiplier for Ambulance and Hospital get set later) _infectionMultiplier = 1; // Multiplier for infectionchance. Anywhere 1, Hospital 0.5, Ambulance 0.75 (the formula is _infenctionChance * _infectionMultiplier so lower multiplier = lower chance) if (_hospitalEnable == 0 && _ambulanceEnable == 0) then { // Check if _hospitalEnable & _ambulanceEnable disabled _anywhereEnable = 1; }; if (_anywhereEnable == 1) then { _nearHospital = true; }; if (_hospitalEnable == 1) then { // if Hospital enabled _playerASL1 = getPosASL player; _playerASLx = _playerASL1 select 0; _playerASLy = _playerASL1 select 1; _playerASLz = _playerASL1 select 2; _playerASLz2 = _playerASLz + 40; _playerASL2 = [_playerASLx,_playerASLy,_playerASLz2]; _decke = lineIntersects[_playerASL1,_playerASL2]; _hospitalFound = count nearestObjects[player,["Land_A_Hospital"],_hospitalDistance]; //can add desired buildings here if (_hospitalFound > 0 && _decke) then { _nearHospital = true; _bloodMultiplier = 2; // multiplier to Bloodamount _infectionMultiplier = 0.5; //multiplier to Infectionchance }; }; if (_ambulanceEnable == 1) then { _ambulanceFound = count nearestObjects[player,["GAZ_Vodnik_MedEvac","HMMWV_Ambulance","S1203_ambulance_EP1"],_ambulanceDistance]; //can add desired vehicles here if (_ambulanceFound > 0 ) then { _nearHospital = true; _bloodMultiplier = 1.5; // multiplier to Bloodamount _infectionMultiplier = 0.75; //multiplier to Infectionchance }; }; _bloodAmount = _bloodAmount * _bloodMultiplier; // Calculate bloodamount & Infectionchance with the multiplier _infectionChance = _infectionChance * _infectionMultiplier; if(!_nearHospital) exitWith { // Abort messegas if Conditions not met if (_hospitalEnable == 1 && _ambulanceEnable == 0) then { cutText [format["You need to be inside a hospital to do this!"], "PLAIN DOWN"]; }; if (_hospitalEnable == 0 && _ambulanceEnable == 1) then { cutText [format["You need to be near a medical vehicle to do this!"], "PLAIN DOWN"]; }; if (_hospitalEnable == 1 && _ambulanceEnable == 1) then { cutText [format["You need to be inside a hospital or near a medical vehicle to do this!"], "PLAIN DOWN"]; }; }; if (isNil 'lastUsed') then {lastUsed = time}; if (time - lastUsed < _useTime && time - lastUsed != 0) exitwith {cutText [format["Not so fast! You can use bloodbag again in %1 seconds",(ceil(_useTime - (time - lastUsed)))],"PLAIN DOWN"]}; call fnc_usec_medic_removeActions; r_action = false; [1,1] call dayz_HungerThirst; if (vehicle player == player) then { //not in a vehicle player playActionNow "Medic"; }; r_interrupt = false; _animState = animationState player; r_doLoop = true; _started = false; _finished = false; while {r_doLoop} do { _animState = animationState player; _isMedic = ["medic",_animState] call fnc_inString; if (_isMedic) then { _started = true; }; if (_started and !_isMedic) then { r_doLoop = false; _finished = true; }; if (r_interrupt) then { r_doLoop = false; }; if (vehicle player != player) then { sleep 3; r_doLoop = false; _finished = true; }; sleep 0.1; }; r_doLoop = false; if (_finished) then { _num_removed = ([player,"ItemBloodbag"] call BIS_fnc_invRemove); if(_num_removed == 1) then { lastUsed = time; if (vehicle player != player) then { _display = findDisplay 106; _display closeDisplay 0; }; r_player_lowblood = false; r_player_blood = r_player_blood + _bloodAmount; //set players LOCAL blood to a certain ammount if(r_player_blood > r_player_bloodTotal) then { r_player_blood = r_player_bloodTotal; // If players blood is greater then max amount allowed set it to max allowed (this check keeps an error at bay) }; player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database //Restore player sound + vision 10 fadeSound 1; "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; if (floor(random(100)+1) <= _infectionChance) then { //Infection chance r_player_infected = true; //set client to show infection player setVariable["USEC_infected",true,true]; //tell server that player is infected cutText [format["You gave yourself blood, but got infected in the process!"], "PLAIN DOWN"]; //display text at bottom center of screen if infected } else { cutText [format["You successfully gave yourself some blood!"], "PLAIN DOWN"]; }; if(_giveHumanity) then { //humanity check [player,_humanityAmount] call player_humanityChange; }; }; } else { r_interrupt = false; player switchMove ""; player playActionNow "stop"; cutText [format["Giving yourself blood was interrupted!"], "PLAIN DOWN"]; }; 7) Edit the config part in SelfBB.sqf to your liking! Start your server and enjoy :P Credits:Krixes - inspiration and some code maca134 - right click tutorial Panadur & Fuchs - hospital restriction Attachments don't work so direct links: extra_rc.zip SelfBB.zip 31_D!4b10, nachtmasse, MrAlfred and 6 others 9 Link to comment Share on other sites More sharing options...
adg Posted February 5, 2014 Author Report Share Posted February 5, 2014 Mixed up _injured and _lowBlood in part 7. Fixed and working as intended now. Link to comment Share on other sites More sharing options...
williamjbrown Posted February 7, 2014 Report Share Posted February 7, 2014 Works perfectly! One thing removed from the scroll wheel thanks to you. :) Link to comment Share on other sites More sharing options...
Novuhz Posted February 7, 2014 Report Share Posted February 7, 2014 Hello having a bit of trouble. Right at the start: 1) Copy these files from dayz_code.pbo to your MPMissions\...Your Mission Folder...\custom folder: dayz_code\compile\ui_selectSlot.sqf dayz_code\actions\player_useMeds.sqf dayz_code\medical\transfusion.sqf <-rename this to transfusionSelf.sqf in your custom folder 2) Open your custom compiles.sqf and change these lines: player_useMeds = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_useMeds.sqf";player_selectSlot = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\ui_selectSlot.sqf"; to player_useMeds = compile preprocessFileLineNumbers "custom\player_useMeds.sqf";player_selectSlot = compile preprocessFileLineNumbers "custom\ui_selectSlot.sqf"; There was no Custom folder so I created one no problem so far, copied the 3 files into the custom folder, but now in point 2 it says open your custom compiles.sqf...? I don't have that since I just created the folder, so maybe I had to create the custom.sqf? So I made it but it seems that file should have something already in it because it tells you to find those 2 lines and change them into something else... What am I missing here? Link to comment Share on other sites More sharing options...
adg Posted February 7, 2014 Author Report Share Posted February 7, 2014 Search your MPMissions\Your Mission Folder for custom.sqf. Alot of server mods use that file and you should only have 1 of those. If you do not have a compiles.sqf anywhere in your missions folder, copy it from dayz_code.pbo\init to your MPMissions\...\custom folder, then open init.sqf in your MPMissions and change call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; //Compile regular functions to call compile preprocessFileLineNumbers "custom\compiles.sqf"; //Compile regular functions then you can continue with the tutorial. OR follow this topic: Link to comment Share on other sites More sharing options...
Kind-Sir Posted February 7, 2014 Report Share Posted February 7, 2014 I used Maca134's code and just added the classname in the .hpphttp://epochmod.com/forum/index.php?/topic/4834-add-right-click-options-to-items/It makes for a lot less code to loom around in the mission.pbo, which, in turn, makes your mission a lot more pleasing. computermancer 1 Link to comment Share on other sites More sharing options...
Gregarious Posted February 7, 2014 Report Share Posted February 7, 2014 This is one beautiful tutorial. Color-coordinated, well-formatted, clear, and concise. I wish more people doing releases used your example. adg, computermancer and mgm 3 Link to comment Share on other sites More sharing options...
Novuhz Posted February 8, 2014 Report Share Posted February 8, 2014 Search your MPMissions\Your Mission Folder for custom.sqf. Alot of server mods use that file and you should only have 1 of those. If you do not have a compiles.sqf anywhere in your missions folder, copy it from dayz_code.pbo\init to your MPMissions\...\custom folder, then open init.sqf in your MPMissions and change call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; //Compile regular functions to call compile preprocessFileLineNumbers "custom\compiles.sqf"; //Compile regular functions then you can continue with the tutorial. OR follow this topic: Thanks! It all went perfect, it's working :) Link to comment Share on other sites More sharing options...
ValdisMD Posted February 8, 2014 Report Share Posted February 8, 2014 Amazing script, works great)) One question though would there be a way to use it inside vehicles like any other consumable item? Link to comment Share on other sites More sharing options...
adg Posted February 8, 2014 Author Report Share Posted February 8, 2014 You can try commenting out this part in transfusionSelf.sqf: // not possible to transfuse while in a vehicle if (vehicle player != player) exitWith { }; like this // not possible to transfuse while in a vehicle // if (vehicle player != player) exitWith { }; Link to comment Share on other sites More sharing options...
ValdisMD Posted February 11, 2014 Report Share Posted February 11, 2014 ok thanks a lot i will look into it Link to comment Share on other sites More sharing options...
tokinherb Posted February 11, 2014 Report Share Posted February 11, 2014 Hi i have implemented your script and when i use the bloodbag it consumes it and then it will either slowly add blood or do nothing at all...not sure where i went wrong Link to comment Share on other sites More sharing options...
adg Posted February 11, 2014 Author Report Share Posted February 11, 2014 Hi i have implemented your script and when i use the bloodbag it consumes it and then it will either slowly add blood or do nothing at all...not sure where i went wrong Can you please try this debug: Open your transfusionSelf.sqf and add after this line publicVariableServer "PVDZE_send"; this line: localize "Self-bloodbag finished!"; Then go to your server, use a bloodbag (have low blood to actually use it etc) and check your Arma2OA.RPT in your "C:\Users\Username\AppData\Local\ArmA 2 OA" If you CAN NOT find String Self-bloodbag finished! not found then you have done something wrong and please redo the tutorial carefully :P If you can see it there, then post back please and maybe we can figure something out... NB! after debugging you can remove the added line. Link to comment Share on other sites More sharing options...
Carp! Posted February 11, 2014 Report Share Posted February 11, 2014 Anyway to add how much blood this gives or a chance of infection like krixes because this is just awesome. Link to comment Share on other sites More sharing options...
cen Posted February 11, 2014 Report Share Posted February 11, 2014 Anyway to add how much blood this gives or a chance of infection like krixes because this is just awesome. Of course! Change this: class ExtraRc { class ItemBloodbag { class Use { text = "Use Bloodbag"; script = "spawn player_useMeds;"; }; }; }; to this: class ExtraRc { class ItemBloodbag { class Use { text = "Use Bloodbag"; script = "execVM 'custom\player_selfbloodbag.sqf'"; }; }; }; Then you can use the krixes file to customize. Buck0 1 Link to comment Share on other sites More sharing options...
Snowfake Posted February 18, 2014 Report Share Posted February 18, 2014 I have been trying to get this to work for my 1.0.4.2 panthera server but keep en counting problems. The sqf files from the PBO do they have to be the original dayz files or should I be getting them from epoch or epoch panthera? When I tried the dayz files I would get stuck at the splash screen when logging into my server even though I could hear myself moving about. When I used the Epoch files everything seemed ok but when I clicked on use blood bag it would say could not find custom\transfusionSelf.sqf I checked over the code several times for mistakes but could not find any, Any help would be greatly appreciated as I am pulling my hair out here, by the way I am new to this all and could be missing simple. Link to comment Share on other sites More sharing options...
adg Posted February 21, 2014 Author Report Share Posted February 21, 2014 Updated first post with new script. If updating from previous version, please start tutorial from the beginning to avoid any problems! If there are any problems with the updated script, please let me know :) Link to comment Share on other sites More sharing options...
WEB11 Posted February 21, 2014 Report Share Posted February 21, 2014 Love the idea of removing Self BB from the scroll menu. I will give this a shot. Link to comment Share on other sites More sharing options...
Snowfake Posted February 21, 2014 Report Share Posted February 21, 2014 Thanks adg for the code and help. managed to figure it out. My p[problem was I was using my selfbb(tselfransfusion) from my @dayz Dayz_code.pbo instead of my @DAYZepoch dayz_code.pbo. Seems you have changed your tutorial now anyho :P But this work on my Dayz epoch panthera 1.0.4.2 Link to comment Share on other sites More sharing options...
adg Posted February 22, 2014 Author Report Share Posted February 22, 2014 Thanks adg for the code and help. managed to figure it out. My p[problem was I was using my selfbb(tselfransfusion) from my @dayz Dayz_code.pbo instead of my @DAYZepoch dayz_code.pbo. Seems you have changed your tutorial now anyho :P But this work on my Dayz epoch panthera 1.0.4.2 Great that you got it working :) And yes, I have updated the tutorial with new (much more cutomizable) code. Link to comment Share on other sites More sharing options...
freakystyle Posted February 26, 2014 Report Share Posted February 26, 2014 Hey guys i have a Problem, i hang a Wait for Host what is wrong? class ExtraRc { class ItemToolbox { class BikeDeploy { text = "Construct bike"; script = "execVM 'deploys\bike\deploy.sqf'"; }; class ExtraRc { class ItemBloodbag { class Use { text = "Use Bloodbag"; script = "execVM 'custom\bloodbag\SelfBB.sqf'"; }; }; }; Kevin Link to comment Share on other sites More sharing options...
Buck0 Posted February 26, 2014 Report Share Posted February 26, 2014 This works great thanks! Always looking to remove as much stuff from mouse wheel as possible Thanks Link to comment Share on other sites More sharing options...
cen Posted February 26, 2014 Report Share Posted February 26, 2014 Hey guys i have a Problem, i hang a Wait for Host what is wrong? class ExtraRc { class ItemToolbox { class BikeDeploy { text = "Construct bike"; script = "execVM 'deploys\bike\deploy.sqf'"; }; class ExtraRc { class ItemBloodbag { class Use { text = "Use Bloodbag"; script = "execVM 'custom\bloodbag\SelfBB.sqf'"; }; }; }; Kevin You are missing some }; Should be: class ExtraRc { class ItemToolbox { class BikeDeploy { text = "Construct bike"; script = "execVM 'deploys\bike\deploy.sqf'"; }; }; class ItemBloodbag { class Use { text = "Use Bloodbag"; script = "execVM 'custom\bloodbag\SelfBB.sqf'"; }; }; }; adg 1 Link to comment Share on other sites More sharing options...
freakystyle Posted February 26, 2014 Report Share Posted February 26, 2014 @cen Thank you, it´s works :D Link to comment Share on other sites More sharing options...
juto Posted March 8, 2014 Report Share Posted March 8, 2014 hello! first of all you are awsome, its a very good idea the clicable selfbb and all its customization. my problem is that when i implement the code, building clicing options, dissapear (the greenbox with option appear, but empty, and nothing happens if i click) and im not able to do anything with the rightclic. Im in dayz epoch 1.0.4.2 if anyone has idea of why thids happens, please gime me some instrucctions. thankyou! (sorry for my english, im 5 year old XP no, im not english speaker) Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now