khalcifer Posted August 21, 2017 Report Share Posted August 21, 2017 Hello how can i change scripts add ItemKiloHemp to backpack Spoiler private ["_hempqty","_hasMachete","_findHemp","_countHemp","_playerNear"]; if (dayz_actioninprogress) exitWith {}; dayz_actioninprogress = true; _hempqty = {_x == "ItemKiloHemp"} count magazines player; _hasMachete = "ItemMachete" in items player; _findHemp = nearestObjects [player,["fiberplant"],5]; _countHemp = count _findHemp; _playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 10]) > 1; player removeAction s_player_Getweed; s_player_Getweed = -1; if (_playerNear) exitWith { cutText ["Cannot do this while another player is nearby!","PLAIN"]; }; if (vehicle player != player) exitWith { cutText ["You cannot do this while in a vehicle!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (_hempqty > 9) exitWith { cutText ["WARNING: You have a max amount of weed in your inventory!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (!_hasMachete) exitWith { cutText ["You need a Machete to do this!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (_countHemp > 0) then { r_interrupt = false; player playActionNow "PutDown"; deleteVehicle (_findHemp select 0); player addMagazine "ItemKiloHemp"; cutText ["You collected some precious weed!", "PLAIN DOWN"]; //[format["%1 Gathered WEED.",name player]] call my_scripts_logger; uiSleep 3; if (round(random(100)) == 1) then { [player,1] call GiveXP; }; } else { cutText ["There is no more Hemp! :'(", "PLAIN DOWN"]; }; dayz_actioninprogress = false; Link to comment Share on other sites More sharing options...
juandayz Posted August 21, 2017 Report Share Posted August 21, 2017 Just now, khalcifer said: Hello how can i change scripts add ItemKiloHemp to backpack Reveal hidden contents private ["_hempqty","_hasMachete","_findHemp","_countHemp","_playerNear"]; if (dayz_actioninprogress) exitWith {}; dayz_actioninprogress = true; _hempqty = {_x == "ItemKiloHemp"} count magazines player; _hasMachete = "ItemMachete" in items player; _findHemp = nearestObjects [player,["fiberplant"],5]; _countHemp = count _findHemp; _playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 10]) > 1; player removeAction s_player_Getweed; s_player_Getweed = -1; if (_playerNear) exitWith { cutText ["Cannot do this while another player is nearby!","PLAIN"]; }; if (vehicle player != player) exitWith { cutText ["You cannot do this while in a vehicle!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (_hempqty > 9) exitWith { cutText ["WARNING: You have a max amount of weed in your inventory!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (!_hasMachete) exitWith { cutText ["You need a Machete to do this!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (_countHemp > 0) then { r_interrupt = false; player playActionNow "PutDown"; deleteVehicle (_findHemp select 0); player addMagazine "ItemKiloHemp"; cutText ["You collected some precious weed!", "PLAIN DOWN"]; //[format["%1 Gathered WEED.",name player]] call my_scripts_logger; uiSleep 3; if (round(random(100)) == 1) then { [player,1] call GiveXP; }; } else { cutText ["There is no more Hemp! :'(", "PLAIN DOWN"]; }; dayz_actioninprogress = false; maybe something like: _player = player; _backPack = typeOf (unitBackPack _player); if (_backPack != "") then { _backPack addMagazine "ItemKiloHemp"; }else{ _player addMagazine "ItemKiloHemp"; }; or you can take a look how advanced trading add items to the backpack when you buy. Link to comment Share on other sites More sharing options...
Tech_Support Posted August 22, 2017 Report Share Posted August 22, 2017 try this small edit private ["_bp","_hempqty","_hasMachete","_findHemp","_countHemp","_playerNear"]; if (dayz_actioninprogress) exitWith {}; dayz_actioninprogress = true; _hempqty = {_x == "ItemKiloHemp"} count magazines player; _hasMachete = "ItemMachete" in items player; _findHemp = nearestObjects [player,["fiberplant"],5]; _countHemp = count _findHemp; _playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 10]) > 1; player removeAction s_player_Getweed; s_player_Getweed = -1; if (_playerNear) exitWith { cutText ["Cannot do this while another player is nearby!","PLAIN"]; }; if (vehicle player != player) exitWith { cutText ["You cannot do this while in a vehicle!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (_hempqty > 9) exitWith { cutText ["WARNING: You have a max amount of weed in your inventory!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (!_hasMachete) exitWith { cutText ["You need a Machete to do this!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (_countHemp > 0) then { r_interrupt = false; player playActionNow "PutDown"; deleteVehicle (_findHemp select 0); _bp = unitBackpack player; _bp addMagazineCargoGlobal ["ItemKiloHemp",1]; cutText ["You collected some precious weed!", "PLAIN DOWN"]; //[format["%1 Gathered WEED.",name player]] call my_scripts_logger; uiSleep 3; if (round(random(100)) == 1) then { [player,1] call GiveXP; }; } else { cutText ["There is no more Hemp! :'(", "PLAIN DOWN"]; }; dayz_actioninprogress = false; juandayz 1 Link to comment Share on other sites More sharing options...
juandayz Posted August 22, 2017 Report Share Posted August 22, 2017 @Tech_Support think you need add the restriction about players without backpacks if (_bp != "") exitWith{dayz_actioninprogress = false; systemchat "need a backpack";}; above this line: _bp addMagazineCargoGlobal ["ItemKiloHemp",1]; Tech_Support 1 Link to comment Share on other sites More sharing options...
Tech_Support Posted August 26, 2017 Report Share Posted August 26, 2017 Im lazy lol guess this line needs to be edited also _hempqty = {_x == "ItemKiloHemp"} count magazines player; so it should check the players backpack instead ? juandayz 1 Link to comment Share on other sites More sharing options...
juandayz Posted August 27, 2017 Report Share Posted August 27, 2017 10 hours ago, Tech_Support said: Im lazy lol guess this line needs to be edited also _hempqty = {_x == "ItemKiloHemp"} count magazines player; so it should check the players backpack instead ? maybe.. _bpWpn = getWeaponCargo unitBackpack player; _bpMag = getMagazineCargo unitBackpack player; if ((count _bpWpn >=10) or (count _bpMag >= 10)) exitWith {dayz_actioninprogress = false; systemchat "no more room";}; its not the best way but is only that i can think right now. Spoiler private ["_bp","_bpWpn","_bpMag","_hasMachete","_findHemp","_countHemp","_playerNear"]; if (dayz_actioninprogress) exitWith {}; dayz_actioninprogress = true; _hasMachete = "ItemMachete" in items player; _findHemp = nearestObjects [player,["fiberplant"],5]; _countHemp = count _findHemp; _playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 10]) > 1; player removeAction s_player_Getweed; s_player_Getweed = -1; if (_playerNear) exitWith { cutText ["Cannot do this while another player is nearby!","PLAIN"]; }; if (vehicle player != player) exitWith { cutText ["You cannot do this while in a vehicle!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (!_hasMachete) exitWith { cutText ["You need a Machete to do this!", "PLAIN DOWN"]; dayz_actioninprogress = false; }; if (_countHemp > 0) then { _bp = unitBackpack player; if (_bp != "") exitWith{dayz_actioninprogress = false; systemchat "need a backpack";}; _bpWpn = getWeaponCargo unitBackpack player; _bpMag = getMagazineCargo unitBackpack player; if ((count _bpWpn >=10) or (count _bpMag >= 10)) exitWith {dayz_actioninprogress = false; systemchat "no more room";}; r_interrupt = false; player playActionNow "PutDown"; deleteVehicle (_findHemp select 0); _bp addMagazineCargoGlobal ["ItemKiloHemp",1]; cutText ["You collected some precious weed!", "PLAIN DOWN"]; //[format["%1 Gathered WEED.",name player]] call my_scripts_logger; uiSleep 3; if (round(random(100)) == 1) then { [player,1] call GiveXP; }; } else { cutText ["There is no more Hemp! :'(", "PLAIN DOWN"]; }; dayz_actioninprogress = false; Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now