Jump to content

[TUTORIAL] Remove/Change Trading Animations (for faster trading)


Gr8

Recommended Posts

якщо ми видалимо анімації ремесло), зміни в  player_craftItem.sqf

 

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 9/21/2014 at 5:13 PM, hopsi66 said:

 

now i try copy the trade_items.sqf to trade_items_old.sqf but it doesn't work.

Trade start write the trade-letters but nothing change in inventory.

 

Here is my copy

private ["_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_textPartIn","_textPartOut","_bos","_needed","_started","_finished","_animState","_isMedic","_total_parts_out","_abort","_removed","_activatingPlayer","_traderID","_done"];
// [part_out,part_in, qty_out, qty_in,];
 
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_103") , "PLAIN DOWN"] };
DZE_ActionInProgress = true;
 
_activatingPlayer = player;
 
_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;
_traderID = (_this select 3) select 7;
 
_bos = 0;
if(_buy_o_sell == "sell") then {
        _bos = 1;
};
 
_abort = false;
 
// perform number of total trades
r_autoTrade = true;
while {r_autoTrade} do {
 
        _removed = 0;
        cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];
         
      r_interrupt = false;
        r_doLoop = true;
        _started = false;
        _finished = false;
       
 
        //////////////
       
            _position = getPos player; // gets the position [x,y,z]
        _posX = _position select 0; // 1th element -> x
        _posY = _position select 1; // 2nd element -> y
 
        _counter = 0.0; // animation duration checker
       
        while {r_doLoop} do {
                _positionCheck = getPos player;
                _newX = _positionCheck select 0; // 1th element -> x
                _newY = _positionCheck select 1; // 2nd element -> y
 
                _counter = _counter + 0.1; // same as the sleep timer: 0.1 sec
 
                if (_counter >  1.5) then { // amount of secs the animation takes estimated ? 2 secs?
                        r_doLoop = false;
                                                _counter = 0.0;
                        _finished = true;
                                               
                };
                if (_newX != _posX || _newY != _posY) then {
                                               
                        r_doLoop = false;
                };
                sleep 0.1;
        };
        r_doLoop = false;
 
        if (!_finished) exitWith {
                r_interrupt = false;
                if (vehicle player == player) then {
                        [objNull, player, rSwitchMove,""] call RE;
                        player playActionNow "stop";
                };
                cutText [(localize "str_epoch_player_106") , "PLAIN DOWN"];
        };
 
        if (_finished) then {
               
                _canAfford = false;
                if(_bos == 1) then {
                       
                        //sell
                        _qty = {_x == _part_in} count magazines player;
                        if (_qty >= _qty_in) then {
                                _part_inClass =  configFile >> "CfgMagazines" >> _part_in;
                                _removed = _removed + ([player,_part_inClass,_qty_in] call BIS_fnc_invRemove);
                                if (_removed == _qty_in) then {
                                        _canAfford = [[[_part_out,_qty_out]],1] call epoch_returnChange;
                                };
                        };
 
                } else {
                       
                        //buy
                        _trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
                        _total_currency = call epoch_totalCurrency;
                        _return_change = _total_currency - _trade_total;
                        if (_return_change >= 0) then {
                                _canAfford = true;
                        };
                };
 
                diag_log format["DEBUG TRADER DONE?: %1", _canAfford];
               
                if (_canAfford) then {
                       
                        // Continue with trade.
                        if (isNil "_part_in") then { _part_in = "Unknown Item" };
                        if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
                        if(_bos == 1) then {
                                // Selling
                                PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
                        } else {
                                // Buying
                                PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
                        };
                        publicVariableServer  "PVDZE_obj_Trade";
 
                        if(_bos == 0) then {
                                // only wait for result when buying
                                waitUntil {!isNil "dayzTradeResult"};
                                if(dayzTradeResult == "PASS") then {
                                        _done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
                                        if (_done) then {
                                                for "_x" from 1 to _qty_out do {
                                                        player addMagazine _part_out;
                                                };
                                                cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
                                        };
                                } else {
                                        _abort = true;
                                        cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
                                };
                        } else {
                                cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
                        };
                        dayzTradeResult = nil;
                       
                } else {
                        _qty = {_x == _part_in} count magazines player;
                        _needed =  _qty_in - _qty;
                        cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
                        _abort = true;
                };
        };
        if(_abort) exitWith {r_autoTrade = false};
       
        sleep 1;
};
 
DZE_ActionInProgress = false;

Kann noone help me? Please !!!

Link to comment
Share on other sites

  On 10/4/2014 at 6:35 PM, hopsi66 said:

Kann noone help me? Please !!!

 

You dont copy your trade_items.sqf to trade_items_old.sqf, you simply copy the original trade_items_old.sqf and paste it in the mission file with all the other trade files

Link to comment
Share on other sites

  • 2 weeks later...

Maybe good to know for people who use Config Traders.

Don't use the Player_TradingMenuHive, but get the Player_TradingMenuConfig.

 

Maybe most of you know this already, but i have bin struggeling for hours to get my traders to show up newly added items and prices until i found this in the original compiles.sqf:

if (DZE_ConfigTrader) then {
call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_traderMenuConfig.sqf";
}else{
call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_traderMenuHive.sqf";
Link to comment
Share on other sites

  • 3 weeks later...
  On 11/7/2014 at 1:39 PM, RussianCaliber said:

I'm really confused right now.. 

To sell the Trade_Items_Old which file to i need to copy, where or what i need to add?

If any could explain me that would be much appreciated!

 

Search for Trade_Items_Old File in your dayz_code, copy the exact file in your trade folder in your mission pbo

Link to comment
Share on other sites

  • 2 weeks later...
  On 11/17/2014 at 4:28 PM, RussianCaliber said:

Okay thanks it works fine but now another problem occurs 

as example selling an lapua to hero everything works great sells it without animation but won't receive money from trader. 

 

Then There a problem with your trader Files, make sure they are what i provided you with

Link to comment
Share on other sites

This is how i have done the trade_items.sqf,

private ["_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_textPartIn","_textPartOut","_bos","_needed","_started","_finished","_animState","_isMedic","_total_parts_out","_abort","_removed","_activatingPlayer","_traderID","_done"];
// [part_out,part_in, qty_out, qty_in,];

if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_103") , "PLAIN DOWN"] };
DZE_ActionInProgress = true;

_activatingPlayer = player;

_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;
_traderID = (_this select 3) select 7;

_bos = 0;
if(_buy_o_sell == "sell") then {
	_bos = 1;
};

_abort = false;

// perform number of total trades
r_autoTrade = true;
while {r_autoTrade} do {

	_removed = 0;

	// check if current magazine count is greater than 20

	if ((count (magazines player)) > 20) exitWith { cutText [(localize "STR_DAYZ_CODE_2"), "PLAIN DOWN"]; r_autoTrade = false};
	
	_canAfford = false;
	if(_bos == 1) then {
		
		//sell
		_qty = {_x == _part_in} count magazines player;
		if (_qty >= _qty_in) then {
			_canAfford = true;
		};

	} else {
		
		//buy
		_trade_total = [[_part_in,_qty_in]] call epoch_itemCost;
		_total_currency = call epoch_totalCurrency;
		_return_change = _total_currency - _trade_total; 
		if (_return_change >= 0) then {
			_canAfford = true;
		};
	};
	
	if(!_canAfford) exitWith {
		_qty = {_x == _part_in} count magazines player;
		_needed =  _qty_in - _qty;
		cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
		r_autoTrade = false
	};
	
	cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];

	
	//_dis=20;
	//_sfx = "repair";
	//[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
	//[player,_dis,true,(getPosATL player)] spawn player_alertZombies;

	r_interrupt = false;
	r_doLoop = true;
	_finished = false;
	
	while {r_doLoop} do {
		sleep 1.2;
		r_doLoop = false;
		_finished = true;
	};

	if (r_interrupt) exitWith {
		r_interrupt = false;
		cutText [(localize "str_epoch_player_106") , "PLAIN DOWN"];
	};

	if (_finished) then {

		//diag_log format["DEBUG TRADER DONE?: %1", _canAfford];
		
		// Continue with trade.
		if (isNil "_part_in") then { _part_in = "Unknown Item" };
		if (isNil "inTraderCity") then { inTraderCity = "Unknown Trader City" };
		if(_bos == 1) then {
			// Selling
			PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_in,inTraderCity,_part_out,_qty_out];
		} else {
			// Buying
			PVDZE_obj_Trade = [_activatingPlayer,_traderID,_bos,_part_out,inTraderCity,_part_in,_qty_in];
		};
		publicVariableServer  "PVDZE_obj_Trade";

		if(_bos == 0) then {
			// only wait for result when buying
			waitUntil {!isNil "dayzTradeResult"};
			if(dayzTradeResult == "PASS") then {
				_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
				if (_done) then {
					for "_x" from 1 to _qty_out do {
						player addMagazine _part_out;
					};
					cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
				};
			} else {
				_abort = true;
				cutText [format[(localize "str_epoch_player_183"),_textPartOut] , "PLAIN DOWN"];
			};
		} else {
			_part_inClass =  configFile >> "CfgMagazines" >> _part_in;
			_removed = _removed + ([player,_part_inClass,_qty_in] call BIS_fnc_invRemove);
			if (_removed == _qty_in) then {
				[[[_part_out,_qty_out]],1] call epoch_returnChange;
			};
			cutText [format[(localize "str_epoch_player_186"),_qty_in,_textPartIn,_qty_out,_textPartOut], "PLAIN DOWN"];
		};
		dayzTradeResult = nil;
	};
	if(_abort) exitWith {r_autoTrade = false};
	
	sleep 1;
};

DZE_ActionInProgress = false;

There is no animation, it still does the loop in 1.2 seconds, meanwhile if you move the trade cancels so works fine as i wanted :D

 

To clarifiy the changed lines:

	if(!_canAfford) exitWith {
		_qty = {_x == _part_in} count magazines player;
		_needed =  _qty_in - _qty;
		cutText [format[(localize "str_epoch_player_184"),_needed,_textPartIn] , "PLAIN DOWN"];
		r_autoTrade = false
	};
	
	cutText [(localize "str_epoch_player_105"), "PLAIN DOWN"];

	r_interrupt = false;
	r_doLoop = true;
	_finished = false;
	
	while {r_doLoop} do {
		sleep 1.2;
		r_doLoop = false;
		_finished = true;
	};

	if (r_interrupt) exitWith {
		r_interrupt = false;
		cutText [(localize "str_epoch_player_106") , "PLAIN DOWN"];
	};

	if (_finished) then {
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
  On 1/9/2015 at 2:29 AM, se7en said:

not working for me.

Did everything thats in install notes, but not for ...Hive, changed to ...Config - because im using ZSC_traders

 

No errors in rpt's...

 

Any info about that ? :>

 

This Script is not compatible with 3.0 SC

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...