Jump to content

AutoEpi Injection - With anti combat-logging


Csus

Recommended Posts

I was just playing around on the server when I got knocked out. I was knocked out for about 2 minutes before zombies finally killed me, but during that whole time I was conscious of the fact that I had an epi pen in my inventory. Then i realized the for all the people who play alone, it kinda sucks that you can never really get 'revived'.

So I spent the next half hour making this.

/*    [15] ExecVM "folder\AutoEpi.sqf";    -    or    -    [15] ExecVM "AutoEpi.sqf";    
      Option 1 is for if the 'AutoEpi.sqf' will be in a folder. Option 2 is for if the 'AutoEpi.sqf' will be in the root of the mission.
	  [15] This is the time you want a player to wait before using AutoEpi.
      Use one of the two options and place the line in your mission 'init.sqf' just under ' if (!isDedicated) then { '    */
if ((isServer) || (isDedicated)) exitWith {};

AE_administer = {
    private ["_tLim","_display"];
    _tLim = _this select 0;

    for "_i" from _tLim to 1 step -1 do {
        _display = format ["\nAuto-Injecting Epinephrine in %1 seconds",_i];
	    titleText [_display,"PLAIN DOWN"];
	    sleep 1;
    };
    
	titleText ["\nInjecting Epinephrine","PLAIN DOWN"];
    player removeMagazine "ItemEpinephrine";
    player setVariable ["NORRN_unconscious", false, true];
    player setVariable ["USEC_isCardiac",false,true];
    sleep 2;
    PVDZE_send = [player,"Epinephrine",[player,player,"ItemEpinephrine"]];
    publicVariableServer "PVDZE_send";

    true
};
sleep 5;

waitUntil {!isNil "dayz_animalCheck"};
waitUntil {alive player};
waitUntil {!(player getVariable ["NORRN_unconscious",false])};

private ["_isUnconscious","_isDead","_hasEpi","_nil","_time"];
_time = _this select 0;

while {true} do {
    _isUnconscious = player getVariable ["NORRN_unconscious",false];
    _isDead = player getVariable ["USEC_isDead",false];
    _hasEpi = "ItemEpinephrine" in ([player] call BIS_fnc_invString);

    if ((_isUnconscious) && (!_isDead) && (_hasEpi)) then {
        sleep 2;
		_nil = [_time] call AE_administer;
    };
};

It automatically uses an epi-pen on a player if they are unconscious and have an epi-pen in their inventory.

It's super easy adjust the time delay. Also, combat loggers cannot abuse it.

The top 4 lines of the file tell you how to put it on your server.

Easy peasy :D

Link to comment
Share on other sites

I cant get this working.. 

I combat logged to get knockout and it just goes slowly through timer like normal.

my init 

 

if (!isDedicated) then {
[10] ExecVM "AutoEpi.sqf";
//Conduct map operations

 

 

 

my 

AutoEpi.sqf in mission root

 

if ((isServer) || (isDedicated)) exitWith {};


AE_administer = {
    private ["_tLim","_display"];
    _tLim = _this select 0;

    for "_i" from _tLim to 1 step -1 do {
        _display = format ["\nAuto-Injecting Epinephrine in %1 seconds",_i];
	    titleText [_display,"PLAIN DOWN"];
	    sleep 1;
    };
    
	titleText ["\nInjecting Epinephrine","PLAIN DOWN"];
    player removeMagazine "ItemEpinephrine";
    player setVariable ["NORRN_unconscious", false, true];
    player setVariable ["USEC_isCardiac",false,true];
    sleep 2;
    PVDZE_send = [player,"Epinephrine",[player,player,"ItemEpinephrine"]];
    publicVariableServer "PVDZE_send";

    true
};
sleep 5;

waitUntil {!isNil "dayz_animalCheck"};
waitUntil {alive player};
waitUntil {!(player getVariable ["NORRN_unconscious",false])};

private ["_isUnconscious","_isDead","_hasEpi","_nil","_time"];
_time = _this select 0;

while {true} do {
    _isUnconscious = player getVariable ["NORRN_unconscious",false];
    _isDead = player getVariable ["USEC_isDead",false];
    _hasEpi = "ItemEpinephrine" in ([player] call BIS_fnc_invString);

    if ((_isUnconscious) && (!_isDead) && (_hasEpi)) then {
        sleep 2;
		_nil = [_time] call AE_administer;
    };
};

 

Link to comment
Share on other sites

 

I cant get this working.. 

I combat logged to get knockout and it just goes slowly through timer like normal.

my init 

 

.....

 

 

 

Says in the thread "Combat loggers cannot abuse it" so I assume it doesn't toggle if you combat log you'll have to jump off a building or something.

Link to comment
Share on other sites

@calamity

 

as anthonypull says, this script is designed so that combat loggers cannot abuse it.

but if you seriously want people to be able to use it after they combat log, just delete this line -

waitUntil {!(player getVariable ["NORRN_unconscious",false])};

i gotta warn you though, a LOT of players will hate this if combat loggers can abuse it.

Link to comment
Share on other sites

@calamity

 

as anthonypull says, this script is designed so that combat loggers cannot abuse it.

but if you seriously want people to be able to use it after they combat log, just delete this line -

waitUntil {!(player getVariable ["NORRN_unconscious",false])};

i gotta warn you though, a LOT of players will hate this if combat loggers can abuse it.

I just want to be able to test it. I keep getting dead instead of knockout

I sure could use the database knockout state so I can log in knocked out.. anyone please share it I have died 15 times trying to get knocked out.

3 shotguns, 4 planecrashes,7 building falls, afew pistol shots and a few rifle shots later still dead. its crazy I cant get knocked out..

if anyone could get knockout goto database and copy the player state.....

Link to comment
Share on other sites

do you not use an antihack on your server?

 

also, if you wanted to edit your medical stats in the database to knock yourself out it would require a restart anyway.

and because you spawn in unconscious it will, once again, not work for you.

Link to comment
Share on other sites

Just installed and it works great. There is an extra "true" in your code, in the function declaration.

I changed it up a bit and make the user "Charge" the epi pen first using the right click menu. Then the script fires and runs as normal. This way if they dont charge it, it doesn't work, and when it does work, they have to charge the next one.

Nice idea by the way. Thanks for sharing.

Link to comment
Share on other sites

@OneManGang

 

The extra 'true' is there as a return value. While it's not always needed to return something from a function I've found things run a lot smoother if they return something, anything.

 

I'd love to check out your changes to it! You mind sharing the file so I can have a play with it? It sounds awesome man!

Link to comment
Share on other sites

  • 2 weeks later...

@OneManGang

 

The extra 'true' is there as a return value. While it's not always needed to return something from a function I've found things run a lot smoother if they return something, anything.

 

I'd love to check out your changes to it! You mind sharing the file so I can have a play with it? It sounds awesome man!

I had to mail it to you, for some reason I can't paste into window from my server.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...