Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // jahangir13: 12/2014 - Personal Player Bike v0.2
- // (jahangir@gmx.de)
- // Personal bike for players (temporarily spawned). Can be packed/unpacked.
- // PlayerUID is stored with the bike, so you can only pack your own bike.
- // If packed, overall damage is remembered and uniformly assigned to bike if unpacked again.
- //
- // Place script into the mission folder (or custom folder within the mission folder)
- // Code to copy and instructions at end of file (init.sqf / fn_selfActions.sqf / battleye / Antihack)
- //
- private ["_zedAttractDist", "_distToPlayer", "_packUnpackTime", "_keepDamage", "_degrees", "_getOnBikeDirectly", "_ownername", "_location", "_positionBike", "_playerdir", "_bike"];
- //#################################################################################################################
- // Config options to change
- _zedAttractDist = 30; // distance in meter zombies get attracted
- _distToPlayer = [0,4,1]; // distance of spawned bike in front of player (4 meter, 1m above)
- _packUnpackTime = 8; // time to pack/unpack in seconds
- _keepDamage = true; // remember overall bike damage
- _degrees = 40; // degrees of the angle the bike has in relation to the player (easier to get the menu with angle)
- _getOnBikeDirectly = true; // player hops onto the bike directly as driver after unpacking
- // No need to change anything below
- //#################################################################################################################
- if ( dayz_combat == 1 ) exitWith { cutText [format["You cannot pack/unpack the bike while in combat!"], "PLAIN DOWN"] };
- if (r_player_unconscious) exitWith { cutText [format["You cannot get a bike while unconscious!"], "PLAIN DOWN"] };
- // part: unpack player bike
- if (_this select 3 == "unpack") then {
- s_playerHadBike = false;
- {
- _ownername = _x getVariable["Ownername", "nil"];
- if ( _ownername == getPlayerUID player ) exitWith {
- s_playerHadBike = true;
- };
- } count (player nearEntities [["MMT_Civ"], 25000]);
- // exit if already unpacked
- if ( s_playerHadBike ) then {
- cutText [format["Your bike is already unpacked!"], "PLAIN DOWN"];
- breakOut "leaveScript";
- };
- // spawn in front of player, 4m distance
- _location = [];
- _location = (getPosATL player) findEmptyPosition [2,8,"MMT_Civ"];
- // if no suitable position found, message the player
- if ( count _location == 0 ) then {
- cutText [format["No suitable position found. Look for more space."], "PLAIN DOWN"];
- breakOut "leaveScript";
- };
- // in front of the player where he was looking when executing the command
- _positionBike = player modelToWorld _distToPlayer;
- // get direction of player at executing the command
- _playerdir = getDir player;
- player removeAction s_player_unpackbike;
- player playActionNow "Medic";
- // attract zombies
- [player,"repair",0,false,_zedAttractDist] call dayz_zombieSpeak;
- [player,_zedAttractDist,true,(getPosATL player)] spawn player_alertZombies;
- sleep _packUnpackTime;
- _bike = createVehicle ["MMT_Civ", _location, [], 0, "CAN_COLLIDE"];
- _bike setVariable ["MalSar",1,true];
- // assign bike to player (playeruid)
- _bike setVariable["Ownername", (getPlayerUID player), true];
- // set damage (uniformly distributed)
- if (_keepDamage) then {
- _bike setDammage s_bikeDamage;
- };
- // set position and direction
- _bike setVehiclePosition [_positionBike, [], 0];
- _bike setDir (_playerdir - _degrees);
- player reveal _bike;
- cutText [format["Unpacked the bike"], "PLAIN DOWN"];
- player switchMove "";
- player playActionNow "stop";
- // Get player on bike as driver
- if ( _getOnBikeDirectly ) then {
- player moveInDriver _bike;
- };
- s_playerHadBike = true;
- };
- // part: pack player bike
- if (_this select 3 == "pack") then {
- // only the own bike (playeruid in variable Ownername) can be packed
- _ownername = cursorTarget getVariable["Ownername", "nil"];
- if ( _ownername != getPlayerUID player ) exitWith { cutText [format["This is not your bike, you cannot pack it!"], "PLAIN DOWN"] };
- _bike = cursorTarget;
- if (typeOf _bike == "MMT_Civ") then {
- if ( _keepDamage ) then {
- s_bikeDamage = getDammage _bike;
- };
- _bike setVariable["Ownername", nil, true];
- player removeAction s_player_packbike;
- player playActionNow "Medic";
- // Attract zombies
- [player,"repair",0,false,_zedAttractDist] call dayz_zombieSpeak;
- [player,_zedAttractDist,true,(getPosATL player)] spawn player_alertZombies;
- sleep _packUnpackTime;
- deletevehicle _bike;
- cutText [format["Packed the bike"], "PLAIN DOWN"];
- player switchMove "";
- player playActionNow "stop";
- s_playerHadBike = false;
- } else {
- cutText [format["Look at the bike to re-pack it!"], "PLAIN DOWN"];
- };
- };
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Variable initialization: Place somewhere at end of init.sqf in the mission (or where you initialize variables normally).
- /* copy from below line
- // jahan - begin player bike
- s_playerHadBike = false;
- s_player_unpackbike = -1;
- s_player_packbike = -1;
- s_bikeDamage = 0;
- // check for existing player bike
- {
- _ownername = _x getVariable["Ownername", "nil"];
- if ( _ownername == getPlayerUID player ) exitWith {
- s_playerHadBike = true;
- };
- } count (player nearEntities [["MMT_Civ"], 25000]);
- // jahan - end player bike
- copy until above line */
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // fn_selfAction.sqf part: Place somewhere at the beginning (change 2 paths to point to player_bike.sqf script (here custom\jtools\)!)
- /* copy from below line
- ///// ################ jahan - Begin Player Bike ########################################
- if ((speed player < 1) && !(player isKindOf "PZombie_VB") && _canDo && !_inVehicle ) then {
- ///// unpack bike addaction:
- if( ( isNull cursorTarget ) ) then {
- if ((s_player_unpackbike < 0) && (!s_playerHadBike)) then {
- s_player_unpackbike = player addAction [("<t color=""#DF01D7"">" + ("Unpack Bike") +"</t>"),"custom\jtools\player_bike.sqf","unpack",-1,false,true,"", ""];
- };
- } else {
- player removeAction s_player_unpackbike;
- s_player_unpackbike = -1;
- };
- ///// pack bike addaction:
- if ( !(isNull cursorTarget) && (player distance cursorTarget < 3) && (typeOf cursorTarget == "MMT_Civ") ) then {
- if ((s_player_packbike < 0) && ( s_playerHadBike )) then {
- s_player_packbike = player addAction [("<t color=""#DF01D7"">" + ("Pack Bike") +"</t>"),"custom\jtools\player_bike.sqf","pack",-1,false,true,"", ""];
- };
- } else {
- player removeAction s_player_packbike;
- s_player_packbike = -1;
- };
- };
- ///// ################ jahan - End Player Bike ########################################
- copy until above line */
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Battleye: (if you don't want/need damage comment out the damage lines and don't add this to the BE filters)
- /* If kicked by Battleye script restriction (setDammage):
- Find the line:
- 5 "setDammage"
- and add this at the end:
- !="_bike setVariable[\"Ownername\", _playeruid, true];"
- So that it looks like this:
- 5 "setDammage" !="_bike setVariable[\"Ownername\", _playeruid, true];"
- */
- /* If killed when sitting on the bike:
- Add the classname of the bike (MMT_Civ) to the array in your custom variables.sqf:
- DZE_safeVehicle = ["ParachuteWest","ParachuteC","MMT_Civ" ];
- or at the init.sqf player bike lines (but after variables.sqf is called)
- DZE_safeVehicle = DZE_safeVehicle + ["MMT_Civ"];
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement