Jump to content
  • 0

Humanity Restriction for certain Vehicles


DAKA

Question

23 answers to this question

Recommended Posts

  • 1
2 hours ago, totis said:

_menClose = cursorTarget;
_hasPatient = alive _menClose;
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
_isClose = ((player distance _menClose) < ((sizeOf typeOf _menClose) / 2));

if (_inVehicle) then {
        r_player_lastVehicle = _vehicle;
        _assignedRole = assignedVehicleRole player;
        _driver = driver (vehicle player);

    if (({(isPlayer _driver) && (alive  _driver)} count (crew _vehicle) > 0)) then {
    
        DZE_heroHumanity =    ["Mi17_rockets_RU","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BRDM2_CDF","Offroad_SPG9_TERROR","BTR40_MG_TK_INS_EP1","M1126_ICV_M2_EP1","M113_TK_EP1"];

        DZE_superHeroHumanity =    ["Mi17_rockets_RU","Mi24_V","Mi24_P","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","AW159_lynx_baf","Ka52Black","Ka52","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BMP3","BRDM2_CDF","Offroad_SPG9_TERROR","T72_INS","BTR40_MG_TK_INS_EP1","BTR60_TK_EP1","M1126_ICV_M2_EP1","M113_TK_EP1","T55_TK_EP1","BAF_FV510_W"];
        
        DZE_agentHumanity =    ["AV8B2","AV8B","A10","F35B","L39_TK_EP1","BAF_Apache_AH1_D","AH1Z_DZ","SU39","SU34","Mi17_rockets_RU","Mi24_V","Mi24_P","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","AW159_lynx_baf","Ka52Black","Ka52","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BMP3","BRDM2_CDF","Offroad_SPG9_TERROR","T72_INS","BTR40_MG_TK_INS_EP1","BTR60_TK_EP1","M1126_ICV_M2_EP1","M113_TK_EP1","T55_TK_EP1","BAF_FV510_W","M1126_ICV_mK19_EP1","M2A2_EP1","M2A3_EP1","M2A3_EP1","BTR90_DZ","M1A1","M1A2_TUSK_MG","Ural_ZU23_GUE","AAV","T90","ZSU_TK_EP1","T55_TK_EP1","MLRS_DES_EP1"];

        _humanity = _driver getVariable["humanity",0];

        if (typeOf _vehicle in DZE_heroHumanity && _humanity <= 20000) then {
        if (typeOf _vehicle in DZE_superHeroHumanity && _humanity <= 40000) then {
        if (typeOf _vehicle in DZE_agentHumanity && _humanity <= 60000) then {
        player action ["getOut", (vehicle player)];
        (format ["Your humanity, %1, is less than the required humanity to use this vehicle", _humanity]) call dayz_rollingMessages;
        };
        };
        };
    };
};

 

Can someone points my mistake here. cant make it work.

 

You can't use cascading if's like that.

I've cleaned up your script and tested it, this works fine:

_vehicle = vehicle player;
_inVehicle = (_vehicle != player);

if (_inVehicle) then {
	_driver = driver (vehicle player);

	if (({(isPlayer _driver) && (alive _driver)} count (crew _vehicle) > 0)) then {
		DZE_heroHumanity = ["Mi17_rockets_RU","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BRDM2_CDF","Offroad_SPG9_TERROR","BTR40_MG_TK_INS_EP1","M1126_ICV_M2_EP1","M113_TK_EP1"];
		DZE_superHeroHumanity = ["Mi17_rockets_RU","Mi24_V","Mi24_P","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","AW159_lynx_baf","Ka52Black","Ka52","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BMP3","BRDM2_CDF","Offroad_SPG9_TERROR","T72_INS","BTR40_MG_TK_INS_EP1","BTR60_TK_EP1","M1126_ICV_M2_EP1","M113_TK_EP1","T55_TK_EP1","BAF_FV510_W"];		
		DZE_agentHumanity = ["AV8B2","AV8B","A10","F35B","L39_TK_EP1","BAF_Apache_AH1_D","AH1Z_DZ","SU39","SU34","Mi17_rockets_RU","Mi24_V","Mi24_P","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","AW159_lynx_baf","Ka52Black","Ka52","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BMP3","BRDM2_CDF","Offroad_SPG9_TERROR","T72_INS","BTR40_MG_TK_INS_EP1","BTR60_TK_EP1","M1126_ICV_M2_EP1","M113_TK_EP1","T55_TK_EP1","BAF_FV510_W","M1126_ICV_mK19_EP1","M2A2_EP1","M2A3_EP1","M2A3_EP1","BTR90_DZ","M1A1","M1A2_TUSK_MG","Ural_ZU23_GUE","AAV","T90","ZSU_TK_EP1","T55_TK_EP1","MLRS_DES_EP1","UH1H_DZE"];

		_humanity = _driver getVariable["humanity",0];

		if (typeOf _vehicle in DZE_heroHumanity && _humanity <= 20000 || (typeOf _vehicle in DZE_superHeroHumanity && _humanity <= 40000) || (typeOf _vehicle in DZE_agentHumanity && _humanity <= 60000)) then {
			player action ["getOut", (vehicle player)];
			format ["Your humanity, %1, is less than the required humanity to use this vehicle", _humanity] call dayz_rollingMessages;
		};
	};
};

 

