Jump to content
  • 0

Quick and simple "starter crate"


boxman80

Question

Recommended Posts

  • 0
Hey, I've written a simple script for something like that, maybe you can make use of it.
It works like that: you run the script (I run it with the BluePhoenix admin tools), then you carry the box in front of you for 5 seconds and it gets placed wherever it is then. Simple, but sufficient for my purpose. :)
 
_crate = "USVehicleBox" createVehicle (position player);
_crate setVariable ["Mission",1,true];

clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;

// add weapons
_crate addWeaponCargoGlobal ["ItemToolbox", 5];
_crate addWeaponCargoGlobal ["ItemSledge", 5];
// add items
_crate addMagazineCargoGlobal ["PartPlankPack", 10];
_crate addMagazineCargoGlobal ["PartPlywoodPack", 10];
_crate addMagazineCargoGlobal ["CinderBlocks", 10];
_crate addMagazineCargoGlobal ["MortarBucket", 10];
_crate addMagazineCargoGlobal ["PartGeneric", 10];

_crate attachto [player, [0,3,1.7]];
sleep 5;
detach _crate;
player reveal _crate;
I'm using a "USVehicleBox" (a big ammo box), you can change that to a smaller box or whatever "vehicle" you want (keep in mind that the vehicle isn't blacklisted in the BattleEye filter createvehicle.txt).
 
The setVariable "Mission" is needed to bypass vehicle removal by the server (i am using the side mission script so i can use the missions variable, you can change it so "Sarge" if you are using Sarga AI). If you're not using Sarge AI or the side mission you may have to add an exception to the server file so it won't get removed by the server after a while (anti cheat protection...).
 
For adding weapons and other items just take a look at my example entries with building stuff ["ItemName", count].
 
If you want to use it and need more help getting it to work, just ask me.
Link to comment
Share on other sites

  • 0

How does this work? and how do i get it to spawn infront of me, can i use mysql to spawn this?

Well you could also do it with the Database like with any other vehicle but then the box will stay forever (until someone destroys it) and you will need a restart to load it into the world.

 

With my script you just spawn the box in front of you in realtime whereever you are in the game, it will be removed after a server restart but it should be enough time to give players the gear so they can store it a safe or whereever they like. On my server we use this for dynamic admin events where we spawn the box in and defend it so players can get it, or hide it somewhere and players have to find it :)

Link to comment
Share on other sites

  • 0

Well you could also do it with the Database like with any other vehicle but then the box will stay forever (until someone destroys it) and you will need a restart to load it into the world.

 

With my script you just spawn the box in front of you in realtime whereever you are in the game, it will be removed after a server restart but it should be enough time to give players the gear so they can store it a safe or whereever they like.

Yeah but how do i launch the script? i want an admin box full of building materials. How do i spawn the box? do i need the admin tools?

Link to comment
Share on other sites

  • 0

You don't need the admin tools but that would make it easier to include scripts like that only admins can use..

if you want I can add another solution to the run the script with the self_actions menu (like self bloodbag)

If so, only let a specific GUID/UID use it, and if possible make it so you can cancel it. Also, how do i find the UID? is it the same as GUID?

Link to comment
Share on other sites

  • 0

If so, only let a specific GUID/UID use it, and if possible make it so you can cancel it. Also, how do i find the UID? is it the same as GUID?

It will check your Player ID (UID), I don't think you can access the GUID from ingame. Your UID is displayed ingame in the player profile (here is a screenshot if cou cant find it: http://bullnet.org/images/faq/playerid/edit.jpg)

And yes there is a way to cancel it but that requires way more code in the script and I haven't figured it all out yet as it isn't that easy to do that in ArmA, maybe someone else can add that part or I may add it later. :D

 

Give me 5 minutes to script the menu for the self_actions menu, I assume you already have a custom fn_selfActions.sqf in your mission.pbo, if not you need to change some other files, too. :/

Link to comment
Share on other sites

  • 0

It will check your Player ID (UID), I don't think you can access the GUID from ingame. Your UID is displayed ingame in the player profile (here is a screenshot if cou cant find it: http://bullnet.org/images/faq/playerid/edit.jpg)

And yes there is a way to cancel it but that requires way more code in the script and I haven't figured it all out yet as it isn't that easy to do that in ArmA, maybe someone else can add that part or I may add it later. :D

 

Give me 5 minutes to script the menu for the self_actions menu, I assume you already have a custom fn_selfActions.sqf in your mission.pbo, if not you need to change some other files, too. :/

I do have a custom fn_selfActions.sqf and thanks for doing this, is it possible to have it set so if you have a special item in your inventory and you are that player UID you can spawn the crate? like a flare or smoke grenade or something. and it uses up the item in the process

Link to comment
Share on other sites

  • 0

Yeah I can add something like that so it uses an item, for now here is the addition for the self_actions:

if ((getPlayerUID player) in ["12345678"]) then { // list of admin UID's who can use the script
	if (_canDo && (speed player <= 1)) then {
		if (s_player_spawnBox < 0) then {
			s_player_spawnBox = player addaction [("<t color=""#007ab7"">" + ("Spawn Box") +"</t>"),"scripts\spawn_box.sqf","",5,false,true,"",""];
		};
	} else {
		player removeAction s_player_spawnBox;
		s_player_spawnBox = -1;
	};
};

Add that code to your fn_selfActions.sqf, after the line "_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);"

 

Just change the UID (12345678) to your UID, you can add more admins if you like ["12345678","12345678","12345678",...]

If you stand still ingame there should be a blue option "Spawn Box", if you select that it will run the script "scripts\spawn_box.sqf" (inside a subfolder scripts, you can change it to your needs). The file "spawn_box.sqf" contains the code from my first anwer. :)

 

Test the code like this, if it works I can add a few lines so it uses an item from your gear if you want that :D

Link to comment
Share on other sites

  • 0

This might be a stupid question, but let go anyway.

 

I added this to my server, but battleye kicked me as I had expected. I am not running side missions or Sarge AI, so I assumed that I had to create an exception in createvehicle.txt.

Then I noticed that USVehicleBox is not there, should it then be necessary to create an exception?

 

I've not had much to do with Battleye as I'm pretty new to DayZ servers, but I always assumed that a Battleye filter had to be present in the filter files, else it would just not look for it at all. Am I wrong?

 

Edit

Never mind, figured out how it worked. The line about box didn't exclude USVehicleBox. Now a different question. Is it safe to allow USVehicleBox?  :o

Link to comment
Share on other sites

  • 0

I tried using the script with multiple options by doing the following:

if ((getPlayerUID player) in ["########"]) then { // list of admin UID's who can use the script
if (_canDo && (speed player <= 1)) then {
        if (s_player_spawnBox < 0) then {
            s_player_spawnBox = player addaction [("<t color=""#007ab7"">" + ("Spawn Building Supplies") +"</t>"),"scripts\spawn_bbox.sqf","",5,false,true,"",""];
            s_player_spawnBox = player addaction [("<t color=""#007ab7"">" + ("Spawn Explosives") +"</t>"),"scripts\spawn_ebox.sqf","",5,false,true,"",""];
            s_player_spawnBox = player addaction [("<t color=""#007ab7"">" + ("Spawn Medical Supplies") +"</t>"),"scripts\spawn_mbox.sqf","",5,false,true,"",""];
            s_player_spawnBox = player addaction [("<t color=""#007ab7"">" + ("Spawn Starter Supplies") +"</t>"),"scripts\spawn_sbox.sqf","",5,false,true,"",""];
            s_player_spawnBox = player addaction [("<t color=""#007ab7"">" + ("Spawn Vehicle Supplies") +"</t>"),"scripts\spawn_vbox.sqf","",5,false,true,"",""];
        };
    } else {
        player removeAction s_player_spawnBox;
        s_player_spawnBox = -1;
    };
};

Unfortunately, the blue options don't disappear like they did when I had a single script option. They also appear multiple times and spam my scroll menu.

 

It looks like its only closing the last option (Spawn Vehicle Supplies) and leaving the rest of them open.

 

Is there a way I could prevent this or perhaps create a sub-menu?

 

Thanks,

 

Rick

Link to comment
Share on other sites

  • 0

I would change 's_player_spawnBox' for each box...so 's_player_spawnMedBox' and so on.

Make your scripts reflect this, since your script should be setting s_player_spawnBox to 1 while the script is in use and when it completes, it sets it to -1.

I'd also put removeAction in the start of the script it calls, so you cant call it again until the first one has finished.

 

Hope that helps

Link to comment
Share on other sites

  • 0

I've got this working with a couple of crates/box on our server. Does anyone know why the boxes float in the air and if there's a way to put them on the floor properly?

 

Thanks.

set the z-position to 0 after you have placed the crate?

_crate setPosATL [(getPosATL _crate) select 0, (getPosATL _crate) select 1, 0];

try that (not tested) :)

Link to comment
Share on other sites

  • 0

set the z-position to 0 after you have placed the crate?

_crate setPosATL [(getPosATL _crate) select 0, (getPosATL _crate) select 1, 0];

try that (not tested) :)

It sometimes works for a split-second then bounces back to around chest/head height.

Oh well, it's not a deal-breaker or anything, worth a shot. Thanks for trying.

Link to comment
Share on other sites

  • 0

Hi Guys,

thats what i do on my servers: A group with 3 or more Players get a Starting Package which includes:

Once:

1 UAZ (fully upgraded + key)

1 ComboLock
1 CinderGarageKit
1 Safe
1 WorkbenchKit
1 OuthouseKit

And per Player:

1 AK47 with 3 Mags
1 AlicePack
1 WoodStair
1 MetalFloorKit
2 HalfCinderWalls

 

Ive modified the Spawn a Vehicle With Key Script to accomplish this.

 

It looks like this:

 

startkit.sqf:

private ["_veh","_location","_isOk","_vehtospawn","_part_in","_qty_in","_qty","_obj","_objectID","_objectUID","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","","_textPartIn","_textPartOut"];
 
_vehtospawn = "UAZ_Unarmed_TK_CIV_EP1_DZE4"; 
 _charID = dayz_characterID;
 _dir = getdir vehicle player;
 _pos = getPos vehicle player;
 _pos = [(_pos select 0)+8*sin(_dir),(_pos select 1)+8*cos(_dir),0];
 _worldspace = [_dir,_pos];
 _num = _this select 0;
 _number = parseNumber _num;
 
cutText ["Starting Spawn, stand still to complete spawn.", "PLAIN DOWN"];
 
// First select key color
_keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom;
 
// then select number from 1 - 2500
_keyNumber = (floor(random 2500)) + 1;
 
// Combine to key (eg.ItemKeyYellow2494) classname
_keySelected = format[("ItemKey%1%2"),_keyColor,_keyNumber]; 
 
_isKeyOK =  isClass(configFile >> "CfgWeapons" >> _keySelected);
 
_config = _keySelected;
_isOk = [player,_config] call BIS_fnc_invAdd;
waitUntil {!isNil "_isOk"};
if (_isOk and _isKeyOK) then {
 
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
_dir = round(random 360);
 
_location = _pos;
 
//place vehicle spawn marker (local)
_veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"];
 
_location = (getPosATL _veh);
 
PVDZE_veh_Publish2 = [_veh,[_dir,_location],_vehtospawn,false,_keySelected];
publicVariableServer  "PVDZE_veh_Publish2";
player reveal _veh;

sleep 5;
_veh = getPos player nearestObject _vehtospawn;
//Startkit for the Group
_veh addMagazineCargoGlobal ["ItemComboLock",1];
_veh addMagazineCargoGlobal ["cinder_garage_kit",1];
_veh addMagazineCargoGlobal ["Itemvault",1];
_veh addMagazineCargoGlobal ["workbench_kit",1];
_veh addMagazineCargoGlobal ["outhouse_kit",1];
_veh addMagazineCargoGlobal ["30m_plot_kit",1];
//Startkit per Player
_veh addWeaponCargoGlobal   ["AKS_74_kobra",1*_number];
_veh addMagazineCargoGlobal ["30Rnd_545x39_AK",3*_number];
_veh addMagazineCargoGlobal ["ItemWoodStairs",1*_number];
_veh addMagazineCargoGlobal ["metal_floor_kit",1*_number];
_veh addMagazineCargoGlobal ["cinder_wall_kit",2*_number];
_veh addBackpackCargoGlobal ["DZ_ALICE_Pack_EP1",1*_number];

cutText [format[("Spawned Starterkit for %1 Players - Key added to toolbelt."),_number,_qty_in,_textPartIn,_textPartOut], "PLAIN DOWN"];
 
} else {
cutText ["You do not have enough room on your toolbelt.", "PLAIN DOWN"];
};

You Access The Script With an Admin Menu (like in BluePhoenix) like this:

		["Spawn StarterKit", [2], "#USER:StarterkitMenu", -5, [["expression", ""]], "1", "1"],

and the StarterKit Menu:

	    ["3 Players", [2], "", -5, [["expression", '["3"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],
		["4 Players", [3], "", -5, [["expression", '["4"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],
		["5 Players", [4], "", -5, [["expression", '["5"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],
		["6 Players", [5], "", -5, [["expression", '["6"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],
		["7 Players", [6], "", -5, [["expression", '["7"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],
		["8 Players", [7], "", -5, [["expression", '["8"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],
		["9 Players", [8], "", -5, [["expression", '["9"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],
		["10 Players", [9], "", -5, [["expression", '["10"] execVM "admintools\tools\startkit.sqf"']], "1", "1"],

Of course u are able to modify the things the players get in the startkit.sqf but watch out that there are enough inventory slots in the car, otherwise it will drop to the ground!

 

The Vehicle i selected got 100 Magazine Slots!

 

hf

Link to comment
Share on other sites

  • 0

Axe Cop (or whoever can help), I've been trying to add a crate of loot to an AI area. I've been using this script I found on here:  (scroll down a bit) But the crates are getting removed after a little while. I notice you add  _crate setVariable ["Mission",1,true]; to keep this crate from getting removed from the vehicle removal script. Could that be added to the script I'm using too? To keep it in place? something like: _this setVariable ["Mission",1,true]; 

 

Thanks in advance,

-Silk

Link to comment
Share on other sites

  • 0

Using DZAI, so with that in mind would this work: _this setVariable ["DZAI",1,true]; 

 

And while I'm at it, where would someone find where the "mission" variable is defined? I poked around in a few of the init.sqf (mission and server function) and didn't see it. I'm familiar with other languages, but still learning how SQF is setup. 

 

thanks,

-Silk

Link to comment
Share on other sites

  • 0

Great! what is this? some sort of escape or break from the server_update func for any object with that var defined? 

 

if (_object getVariable "Mission" == 1) exitWith {};

 

And this, in the server_cleanup, an exception in the if statement - "&& (vehicle _x getVariable [""Mission"",0] != 1) &&"

 

if so I'll be using this again!

 

huge thanks Axe!

Link to comment
Share on other sites

  • 0

Great! what is this? some sort of escape or break from the server_update func for any object with that var defined? 

 

if (_object getVariable "Mission" == 1) exitWith {};

 

And this, in the server_cleanup, an exception in the if statement - "&& (vehicle _x getVariable [""Mission"",0] != 1) &&"

 

if so I'll be using this again!

 

huge thanks Axe!

Yeah don't do the above, doesn't work and broke my missions. This does work - _crate setVariable ["permaLoot",1,true];

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

×
×
  • Create New...