Jump to content
  • 0

Deployable bike, scrollwheel issue


Bags2247

Question

OK guys, I've been trying to get this working... I can remove the bike but I can't get the bike to spawn... and I'm not sure exactly why..

 

I mean, EPOCH is all about the crafting, so I thought that this would be a good addon for my server, and as they don't save after restart,, it wouldn't clog up the DB with bikes either..

Now that bikes don't get a key from the traders either.... it just seemed like a logical step for the rebuilding storyline of EPOCH

 

Can someone point me in the right direction

// Bike //
if((speed player <= 1) && cursorTarget isKindOf "Old_bike_TK_CIV_EP1" && _canDo) then {
if (s_player_deploybike2 < 0) then {
        s_player_deploybike2 = player addaction[("<t color=""#007ab7"">" + ("Re-Pack Bike") +"</t>"),"spawnbike\bike2.sqf","",5,false,true,"", ""];
    };
} else {
    player removeAction s_player_deploybike2;
    s_player_deploybike2 = -1;
};
 
if((speed player <= 1) && _hasToolbox && _canDo) then {
    if (s_player_deploybike < 0) then {
        s_player_deploybike = player addaction[("<t color=""#007ab7"">" + ("Deploy Bike (will loose Toolbox)") +"</t>"),"spawnbike\bike.sqf","",5,false,true,"", ""];
    };
} else {
    player removeAction s_player_deploybike;
    s_player_deploybike = -1;
};

whats wrong here..

I mean, should it be on the scroll wheel or by right clicking on the toolbox..

When I right click the toolbox though, I get a "remove camo net" option..

 

So I figure that it means it should be on the scroll wheel instead..

 

Any suggestions would be appreciated

 

Bags

 

Link to comment
Share on other sites

Recommended Posts

  • 0

I guess your problem is that "_hasToolbox " is not yet defined in the  fn_selfActions.sqf file, just add this right before "if((speed player <= 1) && _hasToolbox && _canDo) then {" and it should work

_itemsPlayer = items player;
_hasToolbox = "ItemToolbox" in _itemsPlayer;

I also changed the deploy bike script so it can be cancelled like other action in epoch and it cannot be used to glitch into buildings anymore (which you can do with the default script because you carry the bike in front of you for some time)! If you want I can publish my changes here but first get it working :D

Link to comment
Share on other sites

  • 0

