Jump to content

[Tutorial] Invisible Backpack for cop/med 4.4r3 [BASIC]


MoNtEcRiStO©
 Share

Recommended Posts

 

I just readjusted the script. "==" with "isEqualTo". If you have a problem it's missing a "};" at the end of the script.

Sorry for my English. I am french

#include "..\script_macros.hpp"
/*
    File: fn_survival.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    All survival? things merged into one thread.
*/
private ["_fnc_food","_fnc_water","_foodTime","_waterTime","_bp","_walkDis","_lastPos","_curPos"];
_fnc_food =  {
    if (life_hunger < 2) then {player setDamage 1; hint localize "STR_NOTF_EatMSG_Death";}
    else
    {
        life_hunger = life_hunger - 10;
        [] call life_fnc_hudUpdate;
        if (life_hunger < 2) then {player setDamage 1; hint localize "STR_NOTF_EatMSG_Death";};
        switch (life_hunger) do {
            case 30: {hint localize "STR_NOTF_EatMSG_1";};
            case 20: {hint localize "STR_NOTF_EatMSG_2";};
            case 10: {
                hint localize "STR_NOTF_EatMSG_3";
                if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
            };
        };
    };
};

_fnc_water = {
    if (life_thirst < 2) then {player setDamage 1; hint localize "STR_NOTF_DrinkMSG_Death";}
    else
    {
        life_thirst = life_thirst - 10;
        [] call life_fnc_hudUpdate;
        if (life_thirst < 2) then {player setDamage 1; hint localize "STR_NOTF_DrinkMSG_Death";};
        switch (life_thirst) do  {
            case 30: {hint localize "STR_NOTF_DrinkMSG_1";};
            case 20: {
                hint localize "STR_NOTF_DrinkMSG_2";
                if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
            };
            case 10: {
                hint localize "STR_NOTF_DrinkMSG_3";
                if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
            };
        };
    };
};

//Setup the time-based variables.
_foodTime = time;
_waterTime = time;
_walkDis = 0;
_bp = "";
_lastPos = visiblePosition player;
_lastPos = (_lastPos select 0) + (_lastPos select 1);
_lastState = vehicle player;

for "_i" from 0 to 1 step 0 do {
    /* Thirst / Hunger adjustment that is time based */
    if ((time - _waterTime) > 600) then {[] call _fnc_water; _waterTime = time;};
    if ((time - _foodTime) > 850) then {[] call _fnc_food; _foodTime = time;};

    /* Adjustment of carrying capacity based on backpack changes */
    if (backpack player isEqualTo "") then {
        life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight");
        _bp = backpack player;
    } else {
        if (!(backpack player isEqualTo "") && {!(backpack player isEqualTo _bp)}) then {
            _bp = backpack player;
            life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight") + round(FETCH_CONFIG2(getNumber,"CfgVehicles",_bp,"maximumload") / 4);
        };
    };

    /* Check if the player's state changed? */
    if (vehicle player != _lastState || {!alive player}) then {
        [] call life_fnc_updateViewDistance;
        _lastState = vehicle player;
    };

    /* Check if the weight has changed and the player is carrying to much */
    if (life_carryWeight > life_maxWeight && {!isForcedWalk player}) then {
        player forceWalk true;
        if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
        hint localize "STR_NOTF_MaxWeight";
    } else {
        if (isForcedWalk player) then {
            player forceWalk false;
        };
    };

    /* Travelling distance to decrease thirst/hunger which is captured every second so the distance is actually greater then 650 */
    if (!alive player) then {_walkDis = 0;} else {
        _curPos = visiblePosition player;
        _curPos = (_curPos select 0) + (_curPos select 1);
        if (!(_curPos isEqualTo _lastPos) && {(isNull objectParent player)}) then {
            _walkDis = _walkDis + 1;
            if (_walkDis isEqualTo 650) then {
                _walkDis = 0;
                life_thirst = life_thirst - 5;
                life_hunger = life_hunger - 5;
                [] call life_fnc_hudUpdate;
            };
        };
        _lastPos = visiblePosition player;
        _lastPos = (_lastPos select 0) + (_lastPos select 1);
    };
    uiSleep 1;
	[] spawn
	{
		private["_bp","_load","_cfg"];
		while{true} do
		{
			waitUntil {backpack player != ""};
			_bp = backpack player;
			_cfg = getNumber(configFile >> "CfgVehicles" >> (backpack player) >> "maximumload");
			_load = round(_cfg / 8);
			life_maxWeight = life_maxWeightT + _load;
			if(playerSide isEqualTo west) then {(unitBackpack player) setObjectTextureGlobal [0,""];}; // <---- Sac invisible chez les flics
			if(playerSide isEqualTo independent) then {(unitBackpack player) setObjectTextureGlobal [0,""];}; // <----- Sac Invisible chez les Medics
			waitUntil {backpack player != _bp};
			if(backpack player isEqualTo "") then 
			{
				life_maxWeight = life_maxWeightT;
			};
		};
	};
};

 

