Restrict Krixes SelfBloodBag only to a special Location

Panadur

New Member
Hi All,

i have written a small restriction to Krixes SelfBloodBag Script that allows the use only inside (not behind, nor on top) a hospital in Chernarus.
open player_selfbloodbag.sqf and search for
Code:
private ["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime"];
and insert this within the brackets
Code:
"_nearHospital","_playerASL1","_playerASLx","_playerASLy","_playerASLz","_playerASLz2","_playerASL2","_decke","_Hospitalfound","_HospitalDistance"

and then insert this just after the Config Area
Code:
_HospitalDistance = 21;
_nearHospital = false;
_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]; //überprüft ob sich zwischen dem Player und (Player+40m höhe) ein Objekt befindet
_Hospitalfound = count nearestObjects[player,["Land_A_Hospital"],_HospitalDistance];
if ((_Hospitalfound > 0) && _decke) then {
    _nearHospital = true;
};
if(!_nearHospital) exitWith {
        cutText [format["You need to be inside a Hospital to do this !!!"], "PLAIN DOWN"];
};

If you want to restrict the location to other buildings just change Land_A_Hospital to the class name of the building that you want.
 
This is the single greatest thing on my Namalsk server. After an EVR event the entire server all goes to the one hospital area to heal and end up slaughtering each other. It's amazing to watch the resulting gun battle.
 
hi change very interesting but I have not managed to install

private OK<<

Code:
["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime"_nearHospital","_playerASL1","_playerASLx","_playerASLy","_playerASLz","_playerASLz2","_playerASL2","_decke","_Hospitalfound","_HospitalDistance"];

but where to put this code??

Code:
_HospitalDistance = 21;
_nearHospital = false;
_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]; //überprüft ob sich zwischen dem Player und (Player+40m höhe) ein Objekt befindet
_Hospitalfound = count nearestObjects[player,["Land_A_Hospital"],_HospitalDistance];
if ((_Hospitalfound > 0) && _decke) then {
    _nearHospital = true;
};
if(!_nearHospital) exitWith {
        cutText [format["You need to be inside a Hospital to do this !!!"], "PLAIN DOWN"];
};

thx sorry english
 
Hi i reworked my code and added a possibility to restrict it to an ambulance (Vodnik) , a Hospital or just everywhere.
Depending on what you choose in the config area, the bloodamount and chance to get an infected bloodbag also vary

search for
Code:
private ["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime"];
within the player_selfbloodbag.sqf and replace it with
Code:
private ["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime","_HospitalDistance","_AmbulanceDistance","_Bloodmultiplier","_Infectionmultiplier","_Hospital_enable","_Ambulance_enable","_Anywhere_enable","_nearHospital","_playerASL1","_playerASLx","_playerASLy","_playerASLz","_playerASLz2","_playerASL2","_decke","_Hospitalfound","_Ambulancefound","_bloodAmount","_infectionChance"];
and now put this just after the config area.
Code:
_HospitalDistance = 21; //Max distancewithin Hospital
_AmbulanceDistance = 5; // Max. Distance to get Ambulancebonus
_Bloodmultiplier = 1; // Blood amount multiplier (1 if not in Hospital or near Ambulance, 1.5 if near an Ambulance, 2 if near a Hospital, The Multiplier for Ambulance and Hospital get set later)
_Infectionmultiplier = 0.5; // Multiplier for infectionchance if in Hospital 0.5, 0.75 for an Ambulance, 1 if not in a Hospital (The higher the Value the lower the chance to get infected (it must never get 0 because of division by 0)
_Hospital_enable = 1; // 1 enables SelfBloodbag in Hospitals
_Ambulance_enable = 1; // 1 enables SelfBloodbag near Ambulances
_Anywhere_enable = 0; // 1 enables SelfBloodBag anywhere; (Turns automatically on if _Hospital_enable = 0 and _Ambulance_enable = 0;)
 
_nearHospital = false;
if ((_Hospital_enable == 0) && (_Ambulance_enable == 0)) then { // Check if _Hospital_enable & _Ambulance_enable disabled
    _Anywhere_enable = 1;
    };
if (_Anywhere_enable == 1) then {
        _nearHospital = true;
}; 
if (_Hospital_enable == 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]; //überprüft ob sich zwischen dem Player und (Player+40m höhe) ein Objekt befindet (benötigt unbedingt ASL Koordinaten)
        _Hospitalfound = count nearestObjects[player,["Land_A_Hospital"],_HospitalDistance]; // check if near Hospital
        if ((_Hospitalfound > 0) && _decke) then {
                _nearHospital = true;
                _Bloodmultiplier = 2; // multiplier to Bloodamount
                _Infectionmultiplier = 0.5; //multiplier to Infectionchance
            };
    }; 
if (_Ambulance_enable == 1)  then {
        _Ambulancefound = count nearestObjects[player,["GAZ_Vodnik_MedEvac"],_AmbulanceDistance]; // check if near Vodnik
        if (_Ambulancefound > 0 ) then {
                _nearHospital = true;
                _Bloodmultiplier = 0.75;
            }; 
    };
_bloodAmount = _bloodAmount * _Bloodmultiplier; // Calculate bloodamount & Infectionchance with the multiplier
_infectionChance = _infectionChance / _Infectionmultiplier;
 
if(!_nearHospital) exitWith { // Abort messegas if Conditions not met
        if ((_Hospital_enable == 1) && (_Ambulance_enable == 0)) then {
            cutText [format["You need to be inside a Hospital to do this !!!"], "PLAIN DOWN"];
        };
        if ((_Hospital_enable == 0) && (_Ambulance_enable == 1)) then {
            cutText [format["You need to be near an Ambulance to do this !!!"], "PLAIN DOWN"];
        };
        if ((_Hospital_enable == 1) && (_Ambulance_enable == 1)) then {
            cutText [format["You need to be near a Hospital or an Ambulance to do this !!!"], "PLAIN DOWN"];
        };
};
 
hi change very interesting but I have not managed to install

private OK<<

Code:
["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime"_nearHospital","_playerASL1","_playerASLx","_playerASLy","_playerASLz","_playerASLz2","_playerASL2","_decke","_Hospitalfound","_HospitalDistance"];

but where to put this code??

Code:
_HospitalDistance = 21;
_nearHospital = false;
_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]; //überprüft ob sich zwischen dem Player und (Player+40m höhe) ein Objekt befindet
_Hospitalfound = count nearestObjects[player,["Land_A_Hospital"],_HospitalDistance];
if ((_Hospitalfound > 0) && _decke) then {
    _nearHospital = true;
};
if(!_nearHospital) exitWith {
        cutText [format["You need to be inside a Hospital to do this !!!"], "PLAIN DOWN"];
};

thx sorry english
Hi just put it right after the config area of player_selfbloodbag.sqf
 
ok but that's where I did not understand what is for you after setting ... like that?
Code:
//////////////////////////////////////////////////////////////////////////////////////////////
// Script writen by Krixes//
// Infection chance and some comments added by Player2//
// Combat check added by istealth//
////
//Version 1.4//
////
// Change Log: //
// 1: Added bloodbag use timer//
// 2: Added a timer for the amount of time before player can use self bloodbag again//
//////////////////////////////////////////////////////////////////////////////////////////////
 
private ["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime"];
 
 
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Config Start-----------------------------------------------------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
_bloodAmount = 4000; // Amount of blood to give to player
_bloodbagUseTime = 30; // Amount of time it takes in second for the player to use the self bloodbag
_bloodbagLastUsedTime = 60; // Amount of time in seconds before player can use self bloodbag again after a succesful use
 
_infectionChance = 10; // Percent chance of player infection on self bloodbag (10 = 10% | 2 = 50% | 1 = 100%)
_infectedLifeBool = true; // Whether the player can loose life if infected (True = On | False = off)
_infectedLifeLost = 1000; // Amount of life to loose in becomes infected
 
_humanityBool = false; // Whether the player can get humanity from giving self a bloodbag (True = On | False = off)
_humanityAmount = 50; // Amount of humanity to give player if _humanityBool is true (250 is default for normal bloodbags)
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Config End-------------------------------------------------------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 
 
 
///////////////////////////////////////////////////////////////////////////////
// Everything below need not be modified unless you know what you are doing! //
///////////////////////////////////////////////////////////////////////////////
 
