Hello everyone,
maybe there is someone around to help me getting this to work. I m not good in scripting.
Like i said above i want to force players to have a knife for open/eat a foodcan. In addition to that i want to have a chance of 40% that the knife can break while open the can. I m searching around the code and find the player_eat.sqf. I modified it like this but i m not able to get this to work. Nothing happen after i clicked on eat ingame. Thanks in advance..
maybe there is someone around to help me getting this to work. I m not good in scripting.
Like i said above i want to force players to have a knife for open/eat a foodcan. In addition to that i want to have a chance of 40% that the knife can break while open the can. I m searching around the code and find the player_eat.sqf. I modified it like this but i m not able to get this to work. Nothing happen after i clicked on eat ingame. Thanks in advance..
Code:
private ["_onLadder","_itemorignal","_hasfooditem","_rawfood","_hasoutput","_config","_text","_regen","_dis","_sfx","_itemtodrop","_nearByPile","_item","_display","_rawexceptions","_badfood","_invehicle"];
disableserialization;
call gear_ui_init;
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
if (_onLadder) exitWith {cutText [(localize "str_player_21") , "PLAIN DOWN"]};
//if (vehicle player != player) exitWith {cutText ["\n\nYou may not eat while in a vehicle", "PLAIN DOWN"]};
//Force players to wait 3 mins to eat again
//if (dayz_lastMeal < 180) exitWith {cutText ["You may not eat, you're already full", "PLAIN DOWN"]};
_itemorignal = _this;
_hasfooditem = _itemorignal in magazines player;
_rawfood = _itemorignal in meatraw;
_rawexceptions = _itemorignal in exceptionsraw;
_hasoutput = _itemorignal in food_with_output;
_badfood = _itemorignal in badfood;
_config = configFile >> "CfgMagazines" >> _itemorignal;
_text = getText (_config >> "displayName");
_regen = getNumber (_config >> "bloodRegen");
_needknife = _itemorignal in food_need_knife;
_hasknife = "ItemKnife" in _itemsPlayer;
_chance = floor(random 100);
if (!_hasfooditem) exitWith {cutText [format[(localize "str_player_31"),_text,"consume"] , "PLAIN DOWN"]};
if (_hasfooditem && _needknife) then {
if (_hasknife) then {
if (_chance > 40) then {
player removeWeapon "ItemKnife";
cutText ["The knife breaks. You couldnt open the can." , "PLAIN DOWN"];
} else {
player playActionNow "PutDown";
player removeMagazine _itemorignal;
_invehicle = false;
if (vehicle player != player) then {
_display = findDisplay 106;
_display closeDisplay 0;
_invehicle = true;
};
sleep 1;
_dis=6;
_sfx = "eat";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
if (_hasoutput and !_invehicle) then {
// Selecting output
_itemtodrop = food_output select (food_with_output find _itemorignal);
sleep 3;
_nearByPile= nearestObjects [(getposATL player), ["WeaponHolder","WeaponHolderBase"],2];
if (count _nearByPile ==0) then {
_iPos = getPosATL player;
_radius = 0.0;
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item setposATL _iPos;
} else {
_item = _nearByPile select 0;
};
_item addMagazineCargoGlobal [_itemtodrop,1];
};
if (_badfood and (random 2 < 1)) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
r_player_blood = r_player_blood + _regen;
if (r_player_blood > r_player_bloodTotal) then {
r_player_blood = r_player_bloodTotal;
};
player setVariable ["messing",[dayz_hunger,dayz_thirst],true];
player setVariable["USEC_BloodQty",r_player_blood,true];
player setVariable["medForceUpdate",true];
//["PVDZE_plr_Save",[player,[],true]] call callRpcProcedure;
PVDZE_plr_Save = [player,[],true,true];
publicVariableServer "PVDZE_plr_Save";
dayz_lastMeal = time;
dayz_hunger = 0;
//Ensure Control is visible
_display = uiNamespace getVariable 'DAYZ_GUI_display';
(_display displayCtrl 1301) ctrlShow true;
if (r_player_blood / r_player_bloodTotal >= 0.2) then {
(_display displayCtrl 1300) ctrlShow true;
};
cutText [format[(localize "str_player_consumed"),_text], "PLAIN DOWN"];
};
} else {
cutText ["Uff..i m not able to open the can.", "PLAIN DOWN"]
};
} else {
if (_rawfood and !_rawexceptions and (random 15 < 1)) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
if (_badfood and (random 2 < 1)) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
r_player_blood = r_player_blood + _regen;
if (r_player_blood > r_player_bloodTotal) then {
r_player_blood = r_player_bloodTotal;
};
player setVariable ["messing",[dayz_hunger,dayz_thirst],true];
player setVariable["USEC_BloodQty",r_player_blood,true];
player setVariable["medForceUpdate",true];
//["PVDZE_plr_Save",[player,[],true]] call callRpcProcedure;
PVDZE_plr_Save = [player,[],true,true];
publicVariableServer "PVDZE_plr_Save";
dayz_lastMeal = time;
dayz_hunger = 0;
//Ensure Control is visible
_display = uiNamespace getVariable 'DAYZ_GUI_display';
(_display displayCtrl 1301) ctrlShow true;
if (r_player_blood / r_player_bloodTotal >= 0.2) then {
(_display displayCtrl 1300) ctrlShow true;
};
cutText [format[(localize "str_player_consumed"),_text], "PLAIN DOWN"];
};