[Request] Toolbelt items having charges & Fuel tanks have limited Fuel

Adding a random chance to loose what you are using, hatchet, toolbox, matches etc is not hard at all. But giving them a set amount of uses would require writing them to DB, would people be happy with the first option?
 
Rossymond: i would be interested, if possible make a wide variety of objects possible and make the % chance of failure (deletion) 0.00 - 1.00 so we can really make it what we want.

Dosent seem that hard at all, i agree, the max uses is too much
 
My modifications for Manatees server to fill Jerry Cans, it does not use DB, but lasts / resets every restart.

It's a little bit ugly, and maybe you can decide to use a different object then a barrel. (Land_Fire_Barrel) as this might cause some conflicts on some maps. (It's ok on Celle.)

So what is it doing: The idea is to just assign a "Variable" using setVariable with a random number of available jerry cans to fill. Since you can only use setVariable on vehicles, I create a vehicle - which in this case is just a Land_Fire_Barrel (I spawn it the same as a Fire pit, but under ground.)

When a person tries to fill the jerry can, we see if there exists a fire barrel first. If it does, let the player fill the jerry can if the variable is > 0.

If there is no fire barrel around, then create one and assign some random jerry can amount.

The line _fuelAmount = round(random 6); sets a random jerrycan amount left. So there is a chance that the fueltank is empty right away.

Code:
private["_hasFood","_item","_text","_qty"];
 
player removeAction s_player_fillfuel;
s_player_fillfuel = -1;
 
// prevent some chance of duping fuel
_someoneAround = ({isPlayer _x} count (getPos vehicle player nearEntities [["AllVehicles"], 8]))-1;
if (_someoneAround != 0) exitWith {cutText [format["You dont need to hold hands to refuel jerrycans!"] , "PLAIN DOWN"]};
 
_fuelAmount = 0;
_fuelBarrel = "Land_Fire_barrel";
 
// this is my "vehicle" which I assign a variable of fuel amount to
_hasFuelAlready = count ((position player) nearObjects ['Land_Fire_barrel', 30]) > 0;
if (!_hasFuelAlready) then {
    _spawn = "Land_Fire_barrel";
    cutText [format["You set up some tubing and hope for the best."], "PLAIN DOWN"];
    _posplr = [((getPos player) select 0), ((getPos player) select 1),-20];
    _spwnveh = createVehicle [_spawn, _posplr, [], 0, "CAN_COLLIDE"];
    _spwnveh setVariable ["Sarge",1,true];
    _fuelAmount = round(random 6);
    _spwnveh setVariable ["fuelAmount",_fuelAmount,true];
} else {
    _fuelBarrel = (position player) nearObjects ['Land_Fire_barrel', 30];
    _fuelBarrel = _fuelBarrel select 0;
    _fuelAmount = _fuelBarrel getVariable["fuelAmount",0];
};
 
 
if ("ItemJerrycanEmpty" in magazines player) then {
 
  if (_fuelAmount == 0) exitWith {
      cutText [format["This fuel tank is empty."], "PLAIN DOWN"];
    };
 
    _fuelAmount = _fuelAmount - 1;
    _fuelBarrel setVariable ["fuelAmount",_fuelAmount,true];
    player removeMagazine "ItemJerrycanEmpty";
    player addMagazine "ItemJerrycan";
    player playActionNow "Medic";
 
    _dis=10;
    _sfx = "refuel";
    [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
    [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
 
    cutText [format["There is barely any fuel left, but you filled a Jerrycan."], "PLAIN DOWN"];
} else {
    cutText [(localize "str_player_10") , "PLAIN DOWN"];
};


Also breaking items is pretty simple: Here is just a small snipped from our salvage script which requires you to have a crowbar.

Code:
            _chance = floor(random 100);
 
            if (_chance < 5) exitWith { // remove crowbar
                player removeWeapon "ItemCrowbar";
                player playActionNow "Medic";
                [player,"repair",0,false] call dayz_zombieSpeak;
                _null = [player,50,true,(getPosATL player)] spawn player_alertZombies;
                cutText ["Your crowbar slips from your hands and falls down a stormdrain, Oops." , "PLAIN DOWN"];
                sleep 8;
                disableUserInput false;
            };

You want to insert such a snipped in any code before it actually does anything. Otherwise it defeats the purpose.

Note: We orioginally had breaking chance of 15%, but that seemed too high when actually playing the damn game - so it was reduced to 10, 7 and now set at 5.

Also with the limited fuel, we prefer it this way, but if you have multiple fuel tanks within the Land_Barrel range, then those will read the same variable and contain/deduct fuel from the same "source"
 
Hey Allen this sounds great, but iam new to "scripting" can you explain a bit more where to put these fine piece of code. Thx
 
Back
Top