Jump to content
  • 0

Script idea - drink red bull and fly


JakeQue

Question

Self exlanatory, think this would be a hilarious perk/mod to have on the server and give a reason for redbull to be so expensive.

 

on purchasing and drinking red bull it could make the player fly for x amount of seconds, I doubt adding wings to it would be possible but it would be funny if an eagle / hawk sound played and the player started flying Haha

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

@JakeQue  @Cherdenko   using noxisacrius flying.  using coke drink  cuz dont know the id for redbull. (you can add others drinks if u want)

 

1-create player_consume.sqf  in somewhere into mpmissions\instance\

Spoiler

/*
	Player action for consuming items
	
	Single parameter:
		string		item classname
	
	Author:
		Foxy
*/

#define PILE_SEARCH_RADIUS 2
#define PILE_PLAYER_OFFSET [0,1,0]

private ["_cfg","_nutrition","_bloodRegen","_infectionChance","_sound","_output","_hungerCount","_thirstCount","_soundDistance"];

_cfg = (ConfigFile >> "CfgMagazines" >> _this);

//class doesn't exist
if (!isClass(_cfg)) exitWith
{
	diag_log format ["DAYZ ERROR: Invalid magazine classname given to player_consume: %1", _this];
};

//class isn't a consumable
if (!isArray(_cfg >> "Nutrition")) exitWith
{
	diag_log format ["DAYZ ERROR: Non-consumable item classname given to player_consume: %1", _this];
};

//player is on a ladder
if ((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1) exitWith
{
	(localize "str_player_21") call dayz_rollingMessages;
};

//player doesn't have the consumable item
if (!(_this in magazines player)) exitWith
{
	(localize "str_player_33") call dayz_rollingMessages;
};

//close gear
(findDisplay 106) closeDisplay 0;

//if player is not in a vehicle play animation
if (vehicle player == player) then
{
	player playActionNow "PutDown";
};
_flyingdrinks = ["ItemSodaCoke"];
if(_this in _flyingdrinks) then {
flying2=true;
systemchat "time to fly";
};


//Remove consumed item
player removeMagazine _this;

//Get values from config
_nutrition = getArray (_cfg >> "Nutrition");
_bloodRegen = getNumber (_cfg >> "bloodRegen");
_infectionChance = getNumber (_cfg >> "infectionChance");
_sound = getText (_cfg >> "consumeSound");
_output = getText (_cfg >> "consumeOutput");

//Apply nutrition and blood regen
if (dayz_nutritionValuesSystem) then {
	_hungerCount = _nutrition select 1;
	_thirstCount = _nutrition select 2;
	
	if (_hungerCount > 0) then { dayz_lastMeal =	time; };
	if (_thirstCount > 0) then { dayz_lastDrink = time; };
	
	["FoodDrink",_bloodRegen,_nutrition] call dayz_NutritionSystem;
	r_player_foodstack = r_player_foodstack + 1;
} else {
	_hungerCount = _nutrition select 1;
	_thirstCount = _nutrition select 2;
	
	if (_hungerCount > 0) then { dayz_hunger = 0; dayz_lastMeal =	time; };
	if (_thirstCount > 0) then { dayz_thirst = 0; dayz_lastDrink = time; };
	
	r_player_blood = r_player_blood + _bloodRegen;
	
	if (r_player_blood > r_player_bloodTotal) then {
		r_player_blood = r_player_bloodTotal;
	};
};

//Apply or cure infection base on infectionChance
if (_infectionChance != 0 && {abs(_infectionChance) > random 1}) then
{
	if (_infectionChance > 0) then
	{
		r_player_infected = true;
		player setVariable["USEC_infected",true,true];
	}
	else
	{
		r_player_infected = false;
		player setVariable["USEC_infected",false,true];
	};
};

//Publish messing
player setVariable ["messing",[dayz_hunger,dayz_thirst,dayz_nutrition],false]; //No need to be sent to everyplayer
PVDZ_serverStoreVar = [player,"messing",[dayz_hunger,dayz_thirst,dayz_nutrition]]; //update server side only
publicVariableServer "PVDZ_serverStoreVar";

//Play sound and alert zombies
if (_sound != "") then
{
	private ["_soundDistance"];
	_soundDistance = getNumber (_cfg >> "consumeSoundDistance");
	
	[player,_sound,0,false,_soundDistance] call dayz_zombieSpeak;
	[player,_soundDistance,true,(getPosATL player)] call player_alertZombies;
};

//If item has a consumeOutput item defined add that to player
//inventory or ground/vehicle inventory based on consumedDrop
if (_output != "") then
{
	//if consumeDrop is false add output item to player inventory
	if (getNumber (_cfg >> "consumeDrop") == 0) then
	{
		player addMagazine _output;
	}
	//consumeDrop is true so drop the output item on the ground
	else
	{
		//if player is not in a vehicle drop output item on the ground
		if (vehicle player == player) then
		{
			//wait a while before dropping the output item
			uiSleep 3;
			//Drop Item to ground
			[_output,1,1] call fn_dropItem;
		};
	};
};

 

2-call it from your custom compiles.sqf

player_consume = compile preprocessFileLineNumbers "your\path\player_consume.sqf";

3-at bottom of init.sqf

call compile preprocessFileLineNumbers "your path\flying.sqf";

4-create flying.sqf in your path.

Spoiler

flying2=false;
waitUntil{flying2}; 

forwardAndBackward = 4; 
leftAndRight = 2;     
upAndDown = 5;         
distanceFromGround = 1; 
hovering = nil;
hoverPos = nil;

move_forward =
{
    if ((getPosATL (vehicle player) select 2) > distanceFromGround) then
    {
		_vehicle = (vehicle player);
		_vel = velocity _vehicle;
		_dir = direction _vehicle;
		_speed = 0.4; comment "Added speed";
		_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+
		(cos _dir*_speed),0.4];
    };
};

