Jump to content

Custom Gem Trader


Recommended Posts

Hey guys, been lurking for quite a long time around here and wanted to give something back. I have seen a lot of tuts and requests for certain things relating to the gemstones but haven't seen this as a tutorial. Lots of great of info on these forums but it seems spread out across several different posts. If someone has already done this and I simply missed it or searched the wrong terms, could a mod please delete this?

 

I wanted to make an easy to use solution for allowing players to sell the gems that they find. I have made a custom gem trader that will buy any gems your players find but that didn't require server admins to mess with the dayz/epoch code itself. I chose this route because I figured if a new server admin messes something up the MPMission it wouldn't be as bad to fix than a mistake in the actual epoch/server files. It also utilizes an outside sql file that you can simply comment out if you want to turn it off. All changes made will be in your mpmissions folder and in the database. Since I made this for a Taviana server I play on everything will be Tavi related but you can change it for any server.

 

First of all, thank you to BetterDeadThanZed. Your post on custom traders last year made this idea possible and most of the below information is directly from that post.

 

1. Open MPMissions\Dayz_Epoch_13.Tavi\server_traders.sqf and find the line 

 

serverTraders = [

 

Place the following code into a new line right under the serverTraders = [

"RU_Villager1",

Below that find the section

 
/*---------------------------------------------------------------------------
NEUTRAL VENDORS
---------------------------------------------------------------------------*/
 
and add the following code right below

//Gems
menu_RU_Villager1 = [
[["Gemstones",700]],
[],
"neutral"
];

It is important to make sure that if you change the RU_Villager1 to something else, (or even if you don't), that you go through the list in server_traders.sqf and ensure that you are not re-using a class name that is already in use. The game will take whatever ai class names that are in the top list and make them traders with the bottom code. After this tutorial you can place an RU_Villager1 anywhere on your map and when a player talks to them, the player will have access to a Gem Trader.

 

Save your server_traders.sqf file and close it.

 

 

2. Open your server's database and navigate to the server_traders table. Create a new entry and insert the following into the appropriate fields:

, RU_Villager1, 13, neutral, ,Tavi Mining Company

Notice the first comma. The empty space to the left of that comma is for the ID column and the second empty space is for the static column. For this tutorial leave both columns blank. You don't need anything in Static and if you leave the ID column empty it will auto-fill that column with whatever is the next ID number available, (thanks to ZeroKOOL for the great tip!). The 13 shown above is for Taviana. If you decide to utilize this code for another island, make sure you change that number to the one relative to your island, (11=Cherno, 16=Pantera, etc). Save this entry and close the server_traders table.

 

 

3. Open the traders_data table in your database. You will need to sort this table in ascending order so you can find the highest number being used in the ID column. I am using 7589-7595 as my ID numbers here. If any of those are already being used you can use any other numbers you like. You will need to create seven new entries and insert the following code into the appropriate fields.

7589,["ItemRuby",1], 250,[9,"ItemGoldBar10oz",1],[5,"ItemGoldBar10oz",1],0,700,trade_items
7590,["ItemTopaz",1], 250,[9,"ItemGoldBar10oz",1],[5,"ItemGoldBar10oz",1],0,700 ,trade_items
7591,["ItemObsidian",1], 250,[9,"ItemGoldBar10oz",1],[5,"ItemGoldBar10oz",1],0,700,trade_items
7592,["ItemSapphire",1], 250,[9,"ItemGoldBar10oz",1],[5,"ItemGoldBar10oz",1],0,700,trade_items
7593,["ItemAmethyst",1], 250,[9,"ItemGoldBar10oz",1],[5,"ItemGoldBar10oz",1],0,700,trade_items
7594,["ItemEmerald",1], 250,[9,"ItemGoldBar10oz",1],[5,"ItemGoldBar10oz",1],0,700,trade_items
7595,["ItemCitrine",1], 250,[9,"ItemGoldBar10oz",1],[5,"ItemGoldBar10oz",1],0,700,trade_items

If you are comfortable with SQL you can alternatively use the following code:

REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7589, '["ItemRuby",1]', 250, '[9,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar10oz",1]', 0, 700, 'trade_items');
REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7590, '["ItemTopaz",1]', 250, '[9,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar10oz",1]', 0, 700, 'trade_items');
REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7591, '["ItemObsidian",1]', 250, '[9,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar10oz",1]', 0, 700, 'trade_items');
REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7592, '["ItemSapphire",1]', 250, '[9,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar10oz",1]', 0, 700, 'trade_items');
REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7593, '["ItemAmethyst",1]', 250, '[9,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar10oz",1]', 0, 700, 'trade_items');
REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7594, '["ItemEmerald",1]', 250, '[9,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar10oz",1]', 0, 700, 'trade_items');
REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7595, '["ItemCitrine",1]', 250, '[9,"ItemGoldBar10oz",1]', '[5,"ItemGoldBar10oz",1]', 0, 700, 'trade_items');
 
