Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Laptop in Mayor Building
- Option to start bank heist
- Have to hold spot for 600 seconds
- Given X coins if still there at end
- */
- /*---------------------------------------------------------------------------
- Config
- ---------------------------------------------------------------------------*/
- p2h_objectPosition = [13715.8,2908.5,0.738091]; //Hackable Object World Positon (X,Y,Z)
- p2h_objectDirection = 181.245; //Hackable Object Direction (NESW)
- p2h_objectModelName = "RU_functionary2"; //Name of the laptop model
- p2h_objectActionText = "Rob The Mayor"; //Text on the scroll action of the laptop
- p2h_objectCollect = "Collect Funds"; //Text to display at end of hack on the laptop scroll action
- p2h_hackLengthMinutes = 10; //How long it takes to hack the bank
- p2h_hackRewardMinMax = [1000000,5000000]; //Hack reward min and max
- p2h_minPlayersToRun = 10; //Min player count on server before starting
- p2h_maxHackDistance = 50; //Max distance from the laptop the hacker can be before it gets cancelled
- p2h_minHackDistance = 5; //How close the player has to be to start and end the hack
- p2h_hackStartAnnouncement = "The mayor is being robbed!"; //Global message to display when someone starts robbing
- p2h_hackMidAnnouncement = "The mayor is still being robbed!"; //Global message to display when someone is half way through robbing
- p2h_hackEndAnnoucnement = "The mayor has been robbed!"; //Global message to display when someone finishes robbing
- p2h_hackerRanAway = "The mayors robber has ran away with out the money!"; //Global message to display when someone starts robbing and runs away
- p2h_hackerDied = "The mayors robber has died!"; //Global message to display when the hacker dies
- if (p2h_testMode) then {}
- p2h_hackLengthMinutes = 10;
- p2h_minPlayersToRun = 1;
- };
- p2h_init = {
- //Client Side
- if (!isDedicated && !isServer && hasInterface) exitWith {
- //Global var inits
- p2h_isHacking = 0;
- p2h_action = -1;
- p2h_hackProgress = 0;
- p2h_cStartHack = nil;
- p2h_sHackStarted = nil;
- //Client side files
- p2h_actionLoop = compile preprocessFileLineNumbers "p2h\p2h_actionLoop.sqf";
- p2h_getMoney = compile preprocessFileLineNumbers "p2h\p2h_getMoney.sqf";
- p2h_startHack = compile preprocessFileLineNumbers "p2h\p2h_startHack.sqf";
- p2h_endHack = compile preprocessFileLineNumbers "p2h\p2h_endHack.sqf";
- p2h_getMsg = compile preprocessFileLineNumbers "p2h\p2h_getMsg.sqf";
- //Start action loop
- [] spawn {
- while {true} do {
- call p2h_actionLoop;
- uiSleep 0.05;
- };
- };
- };
- //Server Side
- if (isServer) exitWith {
- };
- };
- //Start Hacking (Server-Side)
- p2h_serverStartHacking = {
- //Get player who started the hack
- _playerObj = objNull;
- _playerObj = _this;
- if (isNil '_playerObj') exitWith {};
- if (isNull _playerObj) exitWith {};
- //Get id to send msg to
- _playerId = owner _playerObj;
- if (isNil '_playerObj') exitWith {};
- if (_playerId < 1) exitWith {};
- //Start timer
- _timer = 0;
- _timer = p2h_hackLengthMinutes * 60;
- //Send message back to hacker to confirm hack has started
- p2h_sHackStarted = true;
- _playerId publicVariableClient "p2h_sHackStarted";
- p2h_sHackStarted = nil;
- //Send announcement
- p2h_hackMsg = p2h_hackStartAnnouncement;
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- //Track if player is alive/dead/ran away
- _quit = false;
- //if sent halfway msg
- _halfwayMsgSent = false;
- //every second
- while {true} do {
- uiSleep 1;
- _timer = _timer - 1;
- //player alive check
- if ((!alive _playerObj) || (isNull _playerObj)) exitWith {
- _quit = true;
- //Send announcement
- p2h_hackMsg = p2h_hackerDied;
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- };
- //player dist check
- if ((_playerObj distance p2h_objectPosition) > p2h_maxHackDistance) exitWith {
- _quit = true;
- //Send announcement
- p2h_hackMsg = p2h_hackerRanAway;
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- };
- //if we at the half way point
- _halfwayMsgSent = true;
- _halfway = 30;
- _halfway = p2h_hackLengthMinutes * 60;
- _halfway = _halfway / 2;
- _halfway = _halfway + 1;
- if ((_timer < _halfway) && !_halfwayMsgSent) then {
- //Send announcement
- _halfwayMsgSent = true;
- p2h_hackMsg = p2h_hackMidAnnouncement;
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- };
- //if we finished
- if (_timer < 1) exitWith {
- //Send message to players
- p2h_hackMsg = "The funds are ready to collect! You have 120 seconds before they expire!";
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- };
- };
- if (_quit) exitWith {
- };
- //Wait for player to send collect funds signal & check player doesnt run away or dies
- _newTimer = 120;
- while {true} do {
- uiSleep 1;
- _newTimer = _newTimer - 1;
- //player alive check
- if ((!alive _playerObj) || (isNull _playerObj)) exitWith {
- _quit = true;
- //Send announcement
- p2h_hackMsg = p2h_hackerDied;
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- };
- //player dist check
- if ((_playerObj distance p2h_objectPosition) > p2h_maxHackDistance) exitWith {
- _quit = true;
- //Send announcement
- p2h_hackMsg = p2h_hackerRanAway;
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- };
- //new timer check
- if (_newTimer < 1) exitWith {
- _quit = true;
- //Send announcement
- p2h_hackMsg = p2h_hackerRanAway;
- publicVariable "p2h_hackMsg"; p2h_hackMsg = nil;
- };
- //Wait for player to send collect funds signal & check player doesnt run away or dies
- };
- if (_quit) exitWith {
- };
- //Give funds to player
- //Send funds collected status to player
- //Reset timer
- //Reset object hack status
- //Send finished message to all
- };
- //Start hacking (Client-Side)
- p2h_startHack = {
- //Get input (the hack object)
- _hackObj = objNull;
- _hackObj = _this select 3;
- if (isNil '_hackObj') then {
- _hackObj = objNull;
- };
- if (isNull _hackObj) then {
- //Get object
- _objlist = [];
- _objlist = p2h_objectPosition nearObjects 5;
- _hackObj = objNull;
- {
- _obj = objNull;
- _obj = _x;
- if ((typeOf _obj) == p2h_objectModelName) then {
- _hackObj = _obj;
- };
- } forEach _objlist;
- };
- //Send message to server
- p2h_cStartHack = nil;
- p2h_cStartHack = player;
- publicVariableServer "p2h_cStartHack";
- //Wait for response message
- p2h_sHackStarted = nil;
- waitUntil{!isNil "p2h_sHackStarted"};
- //Set object status to being hacked
- _hackObj setVariable ["status", true, true];
- //Show message that hacking has begun and not to stray too far from the hack site
- systemChat(format["ROBBING STARTED! TIME LEFT: %1 Minutes", p2h_hackLengthMinutes]);
- systemChat(format["DO NOT MOVE MORE THAN %1m FROM HERE OR THE ROBBERY WILL END WITH NO REWARD.", p2h_minHackDistance]);
- };
- //Action Loop
- p2h_actionLoop = {
- //player info
- _isAlive = alive player;
- _playerPos = getPosATL player;
- _playerDist = (_playerPos distance p2h_objectPosition);
- //Get object
- _objlist = [];
- _objlist = p2h_objectPosition nearObjects 5;
- _hackObj = objNull;
- {
- _obj = objNull;
- _obj = _x;
- if ((typeOf _obj) == p2h_objectModelName) then {
- _hackObj = _obj;
- };
- } forEach _objlist;
- //Get if object is being robbed already
- _hackObjStatus = false;
- _hackObjStatus = _hackObj getVariable ["status", false];
- //Wait a sec to catch var
- sleep 0.1;
- //If player is close enough and not already hacking and objects not being robbed already
- if ((!(p2h_isHacking > 0)) && (_playerPos < p2h_minHackDistance) && (!_hackObjStatus)) then {
- if (p2h_action > -1) then {
- } else {
- //Add action
- p2h_action = player addAction [p2h_objectActionText, "p2h\p2h_startHackAction.sqf", _hackObj];
- };
- } else {
- //If action is displayed remove it
- if (p2h_action > -1) then {
- player removeAction p2h_action;
- };
- };
- };
- //Server Side
- //While server is running...
- while {true} do {
- player addAction ["Hint Hello!", { hint format ["Hello %1!", _this select 3] }, name player];
- };
Advertisement
Add Comment
Please, Sign In to add comment