move_left =
{
    if ((getPosATL (vehicle player) select 2) > distanceFromGround) then
    {
        _leftDirection = getdir (vehicle player);
        (vehicle player) setdir (_leftDirection) - leftAndRight;
    };
};

move_backward =
{
    if ((getPosATL (vehicle player) select 2) > distanceFromGround) then
    {
		_vehicle = (vehicle player);
		_vel = velocity _vehicle;
		_dir = direction _vehicle;
		_speed = -0.4; comment "Added speed";
		_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+
		(cos _dir*_speed),0.4];
    };
};

move_right =
{
    if ((getPosATL (vehicle player) select 2) > distanceFromGround) then
    {
        _rightDirection = getdir (vehicle player);
        (vehicle player) setdir (_rightDirection) + leftAndRight;
        player setVariable["lastPos",1];player setVariable["lastPos",[]];
    };
};

move_up =
{    
	_vehicle = (vehicle player);
	_vel = velocity _vehicle;
	_dir = direction _vehicle;
	_speed = 6; comment "Added speed";
	_vehicle setVelocity [(_vel select 0),(_vel select 1),8];
};

move_down =
{
    if ((getPosATL (vehicle player) select 2) > distanceFromGround) then
    {
        _vehicle = (vehicle player);
        _forwardCurrentDirection = getdir (vehicle player);
        _forwardCurrentPosition = getPosATL (vehicle player);
        (vehicle player) setdir _forwardCurrentDirection;
        _vehicle setVelocity [0,0,-4];
    };
};

toggle_hover =
{
    if (isnil "hovering") then
    {
        hovering = true;
        titleText ["Hovering ON","PLAIN DOWN"]; titleFadeOut 4;
        hoverPos = getPosATL (vehicle player);
    }
    else
    {
        hovering = nil;
        titleText ["Hovering OFF","PLAIN DOWN"]; titleFadeOut 4;
        hoverPos = nil;
    };
};

if (flying2) then 
{
	

    keyForward = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 17) then {call move_forward;}"];     //W - Forward
    keyLeft = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 30) then {call move_left;}"];         //A - Left
    keyBackward = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 31) then {call move_backward;}"];     //S - Backward
    keyRight = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 32) then {call move_right;}"];         //D - Right
    keyUp = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 16) then {call move_up;}"];         //Q - Up
    keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 44) then {call move_down;}"];         //Z - Down
    keyHover = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 57) then {call toggle_hover;}"];     //SpaceBar - Toggle Hover
};
	

    

_countdown = true;
_maxSeconds = 10;
_seconds = 0;

while {flying2} do
{
    if (!isNil "hovering") then
    {
		(vehicle player) setvelocity [0,0,0.2];
    };
if (_seconds >= _maxSeconds) exitWith {
systemchat "timeover";
hovering = nil;
hoverPos = nil;
flying2 = false;
(findDisplay 46) displayRemoveEventHandler ["KeyDown", keyForward];
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", keyLeft];
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", keyBackward];
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", keyRight];
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", keyUp];
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", keyDown];
    (findDisplay 46) displayRemoveEventHandler ["KeyDown", keyHover];
};

_seconds = _seconds + 1;
  sleep 1;
};

hovering = nil;
hoverPos = nil;
flying2 = false;

 

 

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