Link to comment
Share on other sites

  • 0

I've moved the topic to where it maybe should be.

There's a few ways you could do this, we check in fn_selfActions.sqf to see if the player is in a vehicle, it would be easy to manipulate this check and add a check against their humanity for the vehicle type they are in.

Link to comment
Share on other sites

  • 0
Just now, totis said:

Im interested in this too.

can someone write an example?

Quick idea where start to build.

_humanity = player getVariable["humanity", 0];
_isBandit = (_humanity <= -2500);
_isHero = (_humanity >=5000);
  
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);  
_BanditVeh = typeOf _vehicle in ["hilux1_civil_3_open_DZE","datsun1_civil_3_open_DZE"];
_HeroVeh = typeOf _vehicle in ["V3S_Open_TK_CIV_EP1","V3S_Open_TK_EP1","KamazOpen_DZE"]; 
  



if (_inVehicle && _HeroVeh && _isBandit (driver _vehicle == player)) exitWith {
systemchat "<Prevention>:vehicle not allowed for your humanity amount!";
  player action['getOut', _vehicle];
 };
  

if (_inVehicle && _BanditVeh && _isHero (driver _vehicle == player)) exitWith {
systemchat "<Prevention>:vehicle not allowed for your humanity amount!";
  player action['getOut', _vehicle];
 };  

 

Link to comment
Share on other sites

  • 0

ahh ok. Then i must be doing something wrong.... again! lol

I have like this under 'custom below'

    _inVehicle = (_vehicle != player);  
    _HeroVeh = typeOf _vehicle in ["HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","LAV25","M113_TK_EP1","Mi17_rockets_RU","Mi24_D","UH1Y","AH6J_EP1_DZE","Mi171sh_rockets_CZ_EP1","Ka60_PMC","Mi24_V","Mi24_P","Ka52","BRDM2_CDF"];
    _humanity = player getVariable["humanity", 0];
    _isBandit = (_humanity <= 19999);
    _isHero = (_humanity >=20000);
    _isSuperHero = (_humanity >=40000);
    _isAgentHero = (_humanity >=60000);
    _vehicle = vehicle player;
    
    if (_inVehicle && _HeroVeh && _isBandit (driver _vehicle == player)) exitWith {
    systemchat "<Prevention>:vehicle not allowed for your humanity amount!";
     player action['getOut', _vehicle];
    };


and doesnt work

Ok i see the error at the numbers now.

or not!

Edited by totis
double stupid me
Link to comment
Share on other sites

  • 0

@totis  in the way that I propose you.. would you have to use a loop

but remember its just a dirt idea .

hum_veh.sqf

Spoiler

_vehicle = vehicle player;
waituntil {uiSleep 0.5;(driver _vehicle == player)};

