Jump to content

Deploy bike from Dyna menu


Schalldampfer

Recommended Posts

As I could not find a maintained "deploy bike" script for A3 Epoch, I have created one myself. 
Thanks for G-Dog for assisting my scripting

*Deploy vehicle from dyna menu (Space key menu)
*Pack vehicle from dyna menu while looking at it
*You can define any vehicle to spawn 
*The vehicle is spawned server side (not saved in the hive, but theoretically possible)
*No animation like DayZ Epoch's "deploy anything" for now (but theoretically possible with client side modification)

https://github.com/Schalldampfer/DeployBike4A3E

first version hidden below

  Reveal hidden contents


--
Edit 

BE filter:
in the end of the 1st line of publicvariable.txt :
 !="Deploy_SpawnVehicle" !="Deploy_PackVehicle"

Edited by Schalldampfer
Github
Link to comment
Share on other sites

Couple of questions:

(1) Why not put the server side code in an addon PBO so that you or others do not have to make changes to epoch_server.pbo every time an update is released?

(2) Why make the deployed vehicles persist through a restart? People will just leave bikes all over the map decreasing server performance over time.

(3) Why not check that the target class is the deployed vehicle for the pack option in the dynamenu... otherwise the option to pack will be given for all vehicles.

(4) You should probably add the BE filters for the pubvars for completeness

Hope this is helpful.

Link to comment
Share on other sites

Personally I use the server side UD addon and call a script clientside that checks whether certain requirements are met to be able to deploy a bike or mozzie, for example:

if ("epochz_ToolKit" in (items player)) then {
	if ("VehicleRepair" in (magazines player)) then {
		player removeMagazine "VehicleRepair";
		titleText ["", "PLAIN DOWN"];
		player playActionNow "Medic";
		_spawnPos = player modelToWorld [0,2,0];
		_spawnDir = (getDir player) -90;
		UD_BIKE = [player, _spawnPos, _spawnDir];
		sleep 3;
		publicVariableServer "UD_BIKE";
		sleep 1;
		['You have spawned a bike. It will be gone at restart!',0,0.7,2,0] spawn bis_fnc_dynamictext;
		player removeAction deploybike;
	}
	else {
		['You need Vehicle Repair Parts to craft a bike!',0,0.7,2,0] spawn bis_fnc_dynamictext;
	};
} else {
	['You need a Toolkit to craft a bike!',0,0.7,2,0] spawn bis_fnc_dynamictext;
};	

And then for packing:

obj1 = _this select 0;
_unit = _this select 1;
_action = _this select 2;
_unit removeAction _action;

_deletetime = 8;

_unit playMove "AinvPknlMstpSlayWnonDnon_medic";

//DO NOT CHANGE
sleep _deleteTime;
deleteVehicle obj1;
_unit addMagazine "VehicleRepair";
deploybike = _unit addAction ["<t color=""#00CF11"">" +"Deploy Bike","custom\deploy_bike.sqf","",1,false,false,"",""];

 

Link to comment
Share on other sites

Thank you for your advice, I'll try it if I update it.(Currently I'm busy at making AI cities)


(1)server side update
I thought I'll include checks for deploying vehicle in server side (not implemented for now)
(such as community stat (?), donor and admin)