Ok here is my changed bike.sqf (re packing of bikes isn't changed so you can't abort that, but should be fine as most people on my server hit the "deploy bike" menu always by accident lol:

private ["_finished","_finishedTime","_posplr","_dirplr","_object"];

if (dayz_combat == 1) then {
    cutText [format["You are in Combat and cannot build a bike."], "PLAIN DOWN"];
} else {
	player removeAction s_player_deploybike;
	player removeWeapon "ItemToolbox";

	player playActionNow "Medic";
	[player,"repair",0,false,10] call dayz_zombieSpeak;
	[player,10,true,(getPosATL player)] spawn player_alertZombies;

	r_interrupt = false;
	r_doLoop = true;

	_finished = false;
	_finishedTime = diag_tickTime+3;

	while {r_doLoop} do {
		if (diag_tickTime >= _finishedTime) then {
			r_doLoop = false;
			_finished = true;
		};
		if (r_interrupt) then {
			r_doLoop = false;
		};
		sleep 0.1;
	};

	if (_finished) then {
		_posplr = [((getPos player) select 0) + 2, ((getPos player) select 1) + 2, 0];
		_dirplr = getDir player;

		_object = "Old_bike_TK_CIV_EP1" createVehicle (_posplr);
		_object setVariable ["ObjectID", "1", true];
		_object setVariable ["ObjectUID", "1", true];
		_object setVariable ["SpawnedBike",1,true];
		_object setVariable ["Sarge",1,true];

		player reveal _object;

		cutText [format["You've used your toolbox to build a bike."], "PLAIN DOWN"];
		sleep 10;
		cutText [format["Warning: Spawned Bikes DO NOT SAVE after server restart!"], "PLAIN DOWN"];
	} else {
		r_interrupt = false;
		player switchMove "";
		player playActionNow "stop";
		player addWeapon "ItemToolbox";
		cutText ["\n\nCanceled building a bike.", "PLAIN DOWN"];
	};
};

So you can just walk away while building a bike and get your toolbox back. Also the bikes get spawned somewhere around you to prevent glitching.. maybe not that pretty but there are to many player who abused that to het into player bases on my server! :/

 

And one more thing, I also added the variable "SpawnedBike" to the bike, and changed it in the fn_selfActions.sqf so you can only re-pack self spawned bikes and not spawned or bought ones form epoch, change it to this:

// ---------------------------------------Deployable Bike Start------------------------------------
_itemsPlayer = items player;
_hasToolbox = "ItemToolbox" in _itemsPlayer;
if (_canDo && (speed player <= 1) && _hasToolbox) then {
	if (s_player_deploybike < 0) then {
		s_player_deploybike = player addaction[("<t color=""#007ab7"">" + ("Deploy Bike (will use Toolbox)") +"</t>"),"spawnbike\bike.sqf","",5,false,true,"", ""];
	};
} else {
	player removeAction s_player_deploybike;
	s_player_deploybike = -1;
};

if (_canDo && (speed player <= 1) && cursorTarget isKindOf "Old_bike_TK_CIV_EP1" && (cursorTarget getVariable ["SpawnedBike",0] == 1)) then {
	if (s_player_deploybike2 < 0) then {
		s_player_deploybike2 = player addaction[("<t color=""#007ab7"">" + ("Re-Pack Bike") +"</t>"),"spawnbike\bike2.sqf","",5,false,true,"", ""];
	};
} else {
	player removeAction s_player_deploybike2;
	s_player_deploybike2 = -1;
};
// ---------------------------------------Deployable Bike End------------------------------------
Edited by Axe Cop
Link to comment
Share on other sites

  • 0

Awesome work there AXECOP.. fixing mine now..

 

 

 

I OWE you AXE COP... worked like a charm... I ended up using your script then... I never thought about the possibilty of someone using it to glitch into a base..

 

And followed your version of the selfactions as well..

 

NICE WORK THERE

Edited by Bags2247
Link to comment
Share on other sites

  • 0

When i get on the bike i die is there a fix?

There always is a fix! :D

You die because the game thinks you are a hacker because you've spawned in a bike :P

 

In my version I set the sarge variable to 1 ("_object setVariable ["Sarge",1,true];"), because thats what the Sarge AI uses and you don't need extra variables if you already use the Sarge AI:

Take a look at the installation instructions for Sarge AI https://github.com/Swiss-Sarge/SAR_AI, you only need the step "A2) Adjust your server_cleanup.fsm file for "Killed a hacker" fix".

Link to comment
Share on other sites

  • 0

I added this to our Overwatch server, got the server to spawn the bike should work in epoch:

Client side:

 

deployBike.sqf - activated by selfaction

player removeWeapon "ItemToolbox";
player playActionNow "Medic";
[player,"repair",0,false,10] call dayz_zombieSpeak;
[player,10,true,(getPosATL player)] spawn player_alertZombies;
sleep 6;
serverDepolyTempVehicle = ["Old_bike_TK_INS_EP1", player];
publicVariableServer "serverDepolyTempVehicle";

server_spawnTempVehicle.sqf

private ["_class", "_player", "_object", "_get_position"];
 
_class = _this select 0;
_player = _this select 1;
 
_get_position = {
private ["_offset", "_dir", "_player_position", "_position"];
_offset = _this select 0;
_dir = getDir (_this select 1);
_player_position = getPos (_this select 1);
_position = [(_player_position select 0) + (_offset * sin(_dir)), (_player_position select 1) + (_offset * cos(_dir)), 0];
_position;
};
 
_object = createVehicle [_class, ([5, _player] call _get_position), [], 0, "NONE"];
_object setVariable ["ObjectID",round(random 9999999),true];
_object setVariable ["ObjectUID",round(random 9999999),true];
_object setVariable ["deployed","1",true];
 
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor, _object];