Edited by Voltoring
  • Like 1
Link to comment
Share on other sites

6 hours ago, Voltoring said:

 

I just readjusted the script. "==" with "isEqualTo". If you have a problem it's missing a "};" at the end of the script.

Sorry for my English. I am french

#include "..\script_macros.hpp"
/*
    File: fn_survival.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    All survival? things merged into one thread.
*/
private ["_fnc_food","_fnc_water","_foodTime","_waterTime","_bp","_walkDis","_lastPos","_curPos"];
_fnc_food =  {
    if (life_hunger < 2) then {player setDamage 1; hint localize "STR_NOTF_EatMSG_Death";}
    else
    {
        life_hunger = life_hunger - 10;
        [] call life_fnc_hudUpdate;
        if (life_hunger < 2) then {player setDamage 1; hint localize "STR_NOTF_EatMSG_Death";};
        switch (life_hunger) do {
            case 30: {hint localize "STR_NOTF_EatMSG_1";};
            case 20: {hint localize "STR_NOTF_EatMSG_2";};
            case 10: {
                hint localize "STR_NOTF_EatMSG_3";
                if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
            };
        };
    };
};

_fnc_water = {
    if (life_thirst < 2) then {player setDamage 1; hint localize "STR_NOTF_DrinkMSG_Death";}
    else
    {
        life_thirst = life_thirst - 10;
        [] call life_fnc_hudUpdate;
        if (life_thirst < 2) then {player setDamage 1; hint localize "STR_NOTF_DrinkMSG_Death";};
        switch (life_thirst) do  {
            case 30: {hint localize "STR_NOTF_DrinkMSG_1";};
            case 20: {
                hint localize "STR_NOTF_DrinkMSG_2";
                if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
            };
            case 10: {
                hint localize "STR_NOTF_DrinkMSG_3";
                if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
            };
        };
    };
};

//Setup the time-based variables.
_foodTime = time;
_waterTime = time;
_walkDis = 0;
_bp = "";
_lastPos = visiblePosition player;
_lastPos = (_lastPos select 0) + (_lastPos select 1);
_lastState = vehicle player;

for "_i" from 0 to 1 step 0 do {
    /* Thirst / Hunger adjustment that is time based */
    if ((time - _waterTime) > 600) then {[] call _fnc_water; _waterTime = time;};
    if ((time - _foodTime) > 850) then {[] call _fnc_food; _foodTime = time;};

    /* Adjustment of carrying capacity based on backpack changes */
    if (backpack player isEqualTo "") then {
        life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight");
        _bp = backpack player;
    } else {
        if (!(backpack player isEqualTo "") && {!(backpack player isEqualTo _bp)}) then {
            _bp = backpack player;
            life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight") + round(FETCH_CONFIG2(getNumber,"CfgVehicles",_bp,"maximumload") / 4);
        };
    };

    /* Check if the player's state changed? */
    if (vehicle player != _lastState || {!alive player}) then {
        [] call life_fnc_updateViewDistance;
        _lastState = vehicle player;
    };

    /* Check if the weight has changed and the player is carrying to much */
    if (life_carryWeight > life_maxWeight && {!isForcedWalk player}) then {
        player forceWalk true;
        if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 1;};
        hint localize "STR_NOTF_MaxWeight";
    } else {
        if (isForcedWalk player) then {
            player forceWalk false;
        };
    };

    /* Travelling distance to decrease thirst/hunger which is captured every second so the distance is actually greater then 650 */
    if (!alive player) then {_walkDis = 0;} else {
        _curPos = visiblePosition player;
        _curPos = (_curPos select 0) + (_curPos select 1);
        if (!(_curPos isEqualTo _lastPos) && {(isNull objectParent player)}) then {
            _walkDis = _walkDis + 1;
            if (_walkDis isEqualTo 650) then {
                _walkDis = 0;
                life_thirst = life_thirst - 5;
                life_hunger = life_hunger - 5;
                [] call life_fnc_hudUpdate;
            };
        };
        _lastPos = visiblePosition player;
        _lastPos = (_lastPos select 0) + (_lastPos select 1);
    };
    uiSleep 1;
	[] spawn
	{
		private["_bp","_load","_cfg"];
		while{true} do
		{
			waitUntil {backpack player != ""};
			_bp = backpack player;
			_cfg = getNumber(configFile >> "CfgVehicles" >> (backpack player) >> "maximumload");
			_load = round(_cfg / 8);
			life_maxWeight = life_maxWeightT + _load;
			if(playerSide isEqualTo west) then {(unitBackpack player) setObjectTextureGlobal [0,""];}; // <---- Sac invisible chez les flics
			if(playerSide isEqualTo independent) then {(unitBackpack player) setObjectTextureGlobal [0,""];}; // <----- Sac Invisible chez les Medics
			waitUntil {backpack player != _bp};
			if(backpack player isEqualTo "") then 
			{
				life_maxWeight = life_maxWeightT;
			};
		};
	};
};

 

