Jump to content
  • 0

Custom trader cities


BetterDeadThanZed

Question

This post started as a request for information on how add traders. The question was answered, so I thought I'd update my original post with instructions on how to do this:

 

It is easier to add traders if you don't want them to have their own inventory. This tutorial will start with explaining how to add traders and have them use the same database data/inventory as other traders.

 

Using the 3D editor, create a trader city. Place units at the locations where you want to have the traders standing. I am not going to explain how to use the 3D editor. You should already know how to do that.

Open server_traders.sqf for reference and keep it open.

Open mission.sqf and add an entry for your first new trader:

_unit_13001 = objNull;
if (true) then
{
  _this = createAgent ["GUE_Soldier_1", [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;};

_unit_#### can be a unique number not being used anywhere else in mission.sqf

 

"createAgent" should match one of the traders in the server_traders.sqf file. For example:

// Ammunition Neutral P
menu_BAF_Soldier_AMG_W = [
[["Assault Rifle Ammo",480],["Light Machine Gun Ammo",481],["Pistol Ammo",484],["Shotguns and Single-shot Ammo",573],["Sniper Rifle Ammo",482],["Submachine Gun Ammo",483]],
[],
"neutral"
];

This is a neutral ammunition trader. You can select "BAF_Soldier_AMG_W" and put it in the above mission.sqf file:

_this = createAgent ["BAF_Soldier_AMG_W", [2550.658, 8326.5928, 2.3534577], [], 0, "CAN_COLLIDE"];

Change the coordinates above with the coordinates from the new trader city you created. Also change these lines:

_unit_13001 = _this;
_this setDir 114.59087;

_unit matches the _unit number you chose above and setDir is in the mission file from the trader city you created.

 

What this does is spawns a trader with the classname "BAF_Soldier_AMG_W"", which the server recognizes is the neutral ammo trader as defined in the server_traders.sqf file. Please note that I pulled this from a Panthera server_traders.sqf so yours might be different.

 

After you've added all the traders this way, feel free to copy over the other items, such as tents, boxes, etc that you created in the mission you created in the 3D editor. Place all of this above the "processInitCommands;" commands at the bottom of the server's mission.sqf.

 

Creating traders with their own inventory

 

If you want to create unique traders that do not use the inventory of an existing trader, you need to do a little more.

 

After adding the tents, boxes, etc that make up your new trader city, and adding the traders as above, you perform the following steps.

 

In server_traders.sqf, you have to add the trader. It has to use a unique classname not being used by any other trader and it can not be used by any AI that you have on the server. If, for example, you use the same classname for this new trader as that of a bandit AI in your mission system, when you come across a dead bandit, you will get a trader prompt on your scroll menu!

 

For my example, I will use "Fiona". She is a trader I added to my Napf and Panthera servers that sells and buys rare food and drinks. This is what I added to server_traders.sqf:

// Rare Food and Drinks
menu_RU_Damsel5 = [
[["Rare Food/Drinks",700]],
[],
"neutral"
];

I used the model "RU_Damsel5". When you bring up the menu, it says "Rare Food/Drinks" and it uses trader ID 700. Whatever model you use, it needs to be added to the top of server_traders.sqf:

serverTraders = ["Tanny_PMC","BAF_Soldier_AMG_W","BAF_Soldier_AAA_DDPM","CZ_Special_Forces_MG_DES_EP1","Damsel5","GUE_Commander","GUE_Woodlander1","GUE_Woodlander3","GUE_Soldier_Sab","GUE_Soldier_Pilot","GUE_Soldier_2","Soldier_PMC","Citizen2_EP1","Rita_Ensler_EP1","RU_Farmwife1","US_Soldier_Medic_EP1","USMC_Soldier_TL","USMC_SoldierS_Engineer","UN_CDF_Soldier_AAT_EP1","ValentinaVictim","UN_CDF_Soldier_MG_EP1","GUE_Soldier_1","FR_Corpsman","GUE_Soldier_AR","Dr_Hladik_EP1","RU_Villager1","Reynolds_PMC","RU_Damsel5"];

In your database, you have to add the trader:

REPLACE INTO `server_traders` (`id`, `classname`, `instance`, `status`, `static`, `desc`) VALUES (700, 'RU_Damsel5', 24, 'friendly', NULL, 'Fionas Pub');

Then you have add the items the new trader will stock:

REPLACE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile`) VALUES (7589, '["ItemSodaRabbit",1]', 1000, '[6,"ItemGoldBar",1]', '[3,"ItemGoldBar",1]', 0, 700, 'trade_items');

This adds the item "ItemSodaRabbit" with a quantity of 1000, selling for 6oz gold, buying for 3oz gold, to trader ID #700.

 

I hope that helps everyone! Let me know if you have questions. Thank you for everyone that answered the original post I made which led me to making this new post!

Link to comment
Share on other sites

Recommended Posts

  • 0

@betterdeadthanzed...

 

Thanks for the writeup.  I really want to do something with the trader cities and this saves a lot of groundwork.

 

 Any reason for the '_this' variable being used for the createagent command rather than just using the unit variable (i.e. _unit_13001 in your example) and then just using the unit id for the setdir etc ?.  Have not tried it so not sure if there are any querks that are forcing you to do it that way.

 

RB

 

I really don't know. Most of what I've posted, I've gotten from other sources, including replies in this thread. All I know is that I do it the way I explained in the first post and it works. :)

Link to comment
Share on other sites

  • 0

If you have the interest, you may want to try the createagent  command with _unit_13001 = instead of _this = .

 

You could then replace all the _this with _unit_13001 and remove the _unit_13001 = _this line completely.

 

I may give it a go when I have the better refueling working but that may be some time yet  ;) 

Link to comment
Share on other sites

  • 0

If you have the interest, you may want to try the createagent  command with _unit_13001 = instead of _this = .

 

You could then replace all the _this with _unit_13001 and remove the _unit_13001 = _this line completely.

 

I may give it a go when I have the better refueling working but that may be some time yet  ;) 

 

What advantage does that give?

Link to comment
Share on other sites

  • 0

One less line of code, clarity.

 

If all the activity is with a single unit then why not use the single unit variable.

 

If there were multiple units in an array then using _this or another temp variable to loop through the unit setup lines.

 

If there is no reason for the   _unit_13001 = _this (i.e. you are not referencing _unit_13001 anywhere in the script), then why set it ?.  Less lines = faster execution.

 

_this is also quite a common variable to use and it would help to prevent clashes if you make future amendments (i.e you add a feature that requires you to pass a variable to the script which would be passed using the standard _this select 0 methodology).

 

​Certainly not required, just a suggestion.

Link to comment
Share on other sites

  • 0

So I was finally able to get some traders in. Now i'm trying to get these coords to work. I'm going to try and follow earlier advice of X,Y then the third set of numbers is for setdir. But I can't really figure out what's happening in this code here:

	class Item10
		{
			position[]={4338.8359,101.17657,6317.54};
			a=100;
			b=100;
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="TraderCityUkanc";
			expCond="(player distance TraderCityUkanc) < 100; ";
			expActiv="TitleText[""Now Entering Trader City Ukanc"",""PLAIN DOWN""]; canbuild = false;";
			expDesactiv="TitleText[""Now Leaving Trader City Ukanc"",""PLAIN DOWN""]; canbuild = true;";
			class Effects
			{
			};
		};
		class Item11
		{
			position[]={5288.5581, 3820.4824, -0.00012588501};
			a=100;
			b=100;
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="TraderCityUkanc_1";
			expCond="(player distance TraderCityUkanc) < 100; ";
			expActiv="TitleText[""Now Entering Trader City Ukanc"",""PLAIN DOWN""]; canbuild = false;";
			expDesactiv="TitleText[""Now Leaving Trader City Ukanc"",""PLAIN DOWN""]; canbuild = true;";
			class Effects
			{
			};
		};

This is my added code, copied from the earlier trader city codes. The coords put the safezone somewhere in the ocean, and there's two for each trader city. It also has the marker on the map in the same place. Why does there need to be two, and what are they doing? Also, how would I get the right coordinates for these? Thanks.

Link to comment
Share on other sites

  • 0

Also, for some reason one of the traders that spawns in the right spot also keep spawning multiple AI. So there will be a medic trader, like normal, but then some more with the same skin spawn and just stand there and can be shot and killed. I'm not sure why they spawn. It happened with another medic skin too. I have the trader placed in a medical tent, if that would do anything? Here's the code for the medic, let me know what's wrong with it.

 _unit_1232 = objNull;
if (true) then
{
  _this = createAgent ["Dr_Hladik_EP1", [5255.5122, 3853.0439, 1.9073486e-006], [], 0, "CAN_COLLIDE"];
  _unit_1232 = _this;
   _this setDir 140.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;};
 };
Link to comment
Share on other sites

  • 0
hey guys losing the will to live with this one now lol so im trying to add a super hero vendor to the map. i used this tutorial to add him to the map (https://docs.google.com/document/d/17qG ... UiZuQ/edit) and this tutorial to make a humanitys requirement of 20000 () what i dont understand in the first tutorial is updating the object number, what do i update it to? i have tried many different ones and whatever i change it to, my trader is still on the map. and for the database, what instance do i set it to? it says 11 in that tuorial. anyway the trader is on the map and displayes the menu and items just fine, however anyone can acess it, heros bandits and neutral. im sure my problem is coming from either the object number or the instance but i am at a loss now, if anyone has the answer ill love you for ever lol.

here is what i added to my mission.sqf

_unit_146 = objNull;
if (true) then
{
_this = createAgent ["Tanny_PMC", [5898.0303, 10544.666], [], 0, "CAN_COLLIDE"];
_unit_146 = _this;
_this setDir -83.040123;
_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;
};

here is what my server traders looks like, i have added the tanny_pmc at the top also

/*---------------------------------------------------------------------------
Super Hero Vendor
---------------------------------------------------------------------------*/

//super hero
menu_Tanny_PMC = [
[["Super Hero Trader",693]],
[],
"super"
];

here is my fn_selfactions

// All Traders
if (_isMan and !_isPZombie and _traderType in serverTraders) then {

if (s_player_parts_crtl < 0) then {

// get humanity
_humanity = player getVariable ["humanity",0];
_traderMenu = call compile format["menu_%1;",_traderType];

// diag_log ("TRADER = " + str(_traderMenu));

_low_high = "low";
_humanity_logic = false;
if((_traderMenu select 2) == "friendly") then {
_humanity_logic = (_humanity < -5000);
};
if((_traderMenu select 2) == "hostile") then {
_low_high = "high";
_humanity_logic = (_humanity > -5000);
};
if((_traderMenu select 2) == "hero") then {
_humanity_logic = (_humanity < 5000);
};
if((_traderMenu select 2) == "super") then {
_humanity_logic = (_humanity < 20000);
};
if(_humanity_logic) then {
_cancel = player addAction [format[localize "STR_EPOCH_ACTIONS_HUMANITY",_low_high], "\z\addons\dayz_code\actions\trade_cancel.sqf",["na"], 0, true, false, "",""];
s_player_parts set [count s_player_parts,_cancel];
} else {

he is also set to super in my database written exctly the same and everything and is instance 17 at the moment however i have tried others i will take a screen shot of my database if that helps. Thanks in advance for any help, my mind is boggled lol, Brett.
Link to comment
Share on other sites

  • 0

Ok, question: let's say I want to add 3 traders selling the same things, can I have them have the same trader menu id?

All you would need to do is setup the trader menu info and other various trader stuff once. Then, if you add two more "traders" with the same skin as the one specified for the first, the other two will be traders as well, since, anyone using the specified skin gets the trader menu.

Link to comment
Share on other sites

  • 0

My question, I have created a vehicle trader but the vehicles are spawning a little too close to the trader, how do I go about increasing the distance the vehicles spawn once purchased.

 

Thanks!

 

You would need to move the helipad in the editor ("HeliHCivil" or "HeliHEmpty").

Link to comment
Share on other sites

  • 0

Just open up your map edits in the 3D editor and add one of the helipads I mentioned above. Purchased vehicles will spawn on the helipad.

They "should" spawn there, though I've experienced in certain situations where it chose another heli pad like 100m away at another dealer.  I'm not sure if the proximity of the helipads confused it or if it was simply ignoring the one I was providing because of its placement and reached out for the other one.  Just make sure there's enough room where you're putting it, no objects nearby to obstruct its function.  Trial and error.

Link to comment
Share on other sites

  • 0

They "should" spawn there, though I've experienced in certain situations where it chose another heli pad like 100m away at another dealer.  I'm not sure if the proximity of the helipads confused it or if it was simply ignoring the one I was providing because of its placement and reached out for the other one.  Just make sure there's enough room where you're putting it, no objects nearby to obstruct its function.  Trial and error.

 

 

It worked, thanks a lot guys.

Link to comment
Share on other sites

  • 0

Can't remember if I've posted this, but this is what I made a while ago.  We still have it set up on our server that no one is using.   We were waiting to switch to A3 Epoch, but that looks like it's going to take a while, so we're thinking of changing it to Overpoch.. so I may just completely redo the traders again. XD

Link to comment
Share on other sites

  • 0

Hi there had a flick through this post but I am needing a bit of a hand. I have my server just purchased and what I want to do is actually open up the trader city files in the arma editor so it shows the current epoch trader city objects and then replace and edit the cities that way as I think just putting for example walls around the city in the editor then inserting them to my server as buildings via the mission file will cause alot of collisions as I wont know where the existing items are etc.

Link to comment
Share on other sites

  • 0

I am just at a complete loss here...I have tried just about everything I can think of just to get a trader spawned in the map.
I edit my stuff just like the tut says (I have tried 3 times from scratch) yet every time I get this error:

 

23:54:12 Error in expression <ll;
if (true) then
{
_this = createUnit ["Graves_Light_DZ", [7047.814, 2821.4624>
23:54:12 Error position: <["Graves_Light_DZ", [7047.814, 2821.4624>
23:54:12 Error Missing ;
23:54:12 File z\addons\dayz_server\missions\DayZ_Epoch_11.Chernarus\mission.sqf, line 3235
23:54:12 Error in expression <ll;
if (true) then
{
_this = createUnit ["Graves_Light_DZ", [7047.814, 2821.4624>
23:54:12 Error position: <["Graves_Light_DZ", [7047.814, 2821.4624>
23:54:12 Error Missing ;
23:54:12 File z\addons\dayz_server\missions\DayZ_Epoch_11.Chernarus\mission.sqf, line 3235

 

It says im missing a ";" but how is that ? I have just copied the other traders and changed a few things to this:
 

_unit_17002 = objNull;
if (true) then
{
  _this = createUnit ["Graves_Light_DZ", [7047.814, 2821.4624, -9.5367432e-007], [], 0, "CAN_COLLIDE"];
  _unit_17002 = _this;
  _this setDir 99.524971;
  _this setVehicleInit "this allowDammage false; this disableAI 'FSM'; this disableAI 'MOVE'; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this setBehaviour 'CARELESS'; this forceSpeed 0; this disableAI 'ANIM';";
  _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;
};

What do I have wrong here???

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
  • Advertisement
×
×
  • Create New...