(2)vehicle to be persistent through restart
I haven't made it saved for now.
It can be also used for deploying garage (though it's also not implemented in Virtual Garage in A3 Epoch, and may be done by modifing building settings),
that must be static and persistent.
And I don't know it's really necessary, but can be an option.


(3)pack vehicles not deployed
No problem, the vehicle has an variable about its owner, (which will be "-1" for non-deployed vehicles).  
I'm cheking it in the server script.

  Quote

 _vehObj setvariable ["EPOCH_DeployOwner",_puid];//set puid as owner

Expand  
  Quote

if ((_vehObj getVariable ["EPOCH_DeployOwner","-1"]) == _puid) then {//check owner

Expand  

 

(4)BE filter
oops, I forgot it.I'll add it later. there's at least 2 public variables 

  Quote

!="Deploy_SpawnVehicle" !="Deploy_PackVehicle"

Expand  

 

A reason why I dont use addAction is, the scroll-menu action tend to mulfunction dyna menu.
when I push space key, both the dyna menu and scroll menu opens and dyna menu die with leaving fog effects. (I was using an scroll menu action that spawn silent hint of server rule)

Link to comment
Share on other sites

(1) I'm just suggesting putting the scripts in a separate PBO rather than in epoch_server. If you need a hand on that then let me know. Will be happy to help.

(2) The line 

    _vehObj call EPOCH_server_vehicleInit;

will, iirc, make the vehicle persistent.

(3) My point was more changing the condition line to something like:

    condition = "dyna_isVehicle && ((crew dyna_cursorTarget) isEqualTo []) && (dyna_cursorTarget iskindof 'MBK_01_EPOCH')";

So that that option only shows in the dynamenu for deployed vehicles.

Also, deployed vehicles should be removed from the trader price lists or players will spam them for cash

Link to comment
Share on other sites

To clarify: The line

    _vehObj call EPOCH_server_setVToken;

ensures that the vehicle will not be deleted when a player gets near to it and is required to be run for all vehicles spawned by script.

The line 

        _vehObj call EPOCH_server_vehicleInit;

sets event handlers on the vehicle that will add it into the save vehicle queue for saving into the database (assuming slots are available)

Link to comment
Share on other sites

  On 7/24/2018 at 2:38 PM, Grahame said:

(1) I'm just suggesting putting the scripts in a separate PBO rather than in epoch_server. If you need a hand on that then let me know. Will be happy to help.

(2) The line 

    _vehObj call EPOCH_server_vehicleInit;

will, iirc, make the vehicle persistent.

(3) My point was more changing the condition line to something like:

    condition = "dyna_isVehicle && ((crew dyna_cursorTarget) isEqualTo []) && (dyna_cursorTarget iskindof 'MBK_01_EPOCH')";

So that that option only shows in the dynamenu for deployed vehicles.

Also, deployed vehicles should be removed from the trader price lists or players will spam them for cash

Expand  

thanks for replying,
(1) I'll try it, I found some scripts doing that, so I'll imitate them.
(2) thanks for noticing, I'll check the init function and copy some codes in it.
(3) thanks, I'll try it.
      I have removed the vehicle from spawning and trader list
     (I think it's good to change Deploy_vehicle array to include playerUID instead of vehicles and check puid to prevent duplicates)
 

 

--P.S.--
I'll use GitHub for further updates, to log what was changed

Link to comment
Share on other sites

If you like I can send my server side addon and scripts for you to look at for ideas. I like the direction you are going and you've made a fine start on this. 

You can really just remove the EPOCH_server_vehicleInit line without issues all it does is ensure that a persistent vic writes its death into the Vehicle Killed table in the database and is added to the save queue

Yeah, more important in your case, using the dynaMenu to avoid people just spawning things over and over again. In my case I use an addAction for the scroll wheel and remove it when they spawn one and add it back when they repack it

Link to comment
Share on other sites

  On 7/31/2018 at 9:34 AM, megaz said:

Hi Schalldampfer, I installed this as per instructions but i don't see a deploy menu when i push space bar does the player need anything in inventory to spawn the bike ?

thanks

MegaZ

Expand  

no. I think you failed to edit epoch_config\Configs\CfgActionMenu\CfgActionMenu_self.hpp .

Link to comment
Share on other sites

I Added that see below:

CfgActionMenu_self

  Reveal hidden contents

and CfgActionMenu_target

  Reveal hidden contents

im using infastar dont know if that would stop it ?

Link to comment
Share on other sites

  On 7/31/2018 at 11:59 AM, megaz said:

I Added that see below:

CfgActionMenu_self

  Reveal hidden contents

and CfgActionMenu_target

  Reveal hidden contents

im using infastar dont know if that would stop it ?

Expand  

why you included it in another codes?
it must be out of the brackets. I said, it's at bottom.

 (In this case, you'll see the deploy command in the menu of something about radiation, which appear when you have ItemGeigerCounter_EPOCH.)

 

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

×
×
  • Create New...