translate.google

Danke das hat funktioniert!

Thanks that worked!

Merci cela a fonctionné!

Link to comment
Share on other sites

	[] spawn
	{
		private["_bp","_load","_cfg"];
		while{true} do
		{
			waitUntil {backpack player != ""};
			_bp = backpack player;
			_cfg = getNumber(configFile >> "CfgVehicles" >> (backpack player) >> "maximumload");
			_load = round(_cfg / 8);
			life_maxWeight = life_maxWeightT + _load;
			if(playerSide isEqualTo west) then {(unitBackpack player) setObjectTextureGlobal [0,""];}; // <---- Sac invisible chez les flics
			if(playerSide isEqualTo independent) then {(unitBackpack player) setObjectTextureGlobal [0,""];}; // <----- Sac Invisible chez les Medics
			waitUntil {backpack player != _bp};
			if(backpack player isEqualTo "") then 
			{
				life_maxWeight = life_maxWeightT;
			};
		};
	};
};
Edited by [IL] KingCrazyHunter
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 1 month later...

Hi,

 

I found the solution for this to work.

 

Put that 2 code lines before "if (backpack player isEqualTo "") then {"

if(playerSide isEqualTo west) then {(unitBackpack player) setObjectTextureGlobal [0,""];};
if(playerSide isEqualTo independent) then {(unitBackpack player) setObjectTextureGlobal [0,""];};

It will look like this:

if(playerSide isEqualTo west) then {(unitBackpack player) setObjectTextureGlobal [0,""];};
if(playerSide isEqualTo independent) then {(unitBackpack player) setObjectTextureGlobal [0,""];};
if (backpack player isEqualTo "") then {
    life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight");
    _bp = backpack player;
} else {
    if (!(backpack player isEqualTo "") && {!(backpack player isEqualTo _bp)}) then {
        _bp = backpack player;
        life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight") + round(FETCH_CONFIG2(getNumber,"CfgVehicles",_bp,"maximumload") / 4);
    };
};

Regards,

Bl4cKSh4d6W

Link to comment
Share on other sites

  • 4 months later...
On 16/9/2016 at 7:03 AM, MoNtEcRiStO© said:

Non ricordo dove lo trovo ma lo ho nel mio vecchio styff, molto utile per il server di vaniglia.

-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------------------

Difficoltà: Facile 

Autore: MoNtEcRiStO © 

-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------------------

Aggiungilo in: mission.Altis / core / fn_survival.sqf

 

Fatto!

is not work mission5.0.0

Link to comment
Share on other sites

  • 2 months later...

This is my fn_surrival. How do I fix i t?

[] spawn
	{
		private["_bp","_load","_cfg"];
		while{true} do
		{
			waitUntil {backpack player != ""};
			_bp = backpack player;
			_cfg = getNumber(configFile >> "CfgVehicles" >> (backpack player) >> "maximumload");
			_load = round(_cfg / 8);
			life_maxWeight = life_maxWeightT + _load;
			if(playerSide isEqualTo west) then {(unitBackpack player) setObjectTextureGlobal [0,""];};
			if(playerSide isEqualTo independent) then {(unitBackpack player) setObjectTextureGlobal [0,""];};
			if (backpack player isEqualTo "") then {
			life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight");
			_bp = backpack player;
			} else {
			if (!(backpack player isEqualTo "") && {!(backpack player isEqualTo _bp)}) then {
			_bp = backpack player;
			life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight") + round(FETCH_CONFIG2(getNumber,"CfgVehicles",_bp,"maximumload") / 4);
			};
			
			waitUntil {backpack player != _bp};
			if(backpack player isEqualTo "") then 
			{
				life_maxWeight = life_maxWeightT;
			};
		};
	};
};

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 5 months later...
8 minutes ago, Nirawin said:

Getting the same error, any fix ?

Thanks

Do it this way instead, Go to fn_playerSkins.sqf and add this under case west & case independent if you want it for cops and medics.

Quote

        if (backpack player isEqualTo "B_Carryall_cbr") then {
            (backpackContainer player) setObjectTextureGlobal [0, ""];
        };

just change this "B_Carryall_cbr" to whatever backpack you want to be invisible.

Link to comment
Share on other sites

2 hours ago, Hyper4u.'<3 said:

Do it this way instead, Go to fn_playerSkins.sqf and add this under case west & case independent if you want it for cops and medics.

just change this "B_Carryall_cbr" to whatever backpack you want to be invisible.

Worked (5.0) thanks man !

Link to comment
Share on other sites

  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.