Jump to content
  • 0

Deploy Bike - Create Vehicle Positioning


steamROLLER

Question

if (false) then {
    cutText [format["You are in combat and cannot build a bike."], "PLAIN DOWN"];
} else {
    player removeAction s_player_deploybike;
    closeDialog 602;
    player removeWeapon "ItemToolbox";
    player playActionNow "Medic";
    r_interrupt = false;
    _dis=10;
    _sfx = "repair";
    [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
    [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
   
    sleep 6;
   
    _object = "Old_bike_TK_INS_EP1" createVehicle (position player);
    _object setVariable ["ObjectID", "1", true];
    _object setVariable ["ObjectUID", "1", true];
   
    player reveal _object;

    cutText [format["You have built a bike!  You can re-pack bike at any time. "], "PLAIN DOWN"];
   
    r_interrupt = false;
    player switchMove "";
    player playActionNow "stop";
   
    sleep 10;
   
    cutText [format["Warning: Spawned bikes DO NOT SAVE after server restart!"], "PLAIN DOWN"];
   
};

Everyone,

 

Need some help with a positioning issue when deploying bike in-game.  It's spawning the bike behind the player rather than in front.  Sometimes they deploy bike in woods and a object behind them (e.g. tree) will be in the way causing it to spawn 20m  from player.  I would like for it to spawn in front of player every time.  Shown above is the current deploy bike script I use.

 

 

 

 

 

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0
if (false) then {
    cutText [format["You are in combat and cannot build a bike."], "PLAIN DOWN"];
} else {
    player removeAction s_player_deploybike;
    closeDialog 602;
    player removeWeapon "ItemToolbox";
    player playActionNow "Medic";
    r_interrupt = false;
    _dis=10;
    _sfx = "repair";
    [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
    [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
   
    sleep 6;
   
    _object = "Old_bike_TK_INS_EP1" createVehicle (position player);
    _object setVariable ["ObjectID", "1", true];
    _object setVariable ["ObjectUID", "1", true];
   
    player reveal _object;

    cutText [format["You have built a bike!  You can re-pack bike at any time. "], "PLAIN DOWN"];
   
    r_interrupt = false;
    player switchMove "";
    player playActionNow "stop";
   
    sleep 10;
   
    cutText [format["Warning: Spawned bikes DO NOT SAVE after server restart!"], "PLAIN DOWN"];
   
};

Everyone,

 

Need some help with a positioning issue when deploying bike in-game.  It's spawning the bike behind the player rather than in front.  Sometimes they deploy bike in woods and a object behind them (e.g. tree) will be in the way causing it to spawn 20m  from player.  I would like for it to spawn in front of player every time.  Shown above is the current deploy bike script I use.

 

 

Probably just best off doing:

_object = "Old_bike_TK_INS_EP1" createVehicle [0, 0, 0];
_object setPosASL (getPosASL player);

_object setVariable ["ObjectID", "1", true];
_object setVariable ["ObjectUID", "1", true];

player moveInDriver _object;
player reveal _object;
Link to comment
Share on other sites

  • 0

I use this bit of magic to position something directly in front of the player-

_position = [(((getPos player) select 0) + (DIS * (sin(getDir player)))),(((getPos player) select 1) + (DIS * (cos(getDir player)))),0];

Where DIS is the distance in front of the player you want it to spawn.

 

If you wanna understand sin/sine and cos/cosine check here.

Link to comment
Share on other sites

  • 0

Mikeeyy,  I've tried your and it works but the player is standing up on the bike when riding and not doing any animation.  It fixes if u get off and back on bike but is there a strip of code to enter the driver seat of bike correctly rather than standing?

 

 

Kat, yours moved the bike to the front right of the player when deploying out in open field, which is better than spawning behind the player but still the bike is 20m away on tree line when deploying in middle of woods.

 

 

CordIAsis your didn't work.  I don't know if I added it correctly though.

Link to comment
Share on other sites

  • 0

Still need a little help anyone.  Having the player spawn on the bike caused another issue where exploiters are deploying the bike near base walls and its putting player on the bike and bike spawns on opposite of base wall inside of another players base.

 

I'm looking for it to deploy the bike exactly in front of the player every time.  It keeps spawning randomly around the player and if the player is currently in the woods, it sometimes spawns the bike on the edge of the tree line no where near the player.  Any suggestions?  I've tried "attachTo" and it's not helping very much or I don't have the positioning correct.   I also don't know where to add the strip of code Axis provided above in this thread.

Link to comment
Share on other sites

  • 0
if (false) then {
    cutText [format["You are in combat and cannot build a bike."], "PLAIN DOWN"];
} else {
    player removeAction s_player_deploybike;
    closeDialog 602;
    player removeWeapon "ItemToolbox";
    player playActionNow "Medic";
    r_interrupt = false;
    _dis=10;
    _sfx = "repair";
    [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
    [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
   
    sleep 6;
   
    _object = "Old_bike_TK_INS_EP1" createVehicle (position player);
    _object setVariable ["ObjectID", "1", true];
    _object setVariable ["ObjectUID", "1", true];
   
    player reveal _object;

    cutText [format["You have built a bike!  You can re-pack bike at any time. "], "PLAIN DOWN"];
   
    r_interrupt = false;
    player switchMove "";
    player playActionNow "stop";
   
    sleep 10;
   
    cutText [format["Warning: Spawned bikes DO NOT SAVE after server restart!"], "PLAIN DOWN"];
   
};

Everyone,

 

Need some help with a positioning issue when deploying bike in-game.  It's spawning the bike behind the player rather than in front.  Sometimes they deploy bike in woods and a object behind them (e.g. tree) will be in the way causing it to spawn 20m  from player.  I would like for it to spawn in front of player every time.  Shown above is the current deploy bike script I use.

 

i use this 

_dis=10;
_sfx = "repair";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
_object = "Old_bike_TK_INS_EP1" createVehicle (position player);
_object setVariable ["malsar",1,true];
_uniqueid = str(round(random 999999));
_object setVariable ["ObjectID", _uniqueid, true];
_object setVariable ["ObjectUID", _uniqueid, true];
clearMagazineCargo _object;
clearWeaponCargo _object;
player reveal _object;
_obj = vehicle _object;   
player moveInDriver _obj;
player action ["getInDriver", _obj]; 
Link to comment
Share on other sites

  • 0

SadBoy,

 

As I mentioned before, I've used the MoveInDriver line before but since the bike randomly spawns around the player sometimes if next to a base wall the player can exploit and spawn on bike inside someones base.  Have u not had this happen yet?

No, maybe try this

_dis=2;
_sfx = "repair";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
_object = "Old_bike_TK_INS_EP1" createVehicle (position player);
_object setVariable ["malsar",1,true];
_uniqueid = str(round(random 999999));
_object setVariable ["ObjectID", _uniqueid, true];
_object setVariable ["ObjectUID", _uniqueid, true];
clearMagazineCargo _object;
clearWeaponCargo _object;
player reveal _object;

where _dis=2; is in metters  from getPosATL player

 

without sit on bike, just spawn near

 

or you can try to use this code

// Location of player and crate
_dir = getdir player;
_pos = getposATL player;
_pos = [(_pos select 0)+1*sin(_dir),(_pos select 1)+1*cos(_dir), (_pos select 2)];

if(_LocalOrGlobal == "local") then {
	_spawnCrate = _classname createVehicleLocal _pos;	
} else {
	_spawnCrate = createVehicle [_classname, _pos, [], 0, "CAN_COLLIDE"];
};

_spawnCrate setDir _dir;
_spawnCrate setposATL _pos;

This code from admin tools where u create tent in front of you. Here is full code

 

private ["_LocalOrGlobal","_spawnCrate","_crateName","_pos","_classname","_dir","_selectDelay"];
_LocalOrGlobal = _this select 0;

// Name of this crate
_crateName = "Backpack Tent";

// Crate type
_classname = "TentStorageDomed2";

// Tool use logger
if(logMajorTool) then {
	usageLogger = format["%1 %2 -- has spawned a %3 %4",name player,getPlayerUID player,_LocalOrGlobal,_crateName];
	[] spawn {publicVariable "usageLogger";};
};
// Tool use broadcaster
if(!((getPlayerUID player) in SuperAdminList) && broadcastToolUse) then {
	useBroadcaster = format["%1 -- has spawned a %2 %3",name player,_LocalOrGlobal,_crateName];
	[] spawn {publicVariableServer "useBroadcaster";};
};

// Location of player and crate
_dir = getdir player;
_pos = getposATL player;
_pos = [(_pos select 0)+1*sin(_dir),(_pos select 1)+1*cos(_dir), (_pos select 2)];

if(_LocalOrGlobal == "local") then {
	_spawnCrate = _classname createVehicleLocal _pos;	
} else {
	_spawnCrate = createVehicle [_classname, _pos, [], 0, "CAN_COLLIDE"];
};

_spawnCrate setDir _dir;
_spawnCrate setposATL _pos;

// Remove default items/weapons from current crate before adding custom gear
clearWeaponCargoGlobal _spawnCrate;
clearMagazineCargoGlobal _spawnCrate;
clearBackpackCargoGlobal _spawnCrate;

_spawnCrate addBackpackCargoGlobal ["DZ_Backpack_EP1", 1];
_spawnCrate addBackpackCargoGlobal ["DZ_British_ACU", 1];
_spawnCrate addBackpackCargoGlobal ["DZ_CivilBackpack_EP1", 1];
_spawnCrate addBackpackCargoGlobal ["DZ_CompactPack_EP1", 1];
_spawnCrate addBackpackCargoGlobal ["DZ_GunBag_EP1", 1];
_spawnCrate addBackpackCargoGlobal ["DZ_LargeGunBag_EP1", 1];
_spawnCrate addBackpackCargoGlobal ["DZ_TK_Assault_Pack_EP1", 1];

// Send text to spawner only
titleText [format[_crateName + " spawned!"],"PLAIN DOWN"]; titleFadeOut 4;

selectDelay=0;
// Run delaymenu
delaymenu = 
[
	["",true],
	["Select delay", [-1], "", -5, [["expression", ""]], "1", "0"],
	["", [-1], "", -5, [["expression", ""]], "1", "0"],
	["30 seconds", [], "", -5, [["expression", "selectDelay=30;"]], "1", "1"],
	["1 min", [], "", -5, [["expression", "selectDelay=60;"]], "1", "1"],
	["3 min", [], "", -5, [["expression", "selectDelay=180;"]], "1", "1"],
	["5 min", [], "", -5, [["expression", "selectDelay=300;"]], "1", "1"],
	["10 min", [], "", -5, [["expression", "selectDelay=600;"]], "1", "1"],
	["30 min", [], "", -5, [["expression", "selectDelay=1800;"]], "1", "1"],
	["", [-1], "", -5, [["expression", ""]], "1", "0"],
	["No timer", [], "", -5, [["expression", "selectDelay=0;"]], "1", "1"],
	["", [-1], "", -5, [["expression", ""]], "1", "0"]
];
showCommandingMenu "#USER:delaymenu";

WaitUntil{commandingMenu == ""};
_selectDelay = selectDelay;

if(selectDelay != 0) then {
	titleText [format[_crateName + " will disappear in %1 seconds.",selectDelay],"PLAIN DOWN"]; titleFadeOut 4;
	sleep _selectDelay;
	// Delete crate after selectDelay seconds
	deletevehicle _spawnCrate;
	titleText [format[_crateName + " disappeared."],"PLAIN DOWN"]; titleFadeOut 4;
} else {
	titleText [format[_crateName + " has no timer. Shoot it to destroy."],"PLAIN DOWN"]; titleFadeOut 4;
};

Link to comment
Share on other sites

  • 0
                _type = "Old_bike_TK_INS_EP1";
                _pos = getPos player;
                _dir = getDir player;
                _infrontdist = 2;
                _object = createVehicle [_type,[(_pos select 0)+_infrontdist*sin(_dir),(_pos select 1)+_infrontdist*cos(_dir),0],[], 0, "CAN_COLLIDE"];
                _object setVariable ["ObjectID", _objectID, true];
                _object setVariable ["ObjectUID", _objectID, true];
                _object addEventHandler ["GetIn",{
                    _nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: This vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
                }];

                clearWeaponCargoGlobal _object;
                clearMagazineCargoGlobal _object;
                _object setVehicleAmmo 0;
                _object allowDamage false;
                player reveal _object;
                player moveInDriver _object;
                player action ["getInDriver", _object];

                cutText ["\n\nYou've built a bike!", "PLAIN DOWN"];

I use this. If it helps anybody.

 

Features

  • God Mode Bike
  • Spawns Infront Of player
  • AUtomatic Warning message when get inside
  • Automatic Get in Driver Seat
Link to comment
Share on other sites

  • 0

Gr8,

 

Much appreciate buddy!  I know you an I had a fall out once on a different topic regarding Custom Kill Messages but man your the first to actually show me what I was specifically looking for.   I took a piece out of your script and added it in mine and it spawns the bike right in front of player perfectly! 

 

Fully Updated - Bike Deploy Script v2.0

if (false) then {
    cutText [format["You are in combat and cannot build a bike."], "PLAIN DOWN"];
} else {
    player removeAction s_player_deploybike;
    closeDialog 602;
    player removeWeapon "ItemToolbox";
    player playActionNow "Medic";
    r_interrupt = false;
    _dis=10;
    _sfx = "repair";
    [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
    [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
   
    sleep 6;
   
    _type = "Old_bike_TK_INS_EP1";
    _pos = getPos player;
    _dir = getDir player;
    _infrontdist = 2;
    _object = createVehicle [_type,[(_pos select 0)+_infrontdist*sin(_dir),(_pos select 1)+_infrontdist*cos(_dir),0],[], 0, "CAN_COLLIDE"];
    _object setVariable ["ObjectID", _objectID, true];
    _object setVariable ["ObjectUID", _objectID, true];
  
	player reveal _object;


    cutText [format["You have built a bike!  You can re-pack bike at any time. "], "PLAIN DOWN"];
   
    r_interrupt = false;
    player switchMove "";
    player playActionNow "stop";
   
    sleep 10;
   
    cutText [format["Warning: Spawned bikes DO NOT SAVE after server restart!"], "PLAIN DOWN"];
   
};

//steamROLLER's Bike Deploy Script v2.0
Link to comment
Share on other sites

  • 0

I would suggest some changes to that.

The problem with above script is that you cannot interrupt the animation and if you were to interrupt then your toolbox would disappear without a bike.

 

also using this method below is the best to warn anyone that builds/finds this bike.

_object addEventHandler ["GetIn",{
                    _nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: This vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
}];
Link to comment
Share on other sites

  • 0

Gr8,

 

I have a warn message in my script about it disappearing.  Maybe not for someone else to find the bike, but everyone starts with a toolbox so really no need for them to find someone elses bike.   Now for the interruption, I'll look into that, I haven't quite decided if I want them to have the ability to interrupt or not yet.

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...