_bloodbagTime = time - lastBloodbag; // Variable used for easy reference in determining the self bloodbag cooldown
_bloodbagUsageTime = time;
 
if(_bloodbagTime < _bloodbagLastUsedTime) exitWith { // If cooldown is not done then exit script
cutText [format["You may not use Self Bloodbag this soon please wait %1!",(_bloodbagTime - _bloodbagLastUsedTime)], "PLAIN DOWN"]; //display text at bottom center of screen when players cooldown is not done
};
 
if (dayz_combat == 1) then { // Check if in combat
cutText [format["You are in Combat and cannot give yourself a Bloodbag"], "PLAIN DOWN"]; //display text at bottom center of screen when in combat
} else {
 
player removeAction s_player_selfBloodbag; //remove the action from users scroll menu
 
player playActionNow "Medic"; //play bloodbag animation
 
////////////////////////////////////////////////
// Fancy cancel if interrupted addition start //
////////////////////////////////////////////////
r_interrupt = false; // public interuppt variable
_animState = animationState player; // get the animation state of the player
r_doLoop = true; // while true sets whether to continue self bloodbagging
_started = false; // this starts as false as a check
_finished = false; // this starts as false and when true later sets players blood
while {r_doLoop} do {
_animState = animationState player; // keep checking to make sure player is in correct animation
_isMedic = ["medic",_animState] call fnc_inString; // checking to make sure the animstate is the medic animation still
if (_isMedic) then {
_started = true; // this is a check to make sure everything is still ok
};
if(!_isMedic && !r_interrupt && (time - _bloodbagUsageTime) < _bloodbagUseTime) then {
player playActionNow "Medic"; //play bloodbag animation
_isMedic = true;
};
if (_started && !_isMedic && (time - _bloodbagUsageTime) > _bloodbagUseTime) then {
r_doLoop = false; // turns off the loop
_finished = true; // set finished to true to finish the self bloodbag and give player health/humanity
lastBloodbag = time; // the last self bloodbag time
};
if (r_interrupt) then {
r_doLoop = false; // if interuppted turns loop off early so _finished is never true
};
sleep 0.1;
};
r_doLoop = false; // make sure loop is off on successful self bloodbag
///////////////////////////////////////////////
// Fancy cancel if interrupted addition end //
//////////////////////////////////////////////
 
if (_finished) then {
player removeMagazine "ItemBloodbag"; //remove the used bloodbag from inventory
 
r_player_blood = r_player_blood + _bloodAmount; //set players LOCAL blood to a certain ammount
 
if(r_player_blood > 12000) then {
r_player_blood = 12000; // If players blood is greater then max amount allowed set it to max allowed (this check keeps an error at bay)
};
 
// check if infected
if (random(_infectionChance) < 1) then {
r_player_infected = true; //set players client to show infection
player setVariable["USEC_infected",true,true]; //tell the server the player is infected
cutText [format["You have used a bloodbag on yourself but the bloodbag was infected!"], "PLAIN DOWN"]; //display text at bottom center of screen if infected
 
// check for if loosing life on infection is turned on
if(_infectedLifeBool) then {
r_player_blood = r_player_blood - _infectedLifeLost; //set players LOCAL blood to a certain ammount
player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
} else { // if loosing life is turned off
r_player_lowblood = false; //set lowblood setting to false
10 fadeSound 1; //slowly fade their volume back to maximum
"dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
"colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; //give them their colour back
r_player_lowblood = false; //just double checking their blood isnt low
player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
};
} else { // if not infected
r_player_lowblood = false; //set lowblood setting to false
10 fadeSound 1; //slowly fade their volume back to maximum
"dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
"colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; //give them their colour back
r_player_lowblood = false; //just double checking their blood isnt low
player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
 
cutText [format["You have used a bloodbag on yourself!"], "PLAIN DOWN"]; //display text at bottom center of screen on succesful self bloodbag
};
 
// check if giving player humanity is on
if(_humanityBool) then {
[player,_humanityAmount] call player_humanityChange; // Set players humanity based on amount listed in config area
};
} else {
// this is for handling if interrupted
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
cutText [format["You have interrupted giving yourself a bloodbag!"], "PLAIN DOWN"]; //display text at bottom center of screen on interrupt
};
};
 
_HospitalDistance = 21;
_nearHospital = false;
_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]; //überprüft ob sich zwischen dem Player und (Player+40m höhe) ein Objekt befindet
_Hospitalfound = count nearestObjects[player,["Land_A_Hospital"],_HospitalDistance];
if ((_Hospitalfound > 0) && _decke) then {
_nearHospital = true;
};
if(!_nearHospital) exitWith {
cutText [format["You need to be inside a Hospital to do this !!!"], "PLAIN DOWN"];
};
 
ok but that's where I did not understand what is for you after setting ... like that?
Hi,

this is where the code has to be. Just before Krixes code starts because my code doesnt change anything about the bloodbag itsself, It only adds addidtional conditions and multipliers for his code.
Code:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Config End-------------------------------------------------------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_HospitalDistance = 21;
_nearHospital = false;
_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]; //überprüft ob sich zwischen dem Player und (Player+40m höhe) ein Objekt befindet
_Hospitalfound = count nearestObjects[player,["Land_A_Hospital"],_HospitalDistance];
if ((_Hospitalfound > 0) && _decke) then {
_nearHospital = true;
};
if(!_nearHospital) exitWith {
cutText [format["You need to be inside a Hospital to do this !!!"], "PLAIN DOWN"];
};
 
 
 
 
///////////////////////////////////////////////////////////////////////////////
// Everything below need not be modified unless you know what you are doing! //
///////////////////////////////////////////////////////////////////////////////
 
This is a pretty cool addon to the self blood bag. I took a different route and added consequences to self blood bag to make it so people want to find someone to help them do it. Unless they are desperate of course. :)
 
This is a pretty cool addon to the self blood bag. I took a different route and added consequences to self blood bag to make it so people want to find someone to help them do it. Unless they are desperate of course. :)

what kind of consequences? sounds interesting.
 
Code:
if (_finished) then {
        //Self BloodBag
        _id = [player,player] execVM "\z\addons\dayz_code\medical\publicEH\medTransfuse.sqf";
        //Set Self Blood Bag Consequence
        _unit setVariable["LastTransfusion",time,true];
        _unit setVariable["USEC_lowBlood",false,true];
        // Set Knockout Consequence
        sleep 0.2;
        r_player_timeout = 10;
        r_player_unconscious = true;
        player setVariable ["unconsciousTime", r_player_timeout, true];
        player setVariable ["NORRN_unconscious", true, true];
        player playActionNow "Die";     
        // Set Infection Consequence
        r_player_infected = true;
        player setVariable["USEC_infected",true,true];
        // Set Pain Consequence
        r_player_inpain = true;
        player setVariable["USEC_inPain",true,true];
        // Remove Magazines
        player removeMagazine "ItemBloodbag";
        usecTransfuse = [_unit,player];
        publicVariable "usecTransfuse";
        //Set Humanity Consequence
        [player,-100] call player_humanityChange;
        // End Self Bloodbag


Works very well :)
 
You can also merge this with humanity restrictions, so that a Hero, who is basically a medic, can self blood bag anywhere and is exempt from needing to be near a medical building. Customizing further, you can give hero's more blood and/or less of a chance of infection too.

Good incentive for players who want to play a good guy.

Thanks for the enhancements to the script Panadur!
 
You can also merge this with humanity restrictions, so that a Hero, who is basically a medic, can self blood bag anywhere and is exempt from needing to be near a medical building. Customizing further, you can give hero's more blood and/or less of a chance of infection too.

Good incentive for players who want to play a good guy.

Thanks for the enhancements to the script Panadur!

How would you read humanity from the database in order to evaluate it?
 
Hi, thats a nice Idea. I dont have much time these days because kikyou2 from Chernarus.de managed to enslave me for his project , but i will update the script as soon as possible :)
 
But this won't work with mods where you can change the skin.
You can read the humanity from database with
Code:
getVariable["humanity",0];
without any Problems.
Not really from database, but it does not matter.
 
Back
Top