Self Blood Bag

fergfunk22

New Member
Since I couldn't find a thread about self-administered blood bags I was wondering if anyone could help me out on that.

Any scripts out there?

Thanks.
 
A lot of people frown on this idea but me I say to each their own.

My very very basic version of this is this....


Open your dayz_mission.pbo and find init.sqf

add this just before progressLoadingScreen 1.0;
Code:
call compile preprocessFileLineNumbers "custom\compiles.sqf"; //Compile custom compiles

Now create a folder in your dayz_mission.pbo called custom and create a new empty file called compiles.sqf inside.

Edit the compiles.sqf to look like this.....
Code:
fnc_usec_selfActions = compile preprocessFileLineNumbers "custom\fn_selfActions.sqf";            // fnc_usec_selfActions - adds custom actions to dayz code

add the attached fn_selfActions.sqf to your custom folder.

Now lastly add the attached player_selfbloodbag.sqf into your custom folder.

Go in game give urself a bloodbag and use the scroll wheel to select Self Bloodbag and you should be all set!


P.S. Please like this post if you like and it works for you, it would be appreciated!


Have Fun,
Krixes

**Edit - Sorry re-uploaded the player_selfbloodbag.sqf because I had a mistake on the first line lawl!

**Edit2 - Re-Uploaded player_selfbloodbag.sqf once again with Player2's additions.
 

Attachments

  • fn_selfActions.sqf
    15.8 KB · Views: 3,910
  • player_selfbloodbag.sqf
    1.8 KB · Views: 3,860
I have never been more thankful than I am now. That was so easy! Thanks for assisting me today! Bless your self. <3
 
Yeah it's np, you can doctor that simple player_selfbloodbag.sqf up a bunch and make it do all sorts of neat things when u use the self bloodbag option. That one was just as simple as it gets lawl. =)
 
Thanks for posting this! Saves me from googling all over the place!
One thing I thought was missing from this is a chance of infection when using the bloodbag, since giving yourself a transfusion in the middle of a disease ridden apocalypse would be one hell of a risk...

Anyway, here is a modified version of your 'player_selfbloodbag' script that includes a %10 chance of infection, and comments; for no reason other than I was very bored.

Code:
// Script writen by Krixes
//    Infection chance and comments added by Player2
//    Version 1.1
//
 
player removeAction s_player_selfBloodbag;        //remove the action from users scroll menu
player playActionNow "Medic";                    //play bloodbag animation
 
sleep 5;                                        //wait 5 seconds for animation to finish
 
player removeMagazine "ItemBloodbag";            //remove the used bloodbag from inventory
 
r_player_blood = r_player_bloodTotal;            //set their blood to the maximum allowed
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_bloodTotal,true];    //set their blood back up to maximum again
 
cutText [format["You have used a bloodbag on yourself!"], "PLAIN DOWN"];    //display text at bottom center of screen
 
if (random 10 < 1) then {                                    //10% chance
    r_player_infected = true;                                //set players client to show infection
    player setVariable["USEC_infected",true,true];            //tell the server the player is infected
};
 
if (isServer) then {                                        //if running on server
    player setVariable["medForceUpdate",true];                //force the server to update the players medical status
};
 
I recommend to relook into that script ....

couple of points:

Code:
if (isServer) then {                                        //if running on server
    player setVariable["medForceUpdate",true];                //force the server to update the players medical status
};

This one is absolutely useless. There is no player variable on the server.

The animation cant be interrupted ? So the player is stuck for 5 seconds ? Check how it's done in dayz, thats way more elegant.

And why dont you use the pvehs that are available in Dayz for the animation "doMedicAnim", and the RPCcall (refilling & sound/color correction ? -> "usecTransfuse" ?

cheers

Sarge
 
I told you that script was basic lawl. I saw no one had replied so I spit one out for him.
I recommend to relook into that script ....

couple of points:

Code:
if (isServer) then {                                        //if running on server
    player setVariable["medForceUpdate",true];                //force the server to update the players medical status
};

This one is absolutely useless. There is no player variable on the server.
cheers

Sarge

This is how I saw it being done in reg DayZ code. If you look at dayz_code\medical\publicEH\medTransfuse.sqf it has the same thing there. (Whether it's just there and not being used is another question) I do see your point on the not being able to move for 5 seconds but I figure if your gunna give yourself a bloodbag you should have a penalty for it and being stuck for 5 seconds was a good one.

Thanks for posting this! Saves me from googling all over the place!
One thing I thought was missing from this is a chance of infection when using the bloodbag, since giving yourself a transfusion in the middle of a disease ridden apocalypse would be one hell of a risk...

Anyway, here is a modified version of your 'player_selfbloodbag' script that includes a %10 chance of infection, and comments; for no reason other than I was very bored.

Thank you very much for this. I was going to do all the extra stuff later for my own server as I have not seen any others share a script of this type. This saves me from having to write all of it lawl. =)
 
Well,

actually in the dayz code it's
Code:
if (isServer) then {
    _unit setVariable["medForceUpdate",true];
};

and this is a major difference :)
 
