Jump to content
Sign in to follow this  
JamesonD

Need help wth a spawning script

Recommended Posts

So i am tryin to recreate a script which allows me to use a scroll wheel option to spawn vehicles from say a field toilet i had it working on arma 2 but haven't been able to port the script across over to arma 3 for some reason i was wondering if any1 out there can help me with this as currently working on building a new training map for my clan but would prefer to spawn the vehicles out rather then have them out on the map already.

Also if any1 can provide us with a opfor spawning script aswell that would be greatly appreciated i can provide details on the scripts i was using if needed thanx in advanced

Edited by JamesonD

Share this post


Link to post
Share on other sites

If you posted the script that was working, that would probably help. Anyway, you could try something simple like this:

player addAction ["Spawn ATV", {createVehicle [(_this select 3), (getPosATL player), [], 5, "NONE"]}, "b_quadbike_01_f"];

Regarding a spawning script, you will have to be more specific. Otherwise, I can only suggest this:

http://community.bistudio.com/wiki/BIS_fnc_spawnGroup

Share this post


Link to post
Share on other sites

sry yer i should've been more specific with the script they way we had our training map setup b4 was with a field toilet which had this in the init field:

this addAction["Spawn vehicle", "dlg.sqf"]; this addEventHandler ["HandleDamage", "false"]

then behind the toilet a heavy factory with:

this addEventHandler ["HandleDamage", "false"]

then in the dlg.sqf:

if (not alive player or lifestate player == "UNCONSCIOUS") exitwith {};

if not ((_this select 1) in actionkeys "teamswitch" or count _this == 4) exitwith {};

if dialog exitwith {closedialog 3000};

_near = [];

{

if ({alive _x} count nearestobjects [vehicle player, [_x], 25] != 0) then {

_near = _near + [_x];

};

} foreach ["US_WarfareBLightFactory_EP1", "TK_WarfareBLightFactory_EP1", "US_WarfareBHeavyFactory_EP1","TK_WarfareBHeavyFactory_EP1", "US_WarfareBAircraftFactory_EP1", "TK_WarfareBAircraftFactory_EP1"];

if (count _near == 0) exitwith {hint "No Factory Nearby"};

if not (createdialog "doodialog") exitwith {};

uinamespace setvariable ["doolb", finddisplay 3000 displayctrl 3002];

for [{_i = 0}, {_i < count buyarray}, {_i = _i + 1}] do {

_item = buyarray select _i;

if (_item select 0 in _near) then {

_index = (uinamespace getvariable "doolb") lbadd (_item select 2);

(uinamespace getvariable "doolb") lbsetdata [_index, str _i];

(uinamespace getvariable "doolb") lbsetpicture [_index, _item select 3];

};

};

lbsetcursel [3002, currentselect];

then in the description this:

class doostatic {

type = 0;

idc = -1;

style = 0;

x = 0;

y = 0;

w = 1;

h = 1;

colorBackground[] = {0, 0, 0, 0.75};

colorText[] = {0, 0, 0, 1};

font = "Zeppelin32";

sizeEx = 0.023;

text = "";

};

class doobutton {

type = 1;

idc = -1;

style = "0x02 + 0x100";

x = 0;

y = 0;

w = 0.095589;

h = 0.039216;

colorText[] = {0.543, 0.5742, 0.4102, 1};

colorDisabled[] = {0.4, 0.4, 0.4, 1};

font = "Zeppelin32";

sizeEx = 0.03921;

text = "";

colorBackground[] = {1, 0.537, 0, 0.5};

colorBackgroundActive[] = {1, 0.537, 0, 1};

colorBackgroundDisabled[] = {0.95, 0.95, 0.95, 1};

colorFocused[] = {1, 0.537, 0, 1};

offsetX = 0.003;

offsetY = 0.003;

offsetPressedX = 0.002;

offsetPressedY = 0.002;

colorShadow[] = {0.023529, 0, 0.0313725, 1};

colorBorder[] = {0.023529, 0, 0.0313725, 1};

borderSize = 0;

soundEnter[] = {"\ca\ui\data\sound\mouse2", 0.09, 1};

soundPush[] = {"\ca\ui\data\sound\new1", 0.09, 1};

soundClick[] = {"\ca\ui\data\sound\mouse3", 0.07, 1};

soundEscape[] = {"\ca\ui\data\sound\mouse1", 0.09, 1};

};

