Jump to content
  • 0
Longshot03XX

Roaming Trader

Question

Okay so I am interested in setting up a roaming trader that only moves after every restart and sells high-end weapons/vehicles. If anyone has a way to help or contribute please feel free.

 

**This is not my script** This work is Inkko's 

 

/*-----------------------------------


|Roaming Trader (RT) Script by Inkko |
[] execVM "script.sqf"; bottom of server_functions.sqf
-----------------------------------*/
//Config
RT_TraderArray = ["Functionary2","RU_Functionary1","CIV_EuroMan02_EP1","GUE_Soldier_MG","RU_WorkWoman5","RU_Citizen1","menu_CIV_EuroMan01_EP1","RU_Profiteer4","Woodlander3","Doctor","GUE_Woodlander2","HouseWife1"]; // list of traders that are randomly chosen
RT_MaxDistance = 6000; // Max distance away from center of map to look for safe spot
RT_CloseObject = 30; // Max distance to closest object; BIS_fnc_findSafePos
RT_Timer = 900; // random number between 0-900, added to RT_Timer2 for fluctuating times.
RT_Timer2 = 300; // Base wait time.
RT_Wait = 120; // delay for warning that trader will move soon.
RT_Wait2 = 360; // Time till new trader shows up once previous trader has been deleted. Random number between 0-360.
RT_Color = "ColorBlack"; // Color of marker
RT_SpawnedMessage = "Roaming trader has setup on the map."; // message broadcast when trader spawns
RT_LeaveSoonMessage = "The roaming trader is about to travel to a new location."; // warning that trader will move soon.
RT_MovedMessage = "Roaming trader has packed up and is looking for a new spot."; // Broadcasts that trader has moved and looking for new spot.

//Config End
RT_Counter = 0;
uisleep 200; //intial delay before trader sets up.