server_functions.sqf

server_spawnTempVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnTempVehicle.sqf";
"serverDepolyTempVehicle" addPublicVariableEventHandler {
diag_log format["Spawn Temp Vehicle: %1", _this];
_id = (_this select 1) spawn server_spawnTempVehicle;
};

This might be of interest, add it to a right click on the toolbox 

http://dayzepoch.com/forum/index.php?/topic/4834-add-right-click-options-to-items/

Link to comment
Share on other sites

  • 0

Anyone know whats wrong with this?

 

//begin deployable bike
 
 
    if((speed player <= 1) && cursorTarget isKindOf "CSJ_GyroC" && _canDo) then {
if (s_player_deploybike6 < 0) then {
                s_player_deploybike6 = player addaction[("<t color="#007ab7"">" + ("Re-Pack GyroCopter") +"</t>"),"spawnbike\bike6.sqf","",5,false,true,"", "];
        };
} else {
        player removeAction s_player_deploybike6;
        s_player_deploybike6 = -1;
};
 
if((speed player <= 1) && cursorTarget isKindOf "TT650_Civ" && _canDo) then {
if (s_player_deploybike5 < 0) then {
                s_player_deploybike5 = player addaction[("<t color="#007ab7"">" + ("Upgrade to GyroCopter") +"</t>"),"spawnbike\bike5.sqf","",5,false,true,"", "];
        };
} else {
        player removeAction s_player_deploybike5;
        s_player_deploybike5 = -1;
};
 
if((speed player <= 1) && cursorTarget isKindOf "TT650_Civ" && _canDo) then {
if (s_player_deploybike4 < 0) then {
                s_player_deploybike4 = player addaction[("<t color="#007ab7"">" + ("Re-Pack Motorcycle") +"</t>"),"spawnbike\bike4.sqf","",5,false,true,"", "];
        };
} else {
        player removeAction s_player_deploybike4;
        s_player_deploybike4 = -1;
};
 
if((speed player <= 1) && cursorTarget isKindOf "Old_bike_TK_CIV_EP1" && _canDo) then {
if (s_player_deploybike3 < 0) then {
                s_player_deploybike3 = player addaction[("<t color="#007ab7"">" + ("Upgrade to Motorcycle") +"</t>"),"spawnbike\bike3.sqf","",5,false,true,"", "];
        };
} else {
        player removeAction s_player_deploybike3;
        s_player_deploybike3 = -1;
};
 
if((speed player <= 1) && cursorTarget isKindOf "Old_bike_TK_CIV_EP1" && _canDo) then {
if (s_player_deploybike2 < 0) then {
                s_player_deploybike2 = player addaction[("<t color="#007ab7"">" + ("Re-Pack Bike") +"</t>"),"spawnbike\bike2.sqf","",5,false,true,"", "];
        };
} else {
        player removeAction s_player_deploybike2;
        s_player_deploybike2 = -1;
};
 
if((speed player <= 1) && _hasToolbox && _canDo) then {
        if (s_player_deploybike < 0) then {
                s_player_deploybike = player addaction[("<t color="#007ab7"">" + ("Deploy Bike (will loose Toolbox)") +"</t>"),"spawnbike\bike.sqf","",5,false,true,"", "];
        };
} else {
        player removeAction s_player_deploybike;
        s_player_deploybike = -1;
};
Link to comment
Share on other sites

  • 0

 

Ok here is my changed bike.sqf (re packing of bikes isn't changed so you can't abort that, but should be fine as most people on my server hit the "deploy bike" menu always by accident lol:

private ["_finished","_finishedTime","_posplr","_dirplr","_object"];

if (dayz_combat == 1) then {
    cutText [format["You are in Combat and cannot build a bike."], "PLAIN DOWN"];
} else {
	player removeAction s_player_deploybike;
	player removeWeapon "ItemToolbox";

	player playActionNow "Medic";
	[player,"repair",0,false,10] call dayz_zombieSpeak;
	[player,10,true,(getPosATL player)] spawn player_alertZombies;

	r_interrupt = false;
	r_doLoop = true;

	_finished = false;
	_finishedTime = diag_tickTime+3;

	while {r_doLoop} do {
		if (diag_tickTime >= _finishedTime) then {
			r_doLoop = false;
			_finished = true;
		};
		if (r_interrupt) then {
			r_doLoop = false;
		};
		sleep 0.1;
	};

	if (_finished) then {
		_posplr = [((getPos player) select 0) + 2, ((getPos player) select 1) + 2, 0];
		_dirplr = getDir player;

		_object = "Old_bike_TK_CIV_EP1" createVehicle (_posplr);
		_object setVariable ["ObjectID", "1", true];
		_object setVariable ["ObjectUID", "1", true];
		_object setVariable ["SpawnedBike",1,true];
		_object setVariable ["Sarge",1,true];

		player reveal _object;

		cutText [format["You've used your toolbox to build a bike."], "PLAIN DOWN"];
		sleep 10;
		cutText [format["Warning: Spawned Bikes DO NOT SAVE after server restart!"], "PLAIN DOWN"];
	} else {
		r_interrupt = false;
		player switchMove "";
		player playActionNow "stop";
		player addWeapon "ItemToolbox";
		cutText ["\n\nCanceled building a bike.", "PLAIN DOWN"];
	};
};

So you can just walk away while building a bike and get your toolbox back. Also the bikes get spawned somewhere around you to prevent glitching.. maybe not that pretty but there are to many player who abused that to het into player bases on my server! :/

 

And one more thing, I also added the variable "SpawnedBike" to the bike, and changed it in the fn_selfActions.sqf so you can only re-pack self spawned bikes and not spawned or bought ones form epoch, change it to this:

// ---------------------------------------Deployable Bike Start------------------------------------
_itemsPlayer = items player;
_hasToolbox = "ItemToolbox" in _itemsPlayer;
if (_canDo && (speed player <= 1) && _hasToolbox) then {
	if (s_player_deploybike < 0) then {
		s_player_deploybike = player addaction[("<t color=""#007ab7"">" + ("Deploy Bike (will use Toolbox)") +"</t>"),"spawnbike\bike.sqf","",5,false,true,"", ""];
	};
} else {
	player removeAction s_player_deploybike;
	s_player_deploybike = -1;
};

if (_canDo && (speed player <= 1) && cursorTarget isKindOf "Old_bike_TK_CIV_EP1" && (cursorTarget getVariable ["SpawnedBike",0] == 1)) then {
	if (s_player_deploybike2 < 0) then {
		s_player_deploybike2 = player addaction[("<t color=""#007ab7"">" + ("Re-Pack Bike") +"</t>"),"spawnbike\bike2.sqf","",5,false,true,"", ""];
	};
} else {
	player removeAction s_player_deploybike2;
	s_player_deploybike2 = -1;
};
// ---------------------------------------Deployable Bike End------------------------------------

Ok so I see that you have a bike.sqf and a bike2.sqf ... but I only see 1 file to copy and paste here, can someone do a proper tutorial on this step by step?

Link to comment
Share on other sites

  • 0

What about this? http://dayz.st/w/Deployable_Bike/Motorcycle/GyroCopter

@Turtle my script wasn't supposed to be complete, it was just a change to add a delay when deploying a bike and the oruginil scril is posted like 1000 times on this forums and opendayz as well (because this is not the deploy bike topic but just to solve issues with it haha)..

but here you go,bike2.sqf:

if (dayz_combat == 1) then {
    cutText [format["You are in Combat and cannot re-build your bike."], "PLAIN DOWN"];
} else {
	player removeAction s_player_deploybike2;
	player playActionNow "Medic";
	r_interrupt = false;
	player addWeapon "ItemToolbox";
	deleteVehicle cursorTarget;

	[player,"repair",0,false,10] call dayz_zombieSpeak;
	[player,10,true,(getPosATL player)] spawn player_alertZombies;

	sleep 6;

	cutText [format["You have packed your bike and been given back your toolbox"], "PLAIN DOWN"];

	r_interrupt = false;
	player switchMove "";
	player playActionNow "stop";
};
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...