class doolistbox {

type = 5;

idc = -1;

style = "0 + 0x10";

x = 0;

y = 0;

w = 0;

h = 0;

colorText[] = {0.543, 0.5742, 0.4102, 1};

colorSelect[] = {0.95, 0.95, 0.95, 1};

soundSelect[] = {"\ca\ui\data\sound\new1", 0.09, 1};

class ScrollBar {

thumb = "\ca\ui\data\ui_scrollbar_thumb_ca.paa";

arrowEmpty = "\ca\ui\data\ui_arrow_top_ca.paa";

arrowFull = "\ca\ui\data\ui_arrow_top_active_ca.paa";

border = "\ca\ui\data\ui_border_scroll_ca.paa";

};

font = "Zeppelin32";

sizeEx = 0.03921;

rowHeight = 0.05;

autoScrollRewind = 0;

autoScrollDelay = 1;

autoScrollSpeed = -1;

maxHistoryDelay = 1;

};

class doodialog {

idd = 3000;

class controls {

class title : doostatic {

idc = 3001;

};

class mylistbox : doolistbox {

idc = 3002;

x = 0.152782;

y = 0.27103;

w = 0.752;

h = 0.483;

onlbdblclick = "[] spawn doobuy";

};

class okbutton : doobutton {

idc = 3003;

x = 0.752;

y = 0.7625;

text = "$STR_DISP_OK";

onbuttonclick = "[] spawn doobuy";

default = 1;

};

class cancelbutton : doobutton {

idc = 3004;

x = 0.552;

y = 0.7625;

text = "$STR_DISP_CANCEL";

onbuttonclick = "closedialog 3000";

};

};

};

and in the init.sqf:

#define cfgvehiclestuff(x) x, gettext (configfile >> "CfgVehicles" >> x >> "displayName") + " (" + gettext (configFile >> "CfgFactionClasses" >> gettext (configfile >> "CfgVehicles" >> x >> "faction") >> "displayName") + ")", gettext (configfile >> "CfgVehicles" >> x >> "picture")

buyarray = [

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ATV_CZ_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_ATV_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_ATV_W")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ATV_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("GRAD_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Pickup_PK_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_HMMWV_GMV")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_HMMWV_GMV_MK19")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Offroad_DSHKM_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Offroad_SPG9_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_Jackal2_GMG_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_Jackal2_GMG_W")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_Jackal2_L2A1_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_Jackal2_L2A1_W")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("LandRover_Special_CZ_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("LandRover_CZ_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_Offroad_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_Offroad_W")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_M2")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_MK19_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_MK19")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M1030_US_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M1030")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_TOW_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_TOW")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_Avenger_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_Avenger")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_Armored")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_M998_crows_M2_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_M998_crows_MK19_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_M1035_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_M1151_M2_CZ_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_M1151_M2_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_Terminal_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_Truck5t")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_Truck5tMG")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_Truck5tMGOpen")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_Truck5tOpen")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("MTVR")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("MMT_USMC")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("MTVR_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SUV_PMC_BAF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("V3S_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("HMMWV_M998A2_SOV_DES_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SUV_PMC")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SUV_UN_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ArmoredSUV_PMC")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("TowingTractor")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("UAZ_AGS30_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("UAZ_MG_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_UAZ_SPG9_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("UAZ_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("UAZ_Unarmed_UN_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Ural_ZU23_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Ural_ZU23_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Ural_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Ural_UN_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("UralOpen_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Stinger_Pod")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("AGS_CZ_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("AGS_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("AGS_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("AGS_UN_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("D30_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("D30_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("DSHKM_CZ_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("DSHKM_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("DSHKM_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("DSHkM_Mini_TriPod")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("DSHkM_Mini_TriPod_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("Stinger_Pod_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_GMG_Tripod_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_BAF_GPMG_Minitripod_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_GPMG_Minitripod_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("KORD_high_UN_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("KORD_UN_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_L2A1_Minitripod_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("BAF_L2A1_Tripod_D")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M119_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M119")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_M240_Tripod")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_M240M145_Tripod")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M2StaticMG_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M2StaticMG")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M2HD_mini_TriPod_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M2HD_mini_TriPod")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("TOW_TriPod_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ACE_M224")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M252_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("M252")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("MK19_TriPod_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("MK19_TriPod")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("2b14_82mm_CZ_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("2b14_82mm_GUE")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("2b14_82mm_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SearchLight_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SearchLight_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SearchLight_UN_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SearchLight_US_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SearchLight")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SPG9_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("SPG9_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("TOW_TriPod")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ZU23_CDF")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ZU23_TK_GUE_EP1")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ExA_RG31_M2")],

["US_WarfareBLightFactory_EP1", cfgvehiclestuff("ExA_RG31_Mk19")]

];

then lastly a buy.sqf:

_lbdata = lbdata [3002, lbcursel 3002];

if (_lbdata == "") exitwith {[playerside, "hq"] sidechat "No item selected"};

_item = buyarray select parsenumber _lbdata;

_near = nearestobjects [vehicle player, [_item select 0], 50];

if (count _near == 0) exitwith {};

currentselect = lbcursel 3002;

_neartype = typeof (_near select 0);

_offset = [0, 0];

_dir = 0;

_offset = _near select 0 modeltoworld [0, -25];

_dir = getdir (_near select 0) - 90;

_v = _item select 1 createvehicle _offset;

_v setdir _dir;

_v setpos getpos _v;

processInitCommands;

dooreveal = _v;

publicvariable "dooreveal";

_v call createreveal;

closedialog 3000;

i didnt create any of the original scripting seen here just basically edit it to suit the needs/ vehicles we are using at the time so when it comes to transferring it over to arma 3 i'm having issues to say the least my scripting knowledge is basic to say the least

Share this post


Link to post
Share on other sites

As much fun as it is to write complex scripts, having something that works is more fun. So I removed some parts so that I could get it working in a reasonable amount of time. I or someone else could add them back later if you really need them. I have got it working using these steps:

Create an object (I used a laptop) and place this in its init field:

this addAction ["Spawn Vehicle", "OpenVehicleDialog.sqf"];
this addEventHandler ["HandleDamage", {0}];

Then in the init.sqf, I have this:

#define STORECFG(x) [x, gettext (configfile >> "CfgVehicles" >> x >> "displayName") + " (" + gettext (configFile >> "CfgFactionClasses" >> gettext (configfile >> "CfgVehicles" >> x >> "faction") >> "displayName") + ")", gettext (configfile >> "CfgVehicles" >> x >> "picture")]

BuyArray = [
   STORECFG("B_quadbike_01_f"), 
   STORECFG("B_mrap_01_f")
];

BuyVehicle = {
   _lbdata = lbData [3002, lbCurSel 3002];
   if (_lbdata == "") exitwith {[playerSide, "hq"] sidechat "No item selected"};
   _item = BuyArray select (parseNumber _lbdata);

   _v =  createVehicle [(_item select 0), (getPosATL player), [], 5, "NONE"];
   closeDialog 3000;
};

I have the script file "OpenVehicleDialog.sqf", with contents like so:

if (dialog) exitwith {closeDialog 3000};
if !(createDialog "doodialog") exitwith {};
uiNamespace setVariable ["doolb", (finddisplay 3000 displayctrl 3002)];

private ["_i", "_index", "_item"];
for "_i" from 0 to (count BuyArray - 1) do {
   _item = BuyArray select _i;
   _index = (uiNamespace getVariable "doolb") lbAdd (_item select 1);
   (uiNamespace getVariable "doolb") lbSetData [_index, str _i];
   (uiNamespace getVariable "doolb") lbSetPicture [_index, _item select 2];
};
lbSetCurSel [3002, 0];

The description.ext is the same, except in class doolistbox, I added this statement:

colorDisabled[] = {0.95, 0.95, 0.95, 1};

This is tested and working well on dev branch. Changes include removing the factory entirely, altering and renaming the #define macro, changing classnames, and defining the buy function in the init.

Also, I had to remove 'processInitCommands' from what was 'buy.sqf', as that is no longer a command. There is also a public variable called 'dooreveal' that I removed. If there is some multiplayer issue that required those statements, I suggest looking in this function to replace them:

http://community.bistudio.com/wiki/BIS_fnc_MP

I hope that was what you needed, good luck with your mission.

Share this post


Link to post
Share on other sites

hey man right i got it past the issue i was having that i mentioned in the pm to ya seems i was missing a couple }; at the end, now issue im having is its listing the vehicles but not actually spawning em did you have a marker down as a set spawn point or is there somethin i got to add to 1 of the sqf's?

Edited by JamesonD

Share this post


Link to post
Share on other sites

I could not think of what was wrong (it was working for me), so I started over and followed my own steps exactly. When renaming the functions, I forgot to tell you to change what function the ok button called when you click on it. In the description.ext, in class doodialog.controls (near the end), there are two lines (one in doodialog.controls.mylistbox and one in doodialog.controls.okbutton, lines 82 and 89) that look like these:

onlbdblclick = "[] spawn doobuy";
...
onbuttonclick = "[] spawn doobuy";

'doobuy' is no longer a function. Those lines should be changed to use 'BuyVehicle' like so:

onlbdblclick = "[] spawn BuyVehicle";
..
onbuttonclick = "[] spawn BuyVehicle";

Sorry for missing that and causing confusion.

Share this post


Link to post
Share on other sites

its cool thanx again man

---------- Post added at 01:11 ---------- Previous post was at 00:12 ----------

its working perfectly man 1 last question is there anyway to change which way they spawn out facing & also a set distance from the spawn item?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×