Jump to content

Add items to the traders?


Guest

Recommended Posts

So i think i have tried every posible way and the scripts are loading without any error. But the trader don't accpetd any item / vehicle i would trade, which is not epoch nativ. Can any body explain how this is going and how the scripts must look like? Answer like "Server side make npc trade, thats whats missing" don't bring any results. I started it many times server sided any nothing happend. I tried every script i found on the net, which should work, none work.

At the moment i think it is not possible without changing the default mod

Link to comment
Share on other sites

My Traders some what works u can sell them items but they wont give you money for them and they wont buy the vehicles even thought u can sell them the vehicles stays there 

 

description.ext 

wreckRemovalMaxTime = 360;

#include "cfg\config.hpp"

class CfgRemoteExecCommands {};

class RscTitles
{
	#include "scripts\statusBar.hpp"
};

class CfgEmod {
    override = 1;
    file = "precompile.sqf";
};

precompile.sqf

if (isServer) then {
} else {
	EPOCH_npcTraderAdd = compileFinal preprocessFileLineNumbers "trader\EPOCH_npcTraderAdd.sqf";
	EPOCH_startNpcTrade = compileFinal preprocessFileLineNumbers "trader\EPOCH_startNpcTrade.sqf";
};

config.hpp

#include "CfgPricing.hpp"

So what am i missing?

Link to comment
Share on other sites

So i grabbed the EPOCH_server_makeNPCTrade.sqf from a3_epoch_server\compile\epoch_trading i Change inside the File ConfigFile to missionConfigFile

 

Change the name to EPOCH_makeNPCTrade.sqf i added it to be called from my precompile.sqf with  EPOCH_npcTraderAdd EPOCH_startNpcTrade

 

Booted my server up went to the trader tried to sell something BAM kicked for publicvarible 0# it flagged the whole thing O.o

 

publicvarible.log