The above code will allow players to buy any gem for 9 10Oz Gold Bars and to sell any gem for 6 100z Gold Bars. You can change these values to be anything you want. 
 
 
4.  Navigate to your MPMissions\DayZ_Epoch_13.Tavi folder and open mission.sqm. Find the lines
 
class Markers
{
 
Right after that you should see
 
items=number;
 
Whatever number equals above, simply add 1 to that number. For me it went from
 
items=28; 
 
to
 
items=29;
 
Keep scrolling down through the Markers section until you get to the last marker.
Insert this just before the last }; of the Markers section:
class Item28
{
position[]={6054.33,5,7704.25};
name="TaviMiningCompany";
text="Tavi Mining Company";
type="mil_dot";
colorName="ColorBlack";
};
 
class Item# should be one less than the total number you changed above.
 
 
5. Navigate to your MPMissions\DayZ_Epoch_13.Tavi folder and open init.sqf. Find the line
 
if (isServer) then {
 
Just above the }; that closes that section insert the following:
 
execVM "custom\Gem_Trader.sqf";
 
For me the section ended up looking like this:
 
if (isServer) then {
call compile preprocessFileLineNumbers "\z\addons\dayz_server\missions\DayZ_Epoch_13.Tavi\dynamic_vehicle.sqf"; //Compile vehicle configs
 
// Add trader citys
_nil = [] execVM "\z\addons\dayz_server\missions\DayZ_Epoch_13.Tavi\mission.sqf";
_serverMonitor =  [] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
execVM "custom\Gem_Trader.sqf";
};
 
6. Navigate to your MPMissions\Dayz_Epoch_13.Tavi folder and create a folder named custom if you do not already have one. Inside that folder create a new file called Gem_Trader.sqf
 
Insert the following code into that file and save. This file will hold all of the items and coordinates of the Mining Operation. If you choose to place it somewhere else, (or on a different map), change the coords in this file.
 
 
_unit_1337 = objNull;
if (true) then
{
  _this = createAgent ["RU_Villager1", [6054.33,7704.25,0.1], [], 0, "CAN_COLLIDE"];
  _unit_1337 = _this;
  _this setDir 29;
  _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;
};
 
_vehicle_0 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_bouda_plech", [6056.0205, 7702.5825, 6.1035156e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_0 = _this;
  _this setDir 90.66597;
  _this setPos [6056.0205, 7702.5825, 6.1035156e-005];
};
 
_vehicle_9 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_stanek_3B", [6054.7871, 7705.0747], [], 0, "CAN_COLLIDE"];
  _vehicle_9 = _this;
  _this setDir 118.30024;
  _this setPos [6054.7871, 7705.0747];
};
 
_vehicle_16 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_Misc_WoodPile", [6061.7505, 7702.2954, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_16 = _this;
  _this setPos [6061.7505, 7702.2954, -3.0517578e-005];
};
 
_vehicle_29 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_Barels", [6055.0283, 7700.7544], [], 0, "CAN_COLLIDE"];
  _vehicle_29 = _this;
  _this setDir 6.0406318;
  _this setPos [6055.0283, 7700.7544];
};
 
_vehicle_30 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_barrel_water", [6056.3247, 7703.3833, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_30 = _this;
  _this setPos [6056.3247, 7703.3833, -3.0517578e-005];
};
 
_vehicle_31 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_P_pipe_small", [6059.0938, 7700.5908, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_31 = _this;
  _this setDir 3.4072633;
  _this setPos [6059.0938, 7700.5908, 3.0517578e-005];
};
 
_vehicle_32 = objNull;
if (true) then
{
  _this = createVehicle ["Land_Fire_barrel", [6062.4844, 7704.5562], [], 0, "CAN_COLLIDE"];
  _vehicle_32 = _this;
  _this setDir 203.54425;
  _this setPos [6062.4844, 7704.5562];
};
 
 
 
 
 
 
 
 
After you restart your server you will see a new marker on the map. It will be on the rim of the volcano of the West island in Taviana.
 
346u9w7.jpg
 
Here are a couple pics of the Tavi Mining Company.
 
 
11k9ks6.jpg
 
 
2v7yonc.jpg

 

 

If you have any questions, please ask. This is my first attempt at a tutorial, so if you guys have any pointers or corrections to what I posted, definitely let me know!

 

EDIT #1:

I wanted to add that, for any other map but Taviana, if you want to use this code you have to open your editor with the map you want. Create a mission with a center, group and a playable character You can either copy and paste the code I put above or create your own outpost with whatever props you want. The playable character you added above should be placed where ever you want your trader to be. Save that mission then find it in My Documents\Arma 2 Other Profiles and open the mission file with whatever text editor you use on your PC. 

 

At this point if you wanted cut and paste my code into your mission.sqf you will need to go into the editor again and move the pieces around the map to where you want your trader to be before saving. After saving, you will just need to cut and paste all of your mining setup's createvehicle items from your mission.sqf into gem_trader.sqf.

Link to comment
Share on other sites

I believe you can only find them by mining the ore deposits. There is a 40% chance that a gem will drop and the type will be random according to the wiki. I have found 4 rubies and one emerald so not sure if wiki is 100% accurate or I just had weird luck.

Link to comment
Share on other sites

Heres a cool trick I learned...

 

When INSERT a new row into any table, if you leave the ID blank, the database will find the last row ID and increase by 1. :)

 

2. Open your server's database and navigate to the server_traders table. Verify that there isn't already an entry with ID 700. If there is, ensure that you change all instances of 700 in this tutorial with whatever ID you choose to use. Create a new entry and insert the following into the appropriate fields:

700, RU_Villager1, 13, neutral, ,Tavi Mining Company

 

 

So for this part of the TUT if you leave the 700 out it will find and place the next highest ID. :) I hope I explained this well and it makes sense. Great TUT. And so everyone knows you can use this TUT to create any kind of trader you like!

 

Zero

 

EDIT: You can also add the custom buildings and new trader Server side. I find this keeps the Mission file light and is cleaner. If you are interested in how to do this let me know and I will write a quick tutorial. :)

Link to comment
Share on other sites

Heres a cool trick I learned...

 

When INSERT a new row into any table, if you leave the ID blank, the database will find the last row ID and increase by 1. :)

 

 

So for this part of the TUT if you leave the 700 out it will find and place the next highest ID. :) I hope I explained this well and it makes sense. Great TUT. And so everyone knows you can use this TUT to create any kind of trader you like!

 

Zero

Excellent tip Zero! I'll update the tutorial with this info:)

Does that work in any database navigation tool? I use Navicat

Link to comment
Share on other sites

Excellent tip Zero! I'll update the tutorial with this info:)

Does that work in any database navigation tool? I use Navicat

 

As far as I know yes! Please try and let me know but as long as it is a SQL database then shouldn't matter.....but do try before you update the tutorial. Ive used PHPMyadmin and Navicat and I remember it doing so for both but I could be wrong :)

Link to comment
Share on other sites

  • 3 weeks later...

I've added a custom trader but when i click on the menu it just shows "Loading items..." for 0.05 seconds and it disappears - nothing loads.
I'm 99,9% sure everything has been corrected because I added some custom traders a few days ago and those worked like a charm, so I just copied the method.

Any tips?

Link to comment
Share on other sites

I've added a custom trader but when i click on the menu it just shows "Loading items..." for 0.05 seconds and it disappears - nothing loads.

Any tips?

I believe you also need to setup those gemstones@ trader_items

 

INSERT INTO `trader_items` VALUES ('838', 'ItemRuby', '1', 'GemStones', 'trade_items');

INSERT INTO `trader_items` VALUES ('839', 'ItemTopaz', '1', 'GemStones', 'trade_items');

INSERT INTO `trader_items` VALUES ('840', 'ItemObsidian', '1', 'GemStones', 'trade_items');

INSERT INTO `trader_items` VALUES ('841', 'ItemSapphire', '1', 'GemStones', 'trade_items');

INSERT INTO `trader_items` VALUES ('842', 'ItemAmethyst', '1', 'GemStones', 'trade_items');

INSERT INTO `trader_items` VALUES ('843', 'ItemEmerald', '1', 'GemStones', 'trade_items');

INSERT INTO `trader_items` VALUES ('844', 'ItemCitrine', '1', 'GemStones', 'trade_items');

 

This worked for me.

Link to comment
Share on other sites

for me only work the setting below.  otherwhise i can buy Gems for nothing..

Im using Chernarus

 

INSERT INTO `trader_items` VALUES ('838', 'ItemRuby', '1', 'GemStones', 'trade_items_old');
INSERT INTO `trader_items` VALUES ('839', 'ItemTopaz', '1', 'GemStones', 'trade_items_old');
INSERT INTO `trader_items` VALUES ('840', 'ItemObsidian', '1', 'GemStones', 'trade_items_old');
INSERT INTO `trader_items` VALUES ('841', 'ItemSapphire', '1', 'GemStones', 'trade_items_old');
INSERT INTO `trader_items` VALUES ('842', 'ItemAmethyst', '1', 'GemStones', 'trade_items_old');
INSERT INTO `trader_items` VALUES ('843', 'ItemEmerald', '1', 'GemStones', 'trade_items_old');
INSERT INTO `trader_items` VALUES ('844', 'ItemCitrine', '1', 'GemStones', 'trade_items_old');

 