RT_Fnc_Trader = {

RT_Location = [getMarkerPos "Center",0,RT_MaxDistance,RT_CloseObject,0,2,0] call BIS_fnc_findSafePos; //finds safe location
RT_TraderType = RT_TraderArray call BIS_fnc_selectRandom; // Selects trader type

// Locates correct text for trader skin selected. Change text based on what your traders are setup for.
if (RT_TraderType == "Functionary2") then {RT_Text="Gem Trader";};
if (RT_TraderType == "RU_Functionary1") then {RT_Text="Hero Trader";};
if (RT_TraderType == "CIV_EuroMan02_EP1") then {RT_Text="Ammunition Trader";};
if (RT_TraderType == "GUE_Soldier_MG") then {RT_Text="Bandit Trader";};
if (RT_TraderType == "RU_WorkWoman5") then {RT_Text="Supply Trader";};
if (RT_TraderType == "RU_Citizen1") then {RT_Text="Wholesaler";};
if (RT_TraderType == "menu_CIV_EuroMan01_EP1") then {RT_Text="Weapon Trader";};
if (RT_TraderType == "RU_Profiteer4") then {RT_Text="Vehicle Trader";};
if (RT_TraderType == "Woodlander3") then {RT_Text="Building Supply Trader";};
if (RT_TraderType == "Doctor") then {RT_Text="Medical Trader";};
if (RT_TraderType == "HouseWife1") then {RT_Text="Special Trader";};
if (RT_TraderType == "GUE_Woodlander2") then {RT_Text="Black Market Weapons";};

// creating mini-trader; trader, table, pad.
RT_CreateTrader = createAgent [RT_TraderType, [(RT_Location select 0)-18.6689,(RT_Location select 1)-13.2617, 0], [], 0, "CAN_COLLIDE"];
RT_CreateTrader setDir 233.79846;
RT_CreateTrader setVehicleInit "this allowDammage false; this disableAI 'FSM'; this disableAI 'MOVE'; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this setBehaviour 'CARELESS'; this forceSpeed 0;";
RT_CreateTrader setUnitAbility 0.60000002;
RT_CreateTrader allowDammage false; RT_CreateTrader disableAI 'FSM'; RT_CreateTrader disableAI 'MOVE'; RT_CreateTrader disableAI 'AUTOTARGET'; RT_CreateTrader disableAI 'TARGET'; RT_CreateTrader setBehaviour 'CARELESS'; RT_CreateTrader forceSpeed 0;RT_CreateTrader enableSimulation false;

RT_CreatePad = createVehicle ["HeliHCivil", [(RT_Location select 0),(RT_Location select 1), 0], [], 0, "CAN_COLLIDE"];
RT_CreatePad setDir -29.372313;
RT_CreatePad setPos [(RT_Location select 0),(RT_Location select 1), 0];

RT_CreateObject1 = createVehicle ["MAP_Fortress_01", [(RT_Location select 0)-17.3696,(RT_Location select 1)+10.497, 0], [], 0, "CAN_COLLIDE"];
RT_CreateObject1 setDir 150.883755;
RT_CreateObject1 setPos [(RT_Location select 0)-17.3696,(RT_Location select 1)+10.497, 0];

RT_CreateObject2 = createVehicle ["MAP_Misc_cargo_cont_net3", [(RT_Location select 0)-14.1455,(RT_Location select 1)+3.2548, 0], [], 0, "CAN_COLLIDE"];
RT_CreateObject2 setDir 56.260017;
RT_CreateObject2 setPos [(RT_Location select 0)-14.1455,(RT_Location select 1)+3.2548, 0];

RT_CreateObject3 = createVehicle ["MAP_HBarrier5", [(RT_Location select 0)-16.8638,(RT_Location select 1)-4.3334, 0], [], 0, "CAN_COLLIDE"];
RT_CreateObject3 setDir -123.68772;
RT_CreateObject3 setPos [(RT_Location select 0)-16.8638,(RT_Location select 1)-4.3334, 0];

RT_CreateObject4 = createVehicle ["MAP_HBarrier5", [(RT_Location select 0)-13.5845,(RT_Location select 1)-9.1324, 0], [], 0, "CAN_COLLIDE"];
RT_CreateObject4 setDir -123.68772;
RT_CreateObject4 setPos [(RT_Location select 0)-13.5845,(RT_Location select 1)-9.1324, 0];

RT_CreateObject5 = createVehicle ["MAP_HBarrier5", [(RT_Location select 0)-10.2895,(RT_Location select 1)-13.9164, 0], [], 0, "CAN_COLLIDE"];
RT_CreateObject5 setDir -123.68772;
RT_CreateObject5 setPos [(RT_Location select 0)-10.2895,(RT_Location select 1)-13.9164, 0];

RT_CreateObject6 = createVehicle ["MAP_CamoNet_EAST_var1", [(RT_Location select 0)-17.6933,(RT_Location select 1)+13.2617, 0], [], 0, "CAN_COLLIDE"];
RT_CreateObject6 setDir -122.872;
RT_CreateObject6 setPos [(RT_Location select 0)-17.6933,(RT_Location select 1)+13.2617, 0];

// start timer functions, broadcasts, and logs
_mapgrid = mapGridPosition RT_Location;
diag_log format["Roaming Trader: Spawned at grid %1, trader type selected as %2 trader type %3", _mapgrid, RT_TraderType, RT_Text];
[nil,nil,rTitleText,RT_SpawnedMessage,"PLAIN",10] call RE;
RT_Active = true;
// marker loop to keep marker active while trader is around
[] spawn {
while {RT_Active} do {
_mrk = createmarker ["Special_Trader",RT_Location];
_mrk setmarkertype "mil_dot";
_mrk setMarkerSize [1, 1];
_mrk setmarkercolor RT_Color;
_mrk setMarkerText RT_Text;
sleep 30;
deletemarker "Special_Trader";
};
};
_cleanuptimer = round (random RT_Timer);
_cleanuptimer = _cleanuptimer + RT_Timer2;

diag_log format["Roaming Trader: (%5) Spawned at grid %1, trader type selected as %2 trader type %3 for %4 seconds", _mapgrid, RT_TraderType, RT_Text,_cleanuptimer,RT_Counter];

uisleep _cleanuptimer;

[nil,nil,rTitleText,RT_LeaveSoonMessage,"PLAIN",10] call RE;

uisleep RT_Wait;

[nil,nil,rTitleText,RT_MovedMessage,"PLAIN",10] call RE;

// timer up, removes trader and objects.
deletevehicle RT_CreateTrader;deletevehicle RT_CreatePad;deletevehicle RT_CreateObject1;RT_Active = false;deletemarker "Special_Trader";
deletevehicle RT_CreateObject2;deletevehicle RT_CreateObject3;deletevehicle RT_CreateObject4;deletevehicle RT_CreateObject5;deletevehicle RT_CreateObject6;
// wait time till next trader spawns
RT_Wait2 = round (random RT_Wait2);
diag_log format["Roaming Trader: Spawning in %1 seconds.", RT_Wait2];
uisleep RT_Wait2;

RT_Counter = RT_Counter+1;

call RT_Fnc_Trader; // starts function all over again.

};

call RT_Fnc_Trader; //initial call of function

 

Some issues that I've ran into so far are just the design of the trader and it being underground or not spawning on leveled ground.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Okay so i found a better script but im having problems with the trader spawning off the map in debug sometimes... can anyone please help me?

 

this is the init.sqf for maca134's roaming trader 

/*


Epoch Dynamic Traders my maca134
http://www.epochservers.com

You will need to go into each file in the traders file and change the model/skin to the relevent trader for the map you are using.
Look in server_traders.sqf in the mission pbo for more information.

*/
private ["_trader_config", "_markers"];

DT_fnc_ObjectsMapper = compile preprocessFileLineNumbers "\z\addons\dayz_server\roamingTrader\objectMapper.sqf";
DT_fnc_CreateTrader = compile preprocessFileLineNumbers "\z\addons\dayz_server\roamingTrader\createTrader.sqf";

_trader_config = [
[1, "vehicles.sqf", "Roaming Trader", "ColorRed"]
];

_markers = [];
waitUntil { sleep 1; !isNil "sm_done" };
{
for [{_i=0}, {_i<(_x select 0)}, {_i=_i+1}] do {
private ["_position", "_found_position", "_j", "_near_trader"];
waitUntil { !isNil "BIS_fnc_findSafePos" };
_found_position = false;
_j = 0;
while {!_found_position} do {
_j = _j + 1;
if ((_x select 1) == "boat.sqf") then {
_position = [getMarkerPos 'center',0,DynamicVehicleArea,20,0,2000,1] call BIS_fnc_findSafePos;
} else {
if (!isNil "RoadList" and {(random 1) > 0.5}) then {
waitUntil{!isNil "BIS_fnc_selectRandom"};
_position = RoadList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
waitUntil{!isNil "BIS_fnc_findSafePos"};
_position = [_position,5,40,20,0,2000,0] call BIS_fnc_findSafePos;
} else {
waitUntil{!isNil "BIS_fnc_findSafePos"};
_position = [getMarkerPos 'center',0,DynamicVehicleArea,20,0,2000,0] call BIS_fnc_findSafePos;
};
};

{
if (((_x select 0) distance _position) < 1000) exitWith {
_position = [];
};
true
} count _markers;
if ((count _position) == 2 or _j > 10) then {
_found_position = true;
};
};

if ((count _position) == 2) then {
diag_log format["Trader Caravans: Spawning %1 at %2 (%3)", _x select 1, _position, mapGridPosition _position];
_position execVM format["\z\addons\dayz_server\roamingTrader\traders\%1", _x select 1];
_markers set [count _markers, [_position, _x select 2, _x select 3]];
};
};
true
} count _trader_config;

PV_TraderMarkers = _markers;
publicVariable "PV_TraderMarkers";

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...