17.01.2015 16:37:10: Ree (xxxxxxxxxxxxxxxxx) xxxxxxxxxxxxxxxxxxxxx- Value Restriction #0 "EPOCH_MAKENPCTRADE" = this select 3;
_token = _this select 4;
_returnIn = [];
_returnOut = [];
if(isNull _trader) exitWith {};
if !([_plyr, _token] call EPOCH_server_getPToken) exitWith {};
if(_plyr distance _trader > 20) exitWith {};
_slot = _trader getVariable["AI_SLOT", -1];
if(_slot != -1) then {
_tradeTotal = 0;
_tradeQtyTotal = 0;
_cIndex = EPOCH_customVars find "Crypto";
_current_crypto = (_plyr getVariable["VARS", EPOCH_defaultVars_SEPXVar]) select _cIndex;
diag_log format["_current_crypto: %1 _cIndex:%2", _current_crypto, _cIndex];
_aiItems = _trader getVariable["AI_ITEMS", [
[],
[]
]];
_itemClasses = _aiItems select 0;
_itemQtys = _aiItems select 1; {
_item = _x;
_itemQty = 1;
if(isClass(missionConfigFile >> "CfgPricing" >> _item)) then {
_itemWorth = getNumber(missionConfigFile >> "CfgPricing" >> _item >> "price");
_makeTradeIn = false;
if(_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle") then {
_vehicles = _trader nearEntities[[_item], 30];
if !(_vehicles isEqualTo[]) then {
_vehicle = _vehicles select 0;
if(!isNull _vehicle) then {
_plyrNetID = owner _plyr;
if(_plyrNetID == (owner _vehicle)) then {
_vehSlot = _vehicle getVariable["VEHICLE_SLOT", "ABORT"];
if(_vehSlot != "ABORT") then {
removeFromRemainsCollector[_vehicle];
deleteVehicle _vehicle;
_vehHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _vehSlot];
_VAL = [];
["Vehicle", _vehHiveKey, _VAL] call EPOCH_server_hiveSET;
EPOCH_VehicleSlots pushBack _vehSlot;
EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
publicVariable "EPOCH_VehicleSlotCount";
_makeTradeIn = true;
};
};
};
};
} else {
_makeTradeIn = true;
};
if(_makeTradeIn) then {
_returnIn pushBack _item;
_qtyIndex = _itemClasses find _item;
if(_qtyIndex == -1) then {
_itemClasses pushBack _item;
_itemQtys pushBack _itemQty;
_tradeTotal = _tradeTotal + _itemWorth;
_current_crypto = _current_crypto + _itemWorth;
_tradeQtyTotal = _tradeQtyTotal + _itemQty;
} else {
_currQty = _itemQtys select _qtyIndex;
_itemQtys set[_qtyIndex, (_currQty + _itemQty)];
_tradeTotal = _tradeTotal + _itemWorth;
_current_crypto = _current_crypto + _itemWorth;
_tradeQtyTotal = _tradeQtyTotal + _itemQty;
};
diag_log format["_itemClasses: %1 _itemQtys:%2", _itemClasses, _itemQtys];
};
};
}
forEach _itemsIn; {
_item = _x;
_itemQty = 1;
diag_log format["_item: %1", _item];
if(isClass(missionConfigFile >> "CfgPricing" >> _item)) then {
_itemWorth = getNumber(missionConfigFile >> "CfgPricing" >> _item >> "price");
_itemTax = getNumber(missionConfigFile >> "CfgPricing" >> _item >> "tax");
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
_itemWorth = ceil(_itemWorth + _tax);
diag_log format["_itemWorth: %1", _itemWorth];
_qtyIndex = _itemClasses find _item;
if(_qtyIndex != -1) then {
_currQty = _itemQtys select _qtyIndex;
diag_log format["_currQty: %1 >= %2", _currQty, _itemQty];
if(_currQty >= _itemQty) then {
if(_current_crypto >= _itemWorth) then {
if(_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle") then {
if !(EPOCH_VehicleSlots isEqualTo[]) then {
_position = getPosATL _plyr;
_helipad = nearestObjects[_position, ["Land_HelipadEmpty_F", "Land_HelipadCircle_F"], 30];
if !(_helipad isEqualTo[]) then {
_position = getPosATL(_helipad select 0);
} else {
_tmpposition = [];
if(_item isKindOf "Ship") then {
_tmpposition = [_position, 20, 120, 10, 0, 1000, 1] call BIS_fnc_findSafePos;
_tmpposition = [_tmpposition, 0, 60, 10, 2, 1000, 0] call BIS_fnc_findSafePos;
} else {
_tmpposition = [_position, 20, 120, 20, 0, 2000, 0] call BIS_fnc_findSafePos;
};
if((count _tmpposition) == 2) then {
_position = _tmpposition;
};
};
_slot = EPOCH_VehicleSlots select 0;
EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
publicVariable "EPOCH_VehicleSlotCount";
_vehObj = createVehicle[_item, _position, [], 0, "NONE"];
_vehObj call EPOCH_server_setVToken;
addToRemainsCollector[_vehObj];
_vehObj disableTIEquipment true;
clearWeaponCargoGlobal _vehObj;
clearMagazineCargoGlobal _vehObj;
clearBackpackCargoGlobal _vehObj;
clearItemCargoGlobal _vehObj;
_vehObj lock true;
_lockOwner = getPlayerUID _plyr;
_plyrGroup = _plyr getVariable["GROUP", ""];
if(_plyrGroup != "") then {
_lockOwner = _plyrGroup;
};
_vehObj setVariable["LOCK_OWNER", _lockOwner];
_vehObj setVariable["LOCKED_TILL", serverTime + 1800];
_config = missionConfigFile >> "CfgVehicles" >> _item >> "availableColors";
if(isArray(_config)) then {
_textureSelectionIndex = missionConfigFile >> "CfgVehicles" >> _item >> "textureSelectionIndex";
_selections =
if(isArray(_textureSelectionIndex)) then {
getArray(_textureSelectionIndex)
} else {
[0]
};
_colors = getArray(_config);
_textures = _colors select 0;
_color = floor(random(count _textures));
_count = (count _colors) - 1; {
if(_count >= _forEachIndex) then {
_textures = _colors select _forEachIndex;
};
_vehObj setObjectTextureGlobal[_x, (_textures select _color)];
}
forEach _selections;
_vehObj setVariable["VEHICLE_TEXTURE", _color];
};
_vehObj setVariable["VEHICLE_SLOT", _slot, true];
_vehObj call EPOCH_server_save_vehicle;
_vehObj call EPOCH_server_vehicleInit;
_returnOut pushBack _item;
_itemQtys set[_qtyIndex, (_currQty - _itemQty)];
_tradeTotal = _tradeTotal - _itemWorth;
_current_crypto = _current_crypto - _itemWorth;
_tradeQtyTotal = _tradeQtyTotal + _itemQty;
};
} else {
_returnOut pushBack _item;
_itemQtys set[_qtyIndex, (_currQty - _itemQty)];
_tradeTotal = _tradeTotal - _itemWorth;
_current_crypto = _current_crypto - _itemWorth;
_tradeQtyTotal = _tradeQtyTotal + _itemQty;
};
diag_log format["_itemClasses: %1 _itemQtys:%2", _itemClasses, _itemQtys];
};
};
};
};
}
forEach _itemsOut;
if(_itemsIn isEqualTo _returnIn || _itemsOut isEqualTo _returnOut) then {
_trader setVariable["AI_ITEMS", [_itemClasses, _itemQtys], true];
_objHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
["AI_ITEMS", _objHiveKey, [_itemClasses, _itemQtys]] call EPOCH_server_hiveSET;
diag_log format["UPDATED DB FOR TRADER: %1 SLOT: %2 DATA: %3", _trader, _slot, [_itemClasses, _itemQtys]];
diag_log format["ADMIN: %1 TRADETOTAL:%2", _this, _tradeTotal];
[
["effectCrypto", _tradeTotal], owner _plyr
] call EPOCH_sendPublicVariableClient;
EPOCH_TRADE_COMPLETE = [_returnIn, _returnOut];
(owner _plyr) publicVariableClient "EPOCH_TRADE_COMPLETE";
};
};}
 

 

 

now i looked at my filters and EPOCH_MAKENPCTRADE is already marked as ok to go.

 

 

 

So i checked around for server i know that are selling/buying custom items from NPCs and noticed some servers are calling precompile.sqf from the a3_epoch_server pbo in a custom folder im wondering how they are doing that when changing anything in that pbo breaks the game

if (isServer) then {
    call compile preprocessFileLineNumbers '\x\addons\a3_epoch_server\NAME\precompile.sqf';
} else {
    EPOCH_npcTraderAdd = compileFinal preprocessFileLineNumbers "trader\EPOCH_npcTraderAdd.sqf";
    EPOCH_startNpcTrade = compileFinal preprocessFileLineNumbers "trader\EPOCH_startNpcTrade.sqf";
};
Link to comment
Share on other sites

I've been looking into this for about 2 days for the folks at TeamPlayerGaming, and my analysis concludes that the client-side functions "EPOCH_npcTraderAdd" and "EPOCH_startNpcTrade" cannot be overridden solely via mission scripts, as the client compilation sequence cannot be altered without running Emod or equivalent on every client that joins the server.

 

Long story short, proper selling and buying of custom mod weapons is currently impossible without building an additional addon that would be needed by all players attempting to join.

 

Epoch devs themselves could extremely easily make all the trading scripts look into both "configFile >> CfgPricing" and "missionConfigFile >> CfgPricing", which would completely solve that issue by only requiring to add new prices in the mission's description.ext, but right now it is not the case.

Link to comment
Share on other sites

  • 4 weeks later...

I've been trying to make this work, but i have come to the conclusion this is not possible.

 

The problem is that you need to replace the EPOCH_server_makeNPCTrade function from the a3_epoch_server.pbo

 

Unfortunately you can't do that, because this one is compiled using the compileFinal function (in the file server_compiles.sqf), thus making the function final and not overwriteable :(

 

I've come up to the point that you can select the extra items for sale and see the amount of krypto you would get (all client side), but then when you make the trade, you wont get any krypto and the item is gone. This is because the function EPOCH_server_makeNPCTrade is loading up the default pricing file and the extra items are not in this file, thus breaking the trade :(. Item gone, no krypto.

 

The only thing we can do, is wait and hope the Epoch team is going to build in a way for us to add extra items to traders and change the pricing. Or they have to release the server files where this function:EPOCH_server_makeTrade is compile using the compile function instead of the compileFinal function. Like this:

 

EPOCH_server_makeTrade=compile preprocessFileLineNumbers "\x\addons\a3_epoch_server\compile\epoch_trading\EPOCH_server_makeTrade.sqf";

 

We cant do it ourselves, because that would break the server files and server will restart with the message that you have incorrect server files.

Link to comment
Share on other sites

  • 1 month later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
×
×
  • Create New...