Spare tire script not quite working

SmokeyMeadow

Well-Known Member
I've been trying to adapt a spare tire script from one of the rmod 2 vehicles to work with other cars in day z. It's the M1161, the spare tire can be removed and used as a temporary fix (it goes away after server restart). I like this idea, and am even considering adding a timer to make the spare even more temporary, basically just have it useful as a way to get your vehicle to safety before it becomes immobilized again. But right now, I'm having trouble with it actually putting the tire on. I've written an fn_selfaction that works, and the tirechange.sqf does initialize and make the player perform the tire changing action. But no wheel is placed on the vehicle. Now obviously I don't expect to have the spare tire actually be removable from the day z vehicle, that would require too much 3d modeling and would drastically increase mission size. But for certain trucks, with a spare tire bolted to the side, I'd like to be able to at least use that.

here's the code for fn_selfactions:
Code:
// SPARE TIRE END
_isLand = (cursorTarget isKindOf "LandRover_TK_CIV_EP1") or (cursorTarget isKindOf "LandRover_CZ_EP1") or (cursorTarget isKindOf "LandRover_MG_TK_EP1") or (cursorTarget isKindOf "BAF_Offroad_D")  or (cursorTarget isKindOf "BAF_Offroad_W");
 
if ((_isLand) && ("ItemToolbox" in items player)) then {
    if (usespare < 0) then {
    usespare  = player addAction [("<t color=""#00c362"">" + ("Spare Tire") +"</t>"),"scripts\tirechange.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction usespare ;
    usespare  = -1;
};
// SPARE TIRE END

That is just for the landrover so far, but I intend to add the pickups and large trucks as well.

Here is the problematic code for tirechange.sqf. The only thing I changed was the _M116 variable name to _landrover:

Code:
if (isDedicated) exitWith {};
 
_Landrover = _this select 0;
 
_Landrover animate ["spare", 1];
 
// 'RepairingKneel' - 120 seconds
player playMove 'AinvPknlMstpSlayWrflDnon_medic';
sleep 8;
player playMove 'AinvPknlMstpSlayWrflDnon_medic';
sleep 8;
player playMove 'AinvPknlMstpSlayWrflDnon_medic';
sleep 8;
 
_Landrover setHit ["levy predni tlumic", 0];
_Landrover setHit ["levy zadni tlumic", 0];
_Landrover setHit ["pravy predni tlumic", 0];
_Landrover setHit ["pravy zadni tlumic", 0];
 
_Landrover setDamage 0.1;

Does anyone have an idea why it won't take the part?
 
Ok. After days of working with this, no luck at all getting it going. I did, however, write my own version of the script.

Code:
//private["_nospare","_actionId","_activatingPlayer","_radarObject","_item"];
//_nospare = _item getVariable["nospare",false];
//_item = _this select 3;
//_radarObject = _this select 0;
//_activatingPlayer = _this select 1;
//_actionId = _this select 2;
 
 
//if (!_hasHarvested) then {
player playActionNow "Medic";
sleep 1;
_sfx = "repair";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
_item setVariable["nospare",true,true];
titleText ["You are removing the spare tire.","PLAIN DOWN"]; titleFadeOut 5;
 
 
player addMagazine "PartWheel";       
sleep 0.01; 
 
titleText ["You have removed the spare tire.","PLAIN DOWN"]; titleFadeOut 5;
 
};

So that lets the spare wheel get taken off of the Landrover, not visually, but you perform the action. Problem is I can't seem to get the variable to work so that you can only use the tire once. Now you can just pull infinite magical tires off the truck. So it's a work in progress. I'm just updating so people don't think I gave up on it.
 
You would need some kind of extra Part/HitPoint added to the DB.
I don't think there's a way to check if the script was already executed and prevent it from running more then once on an object.
Even if its possible you would still be able to remove that part after the server restart.

Tapnięte za pomocą HTC Desire S
 
I was thinking something similar to the cannibalism script, where it flags a body as having already been gutted so you can't gut it over and over again. Just, for example, in that script it looks for
Code:
if (_hasKnife and !_hasHarvested) then {
So if the variable is _hasHarvested, you get no more meat. And after you gut the initial time, it sets the variable like this
Code:
_item setVariable["meatHarvested",true,true];
Which reports back to this line here
Code:
_hasHarvested = _item getVariable["meatHarvested",false];
So now the _hasharvested variable reads as true, which means the action can't be executed again. But when I try to use this method on my own script, nothing happens. Frustrating, but it's probably some n00b error I'm making.
 
Back
Top