Jump to content

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


Gr8

Recommended Posts

Awesome, thanks Gr8Boi

 

The code I listed in my last post does that ("trying to add a medic animation and stop it so it doesn't take too long to trade") although its not very clean, it doesn't let you move and cancel until the 2 second timer is up and so from the middle of the trade till then end of that cycle you have to hold a direction in preparation for it, again, not sure why.

 

I can imagine some panicky moments for first time users of the server when buying high value items in that scenario lol  I think I might prefer the no animation option so I'll try that out but if you can get a clean, shorter animation to work that would be perfect :)

Link to comment
Share on other sites

It is working, Gr8Boi's version, the one in the OP download link currently works with a timer but no animation i believe, timer set to 1.5 seconds (correct me if im wrong).

 

The code i posted abovehas a shortened animation but is still buggy and i wouldn't recommend using it.

Link to comment
Share on other sites

Hey! It works like a charm but i found one issue!

 

I have Traders which sell Tanks or some Items for Gems.

 

in database i need to do  "trade_any_vehicle_old" and "trade_any_items_old"

 

now u cant buy or sell this items. Trader GUI closes instantly when u try to buy or sell.

 

i think thats because u dont include thoose files.

 

i try to add it manually into ur "trade" folder. i give feedback after next server restart :)

 

 

Edit:

 

I just addet the files (all with _old) behind ,from "dayz_code\actions" folder to the custom "trade" folder and it works.

just with normal trader animation but thats ok because i think its enought to buy one tank in normal speed xD

Link to comment
Share on other sites

  • 3 weeks later...

it seems to be working fine for me, i saw your post saying its not working i just went and tested working good

the folder "trade" is the same, just the "player_traderMenuHive.sqf" i got from the new version 1.0.5.1 and did the edit again

its working unless i missed something,,,

Link to comment
Share on other sites

it seems to be working fine for me, i saw your post saying its not working i just went and tested working good

the folder "trade" is the same, just the "player_traderMenuHive.sqf" i got from the new version 1.0.5.1 and did the edit again

its working unless i missed something,,,

 

Did you use the files from dayz_code or from the download link?

Link to comment
Share on other sites

 

to stop the medic animation, i just use this:

            player switchMove "";

            player playActionNow "stop";

 

medic animation is easy to cancel like that. But Putdown is short and the animation starts and stops and the same time. Its just just a trigger to put player in a position. To cancel the trade. You will need to do an if statement on player move. But the animation itself moves the player. I am having trouble on how i can do something that stops trade when player moves more than 2 meters.

Link to comment
Share on other sites

I plug in the below code for all the trade files in place of the entire medic animation loop stuff  -- it's a 1 second delay between trades that cancels if you move. Maybe this can help?

//### BEGIN MODIFIED CODE: fast trading
private["_newPosition","_finished","_oldPosition"];
_finished = false;
_oldPosition = position player;
sleep 1;
_newPosition = position player;
if (_oldPosition select 0 == _newPosition select 0 && _oldPosition select 1 == _newPosition select 1) then {
_finished = true;
};


if (!_finished) exitWith {
_abort = true;
cutText [(localize "str_epoch_player_106") , "PLAIN DOWN"];
};
//### END MODIFIED CODE: fast trading
Link to comment
Share on other sites

I just tested this in my trade_items.sqf -- seems to work how you were looking for.

 

You start the initial trade, then it just waits 2 seconds between trades.

 

If you move more than 2 meters from the original position, then it cancels it.

 

See //### lines where I modified code

... <<< TOP OF FILE ...

//### BEGIN MODIFIED CODE: fast trading
private["_oldPosition"];
_oldPosition = position player;
//### END MODIFIED CODE: fast trading

// 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"];

	[1,1] call dayz_HungerThirst;

	//### BEGIN MODIFIED CODE: fast trading
	//player playActionNow "Medic";
	
	//_dis=20;
	//_sfx = "repair";
	//[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
	//[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
	private["_newPosition","_finished"];
	_finished = false;
	sleep 2;
	if (player distance _oldPosition <= 2) then {
		_finished = true;
	};
	if (!_finished) exitWith { 
		r_autoTrade = false;
		cutText [(localize "str_epoch_player_106") , "PLAIN DOWN"];
	};
	//### END MODIFIED CODE: fast trading

... BOTTOM OF FILE >>> ...

Link to comment
Share on other sites

btw I was able to test it and it worked pretty great. I ended up just replacing the section of each trade file from the start of the medic animation to the _finished check:

 

  (reason the _positionOld is defined like that is so that it can just be blocked in with the rest of the code for easy updating of the files between epoch updates.)

    
    //### BEGIN MODIFIED CODE: fast trading
    private["_newPosition","_finished","_oldPosition"];
    if(isNil "_oldPosition") then { _oldPosition = position player;};
    _finished = false;
    sleep 2;
    if (player distance _oldPosition <= 2) then {
        _finished = true;
    };
    if (!_finished) exitWith {
        r_autoTrade = false;
        cutText [(localize "str_epoch_player_106") , "PLAIN DOWN"];
    };
    //### END MODIFIED CODE: fast trading

see a full example trade_items.sqf file here on my github:

 

https://github.com/mudzereli/DayZScripts/blob/master/overwrites/fast_trading/trade_items.sqf

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...