Same as u want buy vehicles for gems... should also called "trade_any_vehicle_old".

Link to comment
Share on other sites

I have heard that, depending on your server provider, that you may need to tweak some of SQL code to get it to work. I have a custom server running stock code on a local machine in my home and everything worked when I tested it with friends joining over the net through Dayz Commander. Please respond if anyone having troubles was able to utilize the code with the above suggestions but also please post your server host. Might help people looking for answers that have similar setups:)

Link to comment
Share on other sites

As far as I know yes! Please try and let me know but as long as it is a SQL database then shouldn't matter.....but do try before you update the tutorial. Ive used PHPMyadmin and Navicat and I remember it doing so for both but I could be wrong :)

 

 

you can also use "NULL" if you are explicitly referencing columns.  edit:  this only work if the column is not set to "NOT NULL"

 

like:

 INSERT INTO dayzepoch.trader_items
(
  id
 ,classname
 ,type
 ,`group`
 ,afile
)
VALUES
(
  123 -- id - INT(11) NOT NULL
 ,'Some Class' -- classname - VARCHAR(128) NOT NULL
 ,1 -- type - TINYINT(1) NOT NULL
 ,NULL -- group - VARCHAR(128)
 ,'somefile' -- afile - VARCHAR(128) NOT NULL
)
 
 
Link to comment
Share on other sites

  • 5 months later...

You guys!

For Overpoch:

mission.sqm

		class Item17
		{
			position[]={8418.33,5,3101.25};
			name="EpicMegaZomgMiningCompany";
			text="Epic mega zomg Mining Company";
			type="mil_dot";
			colorName="ColorBlack";
		};

Gem_Trader.sqf

_unit_1337 = objNull;
if (true) then
{
  _this = createAgent ["RU_Villager1", [8418.33, 3101.25,0.1], [], 0, "CAN_COLLIDE"];
  _unit_1337 = _this;
  _this setDir 29;
  _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;
};
 
_vehicle_0 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_bouda_plech", [8420.0205, 3099.5825, 6.1035156e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_0 = _this;
  _this setDir 90.66597;
  _this setPos [8420.0205, 3099.5825, 6.1035156e-005];
};
 
_vehicle_9 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_stanek_3B", [8418.7871, 3102.0747], [], 0, "CAN_COLLIDE"];
  _vehicle_9 = _this;
  _this setDir 118.30024;
  _this setPos [8418.7871, 3102.0747];
};
 
_vehicle_16 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_Misc_WoodPile", [8425.7505, 3099.2954, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_16 = _this;
  _this setPos [8425.7505, 3099.2954, -3.0517578e-005];
};
 
_vehicle_29 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_Barels", [8419.0283, 3097.7544], [], 0, "CAN_COLLIDE"];
  _vehicle_29 = _this;
  _this setDir 6.0406318;
  _this setPos [8419.0283, 3097.7544];
};
 
_vehicle_30 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_barrel_water", [8420.3247, 3100.3833, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_30 = _this;
  _this setPos [8420.3247, 3100.3833, -3.0517578e-005];
};
 
_vehicle_31 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_P_pipe_small", [8423.0938, 3097.5908, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_31 = _this;
  _this setDir 3.4072633;
  _this setPos [8423.0938, 3097.5908, 3.0517578e-005];
};
 
_vehicle_32 = objNull;
if (true) then
{
  _this = createVehicle ["Land_Fire_barrel", [8426.4844, 3101.5562], [], 0, "CAN_COLLIDE"];
  _vehicle_32 = _this;
  _this setDir 203.54425;
  _this setPos [8426.4844, 3101.5562];
};

Location:

3E5pfRs.jpg

Link to comment
Share on other sites

i am using vilayer and i can't seem to get it to work right.  i am trying to add the gems to the black market trader on NAPF to buy and sell and then trying to add lav's and btr and attack heli's to the hero and bandit for gems but can't figure out why its not working the way i want. any help would be greatly appreciated?    i am also using overpoch as well

Link to comment
Share on other sites

  • 4 weeks later...

I followed you step by step in everyway... but when i click Gemstones, it doesn't show anything! what do i do?

So it sounds like its at least loading the server_traders, have you double checked your database and made sure that the seven item entries and the trader entry have been made?  

Link to comment
Share on other sites

When the trade menu isn't sending anything back for one trader but does for other traders then there's something wrong in one of those three places, your server_traders, your tids table and your items table. If all three of those items are good, I'm not sure what else could be the issue.

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
  • Discord

×
×
  • Create New...