[Tutorial] Custom trader - quick and dirty how to gem trader

FallingSheep

OpenDayZ Lord!
ok this is straight from here ( http://epochmod.com/forum/index.php?/topic/970-custom-trader-cities/ ) just cleaned it up for you :p

This is how i do it so its not the best way :) but it works!

1. create anew file and call it customtrader.sqf and paste this into it
Code:
_unit_13001 = objNull;if(true)then{
  _this = createAgent ["RU_Damsel5",[2550.658,8326.5928,2.3534577],[],0,"CAN_COLLIDE"];
  _unit_13001 = _this;
  _this setDir 114.59087;
  _this setVehicleInit "this allowDammage false; this disableAI 'FSM'; this disableAI 'MOVE'; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this setBehaviour 'CARELESS'; this forceSpeed 0;  ";
  _this setUnitAbility 0.60000002;
_this allowDammage false; _this disableAI 'FSM'; _this disableAI 'MOVE'; _this disableAI 'AUTOTARGET'; _this disableAI 'TARGET'; _this setBehaviour 'CARELESS'; _this forceSpeed 0;_this enableSimulation false;};

now change RU_Damsel5 to the skin you want your trader to have (dont use one already in use!)
change
2550.658,8326.5928,2.3534577 to the loaction you want the trader to spawn.

save the file in your root MPMission folder (where your init.sqf is)
2. open server_trader.sqf and addthis to the bottom of it


// Gem Trader
menu_RU_Damsel5 =[[["Gems",900]],[],"neutral"];
(code tags ruined the color so i just put it as normal text)

make sure you include menu_ also change RU_Damsel5 to the skin you used in step 1

900 is the unique trader id

now at the top of server_traders add into the array add this to the start of the traders array
Code:
"RU_Damsel5",
so it looks like this
Code:
serverTraders =["RU_Damsel5","SOMESKIN",more code];
save

3. now you need to import somethings into your DB so use the below SQL code to import your new trader
Code:
REPLACE INTO `server_traders`(`id`,`classname`,`instance`,`status`,`static`,`desc`) VALUES (900,'RU_Damsel5',11,'friendly', NULL,'Gem Trader');
900 must match the trader id from step 2

Gem Trader is the traders description, you can put what ever you want here
11 is your instance id ( 11 is epoch chernarus id )

now we need to give the trader something to sell!

4. again you need to import this into your DB

Code:
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (9999,'["ItemRuby",1]',1000,'[9,"ItemGoldBar",1]','[5,"ItemGoldBar",1]',0,900,'trade_items');
9999 is a uniquie id make sure its not already used

ItemRuby is the name of the item you want the trader to buy/sell
9,"ItemGoldBar" is the buy price is this case it is 9 goldbars
5,"ItemGoldBar" is the sell price in this case it is 5 gold bars
900 must match the trader id from step 2

here is theSQL to import all the GEMS for the example above
Code:
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (9999,'["ItemRuby",1]',250,'[9,"ItemGoldBar10oz",1]','[5,"ItemGoldBar10oz",1]',0,900,'trade_items');
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (10000,'["ItemTopaz",1]',250,'[9,"ItemGoldBar10oz",1]','[5,"ItemGoldBar10oz",1]',0,900,'trade_items');
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (10001,'["ItemObsidian",1]',250,'[9,"ItemGoldBar10oz",1]','[5,"ItemGoldBar10oz",1]',0,900,'trade_items');
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (10002,'["ItemSapphire",1]',250,'[9,"ItemGoldBar10oz",1]','[5,"ItemGoldBar10oz",1]',0,900,'trade_items');
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (10003,'["ItemAmethyst",1]',250,'[9,"ItemGoldBar10oz",1]','[5,"ItemGoldBar10oz",1]',0,900,'trade_items');
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (10004,'["ItemEmerald",1]',250,'[9,"ItemGoldBar10oz",1]','[5,"ItemGoldBar10oz",1]',0,900,'trade_items');
REPLACE INTO `traders_data`(`id`,`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (10005,'["ItemCitrine",1]',250,'[9,"ItemGoldBar10oz",1]','[5,"ItemGoldBar10oz",1]',0,900,'trade_items');
4. last but not least we need to call our customtrader.sqf to spawn the trader
open your init.sqf and at the bottom add this line
Code:
[] execVM "customtrader.sqf";
thats it your trader should be good to go!
 
Back
Top