Well,

actually in the dayz code it's
Code:
if (isServer) then {
    _unit setVariable["medForceUpdate",true];
};

and this is a major difference :)
Ooooh, I see. I thought that _unit = player at the moment in time.

(BTW thanks for your AI script I love it) ;) I have added a couple extra features to it for my server including backpacks on AI with random loot and a couple modifications to insure random gun distribution to them instead of them all selecting the same guns if you have more then one of a type. If you would like to see the changes I would be more then happy to show you. :)

Back on topic can you explain what the _unit variable is actually referring too since now I know it isn't "player"?

I know it's this but what is the select 0 exactly?
Code:
_array = _this; //_this select 0;
_unit = _array select 0;
 
What happens here is a script that runs on both the server and the client, reacting on a publicvariabled Array.

So the client, after having ran the addaction (cause thats local), runs a publicvariable [_healedunit,healer]

the server and the clients (all clients!) get that variable, and extract the information who was healed and who healed from it, and works with these values.

The first part of that file checks if _unit = player, the player object is local, and by that ALL clients check, if it was their player who got healed.

The server sets a object variable for the player object that is on the server, and makes it LOCAL (so this value is only availabe on the player object on the server).

Theres a constant thread on the server checking player objects if they need a medUpdate, and if yes, data gets stored in the DB.

hope that explains a bit,

Sarge
 
What happens here is a script that runs on both the server and the client, reacting on a publicvariabled Array.

.... ect, ect

hope that explains a bit,

Sarge

AH yes this makes perfect sense, thank you very much sir!

So, from what I gather my mistake was where i assumed player was equal to my local player when calling through server when in fact it is not. It could be all players lawl.

When calling it this way it just forces all players to save their med info to the DB? That could make the DB bog down a bit with the constant saving I suppose.
 
nope, no worries. player if called on the server is a nul object.
Ok that's good. I am glad that it really doesn't hurt anything. But definitely needs to be removed since it serves no purpose lmao.

BTW did you want to see that modified AI code and maybe improve upon it, or did you give up on it lawl? :p
 
Giving up on what ? :)

Nah, it is intended that my AI has no backpacks atm. There were more important things to implement :)
 
Giving up on what ? :)

Nah, it is intended that my AI has no backpacks atm. There were more important things to implement :)
I see, thank's again for explaining that to me and looking forward to seeing more scripts from you. :)
 
So,

I have this script for salvaging parts from cars that goes in the same place as this self-administer. Do you know where or how I can add it in so I can get both of these functions to work? As of right now, it's one or the other.

Here's what mine looks like:

//Load in compiled functions
//call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf"; //Initilize the Variables (IMPORTANT: Must happen very early)
call compile preprocessFileLineNumbers "dayz_code\init\variables.sqf"; //Initilize the Variables (IMPORTANT: Must happen very early)
progressLoadingScreen 0.1;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\publicEH.sqf"; //Initilize the publicVariable event handlers
progressLoadingScreen 0.2;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\setup_functions_med.sqf"; //Functions used by CLIENT for medical
progressLoadingScreen 0.4;
//call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";
call compile preprocessFileLineNumbers "dayz_code\init\compiles.sqf"; //Compile regular functions
progressLoadingScreen 1.0;
 
ok this is overwriting mine......
Code:
fnc_usec_selfActions = compile preprocessFileLineNumbers "dayz_code\compile\fn_selfActions.sqf";        //Checks which actions for self

My compiles.sqf was just to overwrite the defaul fn_selfActions.sqf so all you have to do is remove my fn_selfActions.sqf and my compiles.sqf leaving only the player_selfbloodbag.sqf in the custom folder...

open your dayz_code\compile\fn_selfActions.sqf in YOUR dayz_mission.pbo and add this in....
Code:
// ---------------------------------------Krixes Self Bloodbag Start------------------------------------
    _mags = magazines player;
 
    // Krixes Self Bloodbag
    if ("ItemBloodbag" in _mags) then {
        hasBagItem = true;
    } else { hasBagItem = false;};
    if((speed player <= 1) && hasBagItem && _canDo) then {
        if (s_player_selfBloodbag < 0) then {
            s_player_selfBloodbag = player addaction[("<t color=""#c70000"">" + ("Self Bloodbag") +"</t>"),"custom\player_selfbloodbag.sqf","",5,false,true,"", ""];
        };
    } else {
        player removeAction s_player_selfBloodbag;
        s_player_selfBloodbag = -1;
    };
// ---------------------------------------Krixes Self Bloodbag End------------------------------------

just after this part...........
Code:
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);

**Edit - Sorry to make that more clear you add the above code to the fn_selfActions.sqf that came with vehicle salvage script. You should get used to this as a lot of addons add in their own fn_selfActions.sqf so instead of overwriting them look at the fn_selfActions.sqf that comes with a script and see what they have added and copy paste it into your already existing fn_selfActions.sqf. Saves a lot of headache down the road!
 
Back
Top