while {(driver _vehicle == player)} do {
_vehicle = vehicle player;
_humanity = player getVariable["humanity", 0];
_isBandit = (_humanity <= -2500);
_isHero = (_humanity >=5000);
  

_inVehicle = (_vehicle != player);  
_BanditVeh = typeOf _vehicle in ["hilux1_civil_3_open_DZE","datsun1_civil_3_open_DZE"];
_HeroVeh = typeOf _vehicle in ["V3S_Open_TK_CIV_EP1","V3S_Open_TK_EP1","KamazOpen_DZE"]; 
  



if (_inVehicle && _HeroVeh && _isBandit && (driver _vehicle == player)) then {
systemchat "<Prevention>:vehicle not allowed for your humanity amount!";
  player action['getOut', _vehicle];
 }else{
  

if (_inVehicle && _BanditVeh && _isHero && (driver _vehicle == player)) then {
systemchat "<Prevention>:vehicle not allowed for your humanity amount!";
  player action['getOut', _vehicle];
 }else{ 


if ((driver _vehicle == player)&& _inVehicle && !_isBandit && !_isHero  &&  _BanditVeh or _HeroVeh ) then {
systemchat "<Prevention>:vehicle not allowed for your humanity amount!";
  player action['getOut', _vehicle];
};
};
}; 
waituntil {uiSleep 0.5;(driver _vehicle == player)};
};

 

 

now in init.sqf

paste:

[] execVM 'humveh\hum_veh.sqf';

below of:

execFSM "\z\addons\dayz_code\system\player_monitor.fsm";

 

Link to comment
Share on other sites

  • 0

probably will not work at first time,, gonna need some test,  for example im not sure if you need recognize the vehicle with cursortarget select3  before say :

player action['getOut', _vehicle];

example:

_vehicle = cursorTarget;

 

or if all syntax about checks gonna work with this way.

Link to comment
Share on other sites

  • 0

_menClose = cursorTarget;
_hasPatient = alive _menClose;
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
_isClose = ((player distance _menClose) < ((sizeOf typeOf _menClose) / 2));

if (_inVehicle) then {
        r_player_lastVehicle = _vehicle;
        _assignedRole = assignedVehicleRole player;
        _driver = driver (vehicle player);

    if (({(isPlayer _driver) && (alive  _driver)} count (crew _vehicle) > 0)) then {
    
        DZE_heroHumanity =    ["Mi17_rockets_RU","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BRDM2_CDF","Offroad_SPG9_TERROR","BTR40_MG_TK_INS_EP1","M1126_ICV_M2_EP1","M113_TK_EP1"];

        DZE_superHeroHumanity =    ["Mi17_rockets_RU","Mi24_V","Mi24_P","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","AW159_lynx_baf","Ka52Black","Ka52","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BMP3","BRDM2_CDF","Offroad_SPG9_TERROR","T72_INS","BTR40_MG_TK_INS_EP1","BTR60_TK_EP1","M1126_ICV_M2_EP1","M113_TK_EP1","T55_TK_EP1","BAF_FV510_W"];
        
        DZE_agentHumanity =    ["AV8B2","AV8B","A10","F35B","L39_TK_EP1","BAF_Apache_AH1_D","AH1Z_DZ","SU39","SU34","Mi17_rockets_RU","Mi24_V","Mi24_P","Mi24_D","UH1Y_DZE","UH1Y","AH6J_EP1_DZE","CH_47F_BAF","ka137_mg_pmc","pook_H13_gunship_PMC","Mi171sh_rockets_CZ_EP1","Ka60_PMC","AW159_lynx_baf","Ka52Black","Ka52","HMMWV_mK19","HMMWV_TOW","HMMWV_Avenger","HMMWV_M998_Crows_M2_DES_EP1","ArmoredSUV_PMC_DZE4","BAF_JACKAL2_L2A1_W","BMP2_CDF","BMP3","BRDM2_CDF","Offroad_SPG9_TERROR","T72_INS","BTR40_MG_TK_INS_EP1","BTR60_TK_EP1","M1126_ICV_M2_EP1","M113_TK_EP1","T55_TK_EP1","BAF_FV510_W","M1126_ICV_mK19_EP1","M2A2_EP1","M2A3_EP1","M2A3_EP1","BTR90_DZ","M1A1","M1A2_TUSK_MG","Ural_ZU23_GUE","AAV","T90","ZSU_TK_EP1","T55_TK_EP1","MLRS_DES_EP1"];

        _humanity = _driver getVariable["humanity",0];

        if (typeOf _vehicle in DZE_heroHumanity && _humanity <= 20000) then {
        if (typeOf _vehicle in DZE_superHeroHumanity && _humanity <= 40000) then {
        if (typeOf _vehicle in DZE_agentHumanity && _humanity <= 60000) then {
        player action ["getOut", (vehicle player)];
        (format ["Your humanity, %1, is less than the required humanity to use this vehicle", _humanity]) call dayz_rollingMessages;
        };
        };
        };
    };
};

 

Can someone points my mistake here. cant make it work.

 

Link to comment
Share on other sites

  • 0

Still doesnt work sal. Where i put the code? at the start? at the end?

Do i need to add anything at the '_private' line of code?

Code starts like this:

scriptName "Functions\misc\fn_damageActions.sqf";

#include "\z\addons\dayz_code\util\array.hpp";

/***********************************************************
    ADD ACTIONS FOR A CASUALTY
    - Function
    - [] call fnc_usec_damageActions;
************************************************************/

    private ["_hasPatient","_vehicle","_inVehicle","_isClose","_assignedRole","_driver","_action","_turret","_weapons","_weaponName","_crew","_unconscious_crew","_patients","_vehType","_unit","_antibiotics","_bloodBags","_unconscious","_lowBlood","_injured","_hasSepsis","_inPain","_legsBroke","_armsBroke","_infected","_hasBandage","_hasSepsisBandage","_hasEpi","_hasMorphine","_hasSplint","_hasPainkillers","_hasEmptyBag","_hasTester","_hasAntibiotics","_hasBloodBag","_vehClose","_action1","_action2","_action3","_playerMagazines","_isFriendly"];

    _vehicle = vehicle player;
    _inVehicle = (_vehicle != player);

 

Link to comment
Share on other sites

  • 0
2 hours ago, totis said:

Still doesnt work sal. Where i put the code? at the start? at the end?

Do i need to add anything at the '_private' line of code?

Code starts like this:

scriptName "Functions\misc\fn_damageActions.sqf";

#include "\z\addons\dayz_code\util\array.hpp";

/***********************************************************
    ADD ACTIONS FOR A CASUALTY
    - Function
    - [] call fnc_usec_damageActions;
************************************************************/

    private ["_hasPatient","_vehicle","_inVehicle","_isClose","_assignedRole","_driver","_action","_turret","_weapons","_weaponName","_crew","_unconscious_crew","_patients","_vehType","_unit","_antibiotics","_bloodBags","_unconscious","_lowBlood","_injured","_hasSepsis","_inPain","_legsBroke","_armsBroke","_infected","_hasBandage","_hasSepsisBandage","_hasEpi","_hasMorphine","_hasSplint","_hasPainkillers","_hasEmptyBag","_hasTester","_hasAntibiotics","_hasBloodBag","_vehClose","_action1","_action2","_action3","_playerMagazines","_isFriendly"];

    _vehicle = vehicle player;
    _inVehicle = (_vehicle != player);

 

I didn't test it in an external script, I tested it in a way that means it works, i.e through the test kit.

It was just a quick fix of your code before I went to work.

Link to comment
Share on other sites

  • 0

@totis   @DAKA or @someoneelse

can you test it... if works i guess its gonna be a lil more better for your server performance using waituntil command at top of the loop.

veh_hum.sqf

private ["_vehicle","_driver","_humanity","_txt"];

while {true} do {

waitUntil {uiSleep 0.25;vehicle player != player};

_vehicle = vehicle player;
_driver = driver (vehicle player);

	if (({(isPlayer _driver) && (alive _driver)} count (crew _vehicle) > 0)) then {
		

		_humanity = _driver getVariable["humanity",0];

		if (typeOf _vehicle in DZE_heroHumanity && _humanity <= 20000 || (typeOf _vehicle in DZE_superHeroHumanity && _humanity <= 40000) || (typeOf _vehicle in DZE_agentHumanity && _humanity <= 60000)) then {
			player action ["getOut", (vehicle player)];
			titleText ["","WHITE IN"];
			_txt = "<img image='addons\vehicon.paa' /><br/><t size='0.7' color='#ea2828' align='center'>prohibited vehicle</t>";
            [_txt, [safezoneX, safezoneW], [0.20 * safezoneH + safezoneY, 0.3 * safezoneH], 2, 0.5] spawn BIS_fnc_dynamicText;
		};
	};

sleep 3;
};

 

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...