mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-09 09:42:52 +03:00
another sync with trader fixes
This commit is contained in:
@@ -18,44 +18,96 @@ if (isServer) then {
|
||||
|
||||
waitUntil {!isNil "dayzTraderMenuResult"};
|
||||
|
||||
/*
|
||||
`item` varchar(255) NOT NULL COMMENT '[Class Name,1 = CfgMagazines | 2 = Vehicle | 3 = Weapon]',
|
||||
`qty` int(8) NOT NULL COMMENT 'amount in stock available to buy',
|
||||
`buy` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]',
|
||||
`sell` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]',
|
||||
`order` int(2) NOT NULL DEFAULT '0' COMMENT '# sort order for addAction menu',
|
||||
`tid` int(8) NOT NULL COMMENT 'Trader Menu ID',
|
||||
`afile` varchar(64) NOT NULL DEFAULT 'trade_items',
|
||||
*/
|
||||
|
||||
diag_log format["DEBUG Buy: %1", dayzTraderMenuResult];
|
||||
{
|
||||
_header = _x select 0; // "TRD"
|
||||
_btype = _x select 1;
|
||||
_stype = _x select 2;
|
||||
_loc = _x select 3;
|
||||
_name = _x select 4;
|
||||
_qty = _x select 5;
|
||||
_cost = _x select 6;
|
||||
_bcurrency = _x select 7;
|
||||
_sell = _x select 8;
|
||||
_scurrency = _x select 9;
|
||||
_cat = _x select 10;
|
||||
_order = _x select 11;
|
||||
_tid = _x select 12;
|
||||
_actionFile = _x select 13;
|
||||
|
||||
_textPart = getText(configFile >> _btype >> _name >> "displayName");
|
||||
// Trader Item name|type
|
||||
_item = _x select 1;
|
||||
_name = _item select 0;
|
||||
_type = _item select 1;
|
||||
switch(true)do{
|
||||
case (_type == 1): {
|
||||
_type = "CfgMagazines";
|
||||
};
|
||||
case (_type == 2): {
|
||||
_type = "CfgVehicles";
|
||||
};
|
||||
case (_type == 3): {
|
||||
_type = "CfgWeapons";
|
||||
};
|
||||
};
|
||||
// Display Name of item
|
||||
_textPart = getText(configFile >> _type >> _name >> "displayName");
|
||||
|
||||
_File = "\z\addons\dayz_code\actions\" + _actionFile + ".sqf";
|
||||
// Total in stock
|
||||
_qty = _x select 2;
|
||||
|
||||
_part_out = _name;
|
||||
_part_in = _bcurrency;
|
||||
// Buy Data from array
|
||||
_buy = _x select 3;
|
||||
_bqty = _buy select 0;
|
||||
_bname = _buy select 1;
|
||||
_btype = _buy select 2;
|
||||
switch(true)do{
|
||||
case (_btype == 1): {
|
||||
_btype = "CfgMagazines";
|
||||
};
|
||||
case (_btype == 2): {
|
||||
_btype = "CfgVehicles";
|
||||
};
|
||||
case (_btype == 3): {
|
||||
_btype = "CfgWeapons";
|
||||
};
|
||||
};
|
||||
// Display Name of buy item
|
||||
_textCurrency = getText(configFile >> _btype >> _bname >> "displayName");
|
||||
|
||||
// Sell data from array
|
||||
_sell = _x select 4;
|
||||
_sqty = _sell select 0;
|
||||
_sname = _sell select 1;
|
||||
_stype = _sell select 2;
|
||||
|
||||
// Menu sort order
|
||||
_order = _x select 5;
|
||||
|
||||
// Trader Menu ID
|
||||
_tid = _x select 6;
|
||||
|
||||
// Action file to use for trade
|
||||
_afile = _x select 7;
|
||||
_File = "\z\addons\dayz_code\actions\" + _afile + ".sqf";
|
||||
|
||||
// Allways 1 for now
|
||||
_out = 1;
|
||||
_in = _cost;
|
||||
// qty consumed of bname
|
||||
_in = _bqty;
|
||||
|
||||
_textCurrency = getText(configFile >> _stype >> _part_in >> "displayName");
|
||||
|
||||
_Display = format["Buy %1 for %2 %3", _textPart, _cost, _textCurrency];
|
||||
|
||||
// trade_items.sqf | [part_out, part_in, qty_out, qty_in,_textPart,_textCurrency];
|
||||
_part = player addAction [_Display, _File,[_part_out,_part_in,_out,_in,"buy",_textPart,_textCurrency], _order, true, true, "",""];
|
||||
if(_qty <= 0) then {
|
||||
_Display = format["Buy %1 (Out of Stock: %2)", _textPart, _qty];
|
||||
_part = player addAction [_Display, "\z\addons\dayz_code\actions\trade_cancel.sqf",[], 0, true, false, "",""];
|
||||
} else {
|
||||
_Display = format["Buy %1 for %2 %3 (Available: %4)", _textPart, _in, _textCurrency, _qty];
|
||||
_part = player addAction [_Display, _File,[_name,_bname,_out,_in,"buy",_textCurrency,_textPart], _order, true, true, "",""];
|
||||
};
|
||||
|
||||
diag_log format["DEBUG TRADER: %1", _part];
|
||||
s_player_parts set [count s_player_parts,_part];
|
||||
|
||||
} forEach dayzTraderMenuResult;
|
||||
|
||||
_cancel = player addAction ["Cancel", "\z\addons\dayz_code\actions\trade_cancel.sqf",["medical"], 10, true, false, "",""];
|
||||
_cancel = player addAction ["Cancel", "\z\addons\dayz_code\actions\trade_cancel.sqf",["medical"], 0, true, false, "",""];
|
||||
s_player_parts set [count s_player_parts,_cancel];
|
||||
|
||||
// Clear Data maybe consider cacheing results
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
private["_vehicle"];
|
||||
_vehicle = _this select 3;
|
||||
|
||||
_vehicle setVehicleInit "this lock true";
|
||||
_vehicle setVehicleInit "this lockCargo true";
|
||||
_vehicle setVehicleInit "this lock true; this lockCargo true;";
|
||||
|
||||
processInitCommands;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
private["_activatingPlayer","_trader_id","_category","_action","_id","_btype","_stype","_loc","_name","_qty","_cost","_qty","_sell","_order","_tid","_bcurrency","_scurrency","_actionFile","_in","_out","_part","_cat","_cancel","_Display","_File","_textCurrency","_textPart"];
|
||||
private["_activatingPlayer","_trader_id","_category","_action","_id","_type","_loc","_name","_qty","_cost","_qty","_sell","_cur","_order","_tid","_currency","_actionFile","_in","_out","_part","_cat","_cancel","_Display","_File","_textCurrency","_textPart"];
|
||||
|
||||
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
|
||||
|
||||
@@ -18,45 +18,93 @@ if (isServer) then {
|
||||
|
||||
waitUntil {!isNil "dayzTraderMenuResult"};
|
||||
|
||||
diag_log format["DEBUG Sell: %1", dayzTraderMenuResult];
|
||||
/*
|
||||
`item` varchar(255) NOT NULL COMMENT '[Class Name,1 = CfgMagazines | 2 = Vehicle | 3 = Weapon]',
|
||||
`qty` int(8) NOT NULL COMMENT 'amount in stock available to buy',
|
||||
`buy` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]',
|
||||
`sell` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]',
|
||||
`order` int(2) NOT NULL DEFAULT '0' COMMENT '# sort order for addAction menu',
|
||||
`tid` int(8) NOT NULL COMMENT 'Trader Menu ID',
|
||||
`afile` varchar(64) NOT NULL DEFAULT 'trade_items',
|
||||
*/
|
||||
|
||||
diag_log format["DEBUG Buy: %1", dayzTraderMenuResult];
|
||||
{
|
||||
_header = _x select 0; // "TRD"
|
||||
_btype = _x select 1;
|
||||
_stype = _x select 2;
|
||||
_loc = _x select 3;
|
||||
_name = _x select 4;
|
||||
_qty = _x select 5;
|
||||
_cost = _x select 6;
|
||||
_bcurrency = _x select 7;
|
||||
_sell = _x select 8;
|
||||
_scurrency = _x select 9;
|
||||
_cat = _x select 10;
|
||||
_order = _x select 11;
|
||||
_tid = _x select 12;
|
||||
_actionFile = _x select 13;
|
||||
|
||||
_textPart = getText(configFile >> _stype >> _scurrency >> "displayName");
|
||||
// Trader Item name|type
|
||||
_item = _x select 1;
|
||||
_name = _item select 0;
|
||||
_type = _item select 1;
|
||||
switch(true)do{
|
||||
case (_type == 1): {
|
||||
_type = "CfgMagazines";
|
||||
};
|
||||
case (_type == 2): {
|
||||
_type = "CfgVehicles";
|
||||
};
|
||||
case (_type == 3): {
|
||||
_type = "CfgWeapons";
|
||||
};
|
||||
};
|
||||
// Display Name of item
|
||||
_textPart = getText(configFile >> _type >> _name >> "displayName");
|
||||
|
||||
_File = "\z\addons\dayz_code\actions\" + _actionFile + ".sqf";
|
||||
|
||||
_part_out = _scurrency;
|
||||
_part_in = _name;
|
||||
_out = _sell;
|
||||
// Total in stock
|
||||
_qty = _x select 2;
|
||||
|
||||
// Buy Data from array
|
||||
_buy = _x select 3;
|
||||
_bqty = _buy select 0;
|
||||
_bname = _buy select 1;
|
||||
_btype = _buy select 2;
|
||||
|
||||
// Sell data from array
|
||||
_sell = _x select 4;
|
||||
_sqty = _sell select 0;
|
||||
_sname = _sell select 1;
|
||||
_stype = _sell select 2;
|
||||
switch(true)do{
|
||||
case (_stype == 1): {
|
||||
_stype = "CfgMagazines";
|
||||
};
|
||||
case (_stype == 2): {
|
||||
_stype = "CfgVehicles";
|
||||
};
|
||||
case (_stype == 3): {
|
||||
_stype = "CfgWeapons";
|
||||
};
|
||||
};
|
||||
// Display Name of sell item
|
||||
_textCurrency = getText(configFile >> _stype >> _sname >> "displayName");
|
||||
|
||||
// Menu sort order
|
||||
_order = _x select 5;
|
||||
|
||||
// Trader Menu ID
|
||||
_tid = _x select 6;
|
||||
|
||||
// Action file to use for trade
|
||||
_afile = _x select 7;
|
||||
_File = "\z\addons\dayz_code\actions\" + _afile + ".sqf";
|
||||
|
||||
// Allways 1 for now
|
||||
_out = _sqty;
|
||||
// qty consumed of bname
|
||||
_in = 1;
|
||||
|
||||
_textCurrency = getText(configFile >> _btype >> _part_in >> "displayName");
|
||||
|
||||
_Display = format["Sell %1 for %2 %3", _textPart, _sell, _textCurrency];
|
||||
|
||||
// trade_items.sqf | [part_out, part_in, qty_out, qty_in,"buy",_textPart,_textCurrency];
|
||||
_part = player addAction [_Display, _File,[_part_out,_part_in,_out,_in,"sell",_textPart,_textCurrency], _order, true, true, "",""];
|
||||
//diag_log format["DEBUG TRADER: %1", _part];
|
||||
// trade_items.sqf | [part_out, part_in, qty_out, qty_in,_textPart,_textCurrency];
|
||||
_Display = format["Sell %1 for %2 %3", _textPart, _sqty, _textCurrency];
|
||||
_part = player addAction [_Display, _File,[_sname,_name,_out,_in,"sell",_textPart,_textCurrency], _order, true, true, "",""];
|
||||
|
||||
diag_log format["DEBUG TRADER: %1", _part];
|
||||
s_player_parts set [count s_player_parts,_part];
|
||||
|
||||
} forEach dayzTraderMenuResult;
|
||||
|
||||
_cancel = player addAction ["Cancel", "\z\addons\dayz_code\actions\trade_cancel.sqf",["medical"], 10, true, false, "",""];
|
||||
_cancel = player addAction ["Cancel", "\z\addons\dayz_code\actions\trade_cancel.sqf",["medical"], 0, true, false, "",""];
|
||||
s_player_parts set [count s_player_parts,_cancel];
|
||||
|
||||
// Clear Data maybe consider cacheing results
|
||||
dayzTraderMenuResult = nil;
|
||||
s_player_parts_crtl = 1;
|
||||
s_player_parts_crtl = 1;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
private["_position","_tent","_location","_isOk","_backpack","_tentType","_trg","_key"];
|
||||
//check if can pitch here
|
||||
call gear_ui_init;
|
||||
_playerPos = getPosATL player;
|
||||
_item = _this;
|
||||
_hastentitem = _this in magazines player;
|
||||
_location = player modeltoworld [0,2.5,0];
|
||||
@@ -9,23 +10,28 @@ _building = nearestObject [(vehicle player), "HouseBase"];
|
||||
_isOk = [(vehicle player),_building] call fnc_isInsideBuilding;
|
||||
//_isOk = true;
|
||||
|
||||
diag_log ("Pitch Tent: " + str(_isok) );
|
||||
//diag_log ("Pitch Tent: " + str(_isok) );
|
||||
|
||||
_config = configFile >> "CfgMagazines" >> _item;
|
||||
_text = getText (_config >> "displayName");
|
||||
|
||||
if (!_hastentitem) exitWith {cutText [format[(localize "str_player_31"),_text,"pitch"] , "PLAIN DOWN"]};
|
||||
|
||||
|
||||
//allowed
|
||||
if (["forest",dayz_surfaceType] call fnc_inString) then { _isOk = false; diag_log ("surface forest"); };
|
||||
//if (["grass",dayz_surfaceType] call fnc_inString) then { _isOk = false; diag_log ("surface grass"); };
|
||||
|
||||
//blocked
|
||||
if (["concrete",dayz_surfaceType] call fnc_inString) then { _isOk = true; diag_log ("surface concrete"); };
|
||||
//if (["wood",dayz_surfaceType] call fnc_inString) then { _isOk = true; diag_log ("surface concrete"); };
|
||||
//Block Tents in pounds
|
||||
_objectsPond = nearestObjects [_playerPos, [], 10];
|
||||
{
|
||||
_isPond = ["pond",str(_x),false] call fnc_inString;
|
||||
if (_isPond) then {
|
||||
_pondPos = (_x worldToModel _playerPos) select 2;
|
||||
if (_pondPos < 0) then {
|
||||
_isOk = true;
|
||||
};
|
||||
};
|
||||
} forEach _objectsPond;
|
||||
|
||||
diag_log ("Pitch Tent Surface: " + str(_isok) );
|
||||
//diag_log ("Pitch Tent: " + str(_isok) );
|
||||
|
||||
if (!_isOk) then {
|
||||
//remove tentbag
|
||||
|
||||
@@ -75,5 +75,6 @@ if (_qty >= _qty_in) then {
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
};
|
||||
48
dayz_code/actions/trade_backpacks.sqf
Normal file
48
dayz_code/actions/trade_backpacks.sqf
Normal file
@@ -0,0 +1,48 @@
|
||||
private["_iarray","_part_out","_part_in","_qty_out","_qty_in","_qty"];
|
||||
// [part_out,part_in, qty_out, qty_in,];
|
||||
|
||||
_part_out = (_this select 3) select 0;
|
||||
_part_in = (_this select 3) select 1;
|
||||
_qty_out = (_this select 3) select 2;
|
||||
_qty_in = (_this select 3) select 3;
|
||||
_buy_o_sell = (_this select 3) select 4;
|
||||
_textPartIn = (_this select 3) select 5;
|
||||
_textPartOut = (_this select 3) select 6;
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
_qty = {_x == _part_in} count magazines player;
|
||||
} else {
|
||||
_qty = 0;
|
||||
_bag = unitBackpack player;
|
||||
_class = typeOf _bag;
|
||||
if(_class == _part_in) then {
|
||||
_qty = 1;
|
||||
};
|
||||
};
|
||||
|
||||
if (_qty >= _qty_in) then {
|
||||
|
||||
if(_buy_o_sell == "buy") then {
|
||||
for "_x" from 1 to _qty_in do {
|
||||
player removeMagazine _part_in;
|
||||
};
|
||||
removeBackpack player;
|
||||
player addBackpack _part_out;
|
||||
} else {
|
||||
// Sell
|
||||
for "_x" from 1 to _qty_out do {
|
||||
player addMagazine _part_out;
|
||||
};
|
||||
removeBackpack player;
|
||||
// player addBackpack _part_out;
|
||||
};
|
||||
|
||||
cutText [format[("Traded %1 %2 for %3 %4"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
|
||||
|
||||
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
};
|
||||
@@ -24,8 +24,6 @@ if (_qty >= _qty_in) then {
|
||||
// [player,"repair",0,false] call dayz_zombieSpeak;
|
||||
cutText [format[("Traded %1 %2 for %3 %4"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
|
||||
|
||||
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
|
||||
@@ -40,7 +40,6 @@ if (_qty >= _qty_in) then {
|
||||
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
|
||||
s_player_parts_crtl = -1;
|
||||
|
||||
|
||||
} else {
|
||||
_needed = _qty_in - _qty;
|
||||
cutText [format[("Need %1 More %2"),_needed,_textPartIn] , "PLAIN DOWN"];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
private["_vehicle"];
|
||||
_vehicle = _this select 3;
|
||||
|
||||
_vehicle setVehicleInit "this lock false";
|
||||
_vehicle setVehicleInit "this lockCargo false";
|
||||
_vehicle setVehicleInit "this lock false; this lockCargo false;";
|
||||
|
||||
processInitCommands;
|
||||
|
||||
3
dayz_code/actions/vault_pack.sqf
Normal file
3
dayz_code/actions/vault_pack.sqf
Normal file
@@ -0,0 +1,3 @@
|
||||
private["_obj","_bag","_pos"];
|
||||
_obj = _this select 3;
|
||||
_obj spawn player_packVault;
|
||||
70
dayz_code/actions/vault_pitch.sqf
Normal file
70
dayz_code/actions/vault_pitch.sqf
Normal file
@@ -0,0 +1,70 @@
|
||||
private["_position","_tent","_location","_isOk","_backpack","_tentType","_trg","_key"];
|
||||
//check if can pitch here
|
||||
call gear_ui_init;
|
||||
_playerPos = getPosATL player;
|
||||
_item = _this;
|
||||
_hastentitem = _this in magazines player;
|
||||
_location = player modeltoworld [0,2.5,0];
|
||||
_location set [2,0];
|
||||
_building = nearestObject [(vehicle player), "HouseBase"];
|
||||
_isOk = [(vehicle player),_building] call fnc_isInsideBuilding;
|
||||
//_isOk = true;
|
||||
|
||||
//diag_log ("Pitch Tent: " + str(_isok) );
|
||||
|
||||
_config = configFile >> "CfgMagazines" >> _item;
|
||||
_text = getText (_config >> "displayName");
|
||||
|
||||
if (!_hastentitem) exitWith {cutText [format[(localize "str_player_31"),_text,"pitch"] , "PLAIN DOWN"]};
|
||||
|
||||
//blocked
|
||||
if (["concrete",dayz_surfaceType] call fnc_inString) then { _isOk = true; diag_log ("surface concrete"); };
|
||||
//Block Tents in pounds
|
||||
_objectsPond = nearestObjects [_playerPos, [], 10];
|
||||
{
|
||||
_isPond = ["pond",str(_x),false] call fnc_inString;
|
||||
if (_isPond) then {
|
||||
_pondPos = (_x worldToModel _playerPos) select 2;
|
||||
if (_pondPos < 0) then {
|
||||
_isOk = true;
|
||||
};
|
||||
};
|
||||
} forEach _objectsPond;
|
||||
|
||||
//diag_log ("Pitch Tent: " + str(_isok) );
|
||||
|
||||
if (!_isOk) then {
|
||||
//remove tentbag
|
||||
player removeMagazine _item;
|
||||
_dir = round(direction player);
|
||||
|
||||
//wait a bit
|
||||
player playActionNow "Medic";
|
||||
sleep 1;
|
||||
[player,"tentunpack",0,false] call dayz_zombieSpeak;
|
||||
|
||||
_id = [player,50,true,(getPosATL player)] spawn player_alertZombies;
|
||||
|
||||
sleep 5;
|
||||
//place tent (local)
|
||||
_tent = createVehicle ["VaultStorage", _location, [], 0, "CAN_COLLIDE"];
|
||||
_tent setdir _dir;
|
||||
_tent setpos _location;
|
||||
player reveal _tent;
|
||||
_location = getPosATL _tent;
|
||||
|
||||
_tent setVariable ["characterID",dayz_characterID,true];
|
||||
|
||||
//player setVariable ["tentUpdate",["Land_A_tent",_dir,_location,[dayz_tentWeapons,dayz_tentMagazines,dayz_tentBackpacks]],true];
|
||||
|
||||
dayzPublishObj = [dayz_characterID,_tent,[_dir,_location],"VaultStorage"];
|
||||
publicVariable "dayzPublishObj";
|
||||
if (isServer) then {
|
||||
dayzPublishObj call server_publishObj;
|
||||
};
|
||||
|
||||
cutText ["You have setup your vault", "PLAIN DOWN"];
|
||||
} else {
|
||||
cutText ["You cannot place a Vault here. The area must be flat, and free of other objects", "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user