Jump to content

[Tutorial] MrKraken's ATM Robbery Script


Recommended Posts

Just now, Dave650 said:

@StonerGaming At the bottom you added [getPlayerUID _robber,name _robber,"211"]remoteExec["life_fnc_wantedAdd",false,false] , Shouldn't it be [getPlayerUID _robber,name _robber,"211"] remoteExec ["life_fnc_wantedAdd",2]; To make the guy wanted? 

its not my script, I updated it

Link to post
Share on other sites
  • 1 month later...
  • 3 years later...
On 3/13/2017 at 3:37 AM, SimZor - Frogman Life said:

Hi,

Made a up-to-date script which shall work, may have a bug or two since I made this at 4 in the morning and a bit tired, but just let me know if there is any problems. But generally should be more reliable.

Make sure to redefine variables to your liking and make sure to put command hint in your RemoteExec whitelist. Please do not remove the header! :)

/**
    * SimZor 2017
    * [email protected]
    * Everyone allowed to use script as long as this header stays in place
*/

// -- Get Parameters from action
_this params [
    ["_atm", objNull, [objNull]],
    ["_robber", player, [objNull]],
    ["_action"]
];

// -- Define these options please!
private _amount = 20000; // -- Amount which will be the base which the players will always get minimum
private _randomMoney = 30000; // -- Define amount that should be randomized
private _cooldown = 200; // -- Cooldown until ATM can be robbed again after already being robbed
private _atmPlayAnimation = false; // -- Player Shop Animation (NPC)
private _atmAnimation = "AmovPercMstpSsurWnonDnon"; // -- Define animation to be played
private _alarmPercentage = 80; // -- Percent change that alarm will go off and send a message to police
private _messageOnlyBlufor = true; // -- Set to false if everyone should be notified of the gas station robbery
private _neededBluforUnits = 3; // -- Define blufor units required to carry out robbery
private _cashvariable = life_cash;

// -- Checks
if !(side _robber isEqualTo civilian) exitWith {};
if !(vehicle player isEqualTo _robber) exitWith {};
if (_robber distance _atm > 2) exitwith {};
if !(alive _robber) exitWith {};
if (life_inv_boltcutter <= 0) exitWith {};
private _bluforUnits = (west countSide playableUnits);
if (_bluforUnits < 2) exitWith {};

// -- Remvoe Option from NPC or other object
_atm removeAction _action;

// -- Switch move if applicable
if (_atmPlayAnimation) then {
    _atm playMove _atmAnimation;
};

// -- Notify Authorities if there is _alarmPercentage chance
if (random 100 >= _alarmPercentage) then {
    // -- Get Closest Town
    text (nearestLocations [player, ["NameCityCapital","NameCity","NameVillage"], 10000]) params ["_closestTown"];

    // -- Notify player
    hint "Alarm has been triggered, authorities has been notified";

    // -- Send message to notify all targets
    private _broadcastTargets = if (_messageOnlyBlufor) then {west} else {-2};
    [format parseText ["<t font='PuristaMedium' align='center'>WARNING</t><br/><t font'PuristaLight'>There is currently an ATM being robbed at %1. Nearest town is %2. Check your map for more information!</t>", getPos _atm, _closestTown]] remoteExecCall ["hint", _broadcastTargets];

    // -- Create Marker
    private _marker = createMarker ["ATM_Robbery_Marker", position player];
    "ATM_Robbery_Marker" setMarkerColor "ColorRed";
    "ATM_Robbery_Marker" setMarkerText "ATM Robbery in Progress";
    "ATM_Robbery_Marker" setMarkerType "mil_warning";
};

// -- Disable Serialization
disableSerialization;

// -- Create Resource and Setup Variables
"ATM_Robbery" cutRsc ["life_progress", "PLAIN"];
private _ui = uiNameSpace getVariable "life_progress";
private _progress = _ui displayCtrl 38201;
private _pgText = _ui displayCtrl 38202;

// -- Set Default Values
_pgText ctrlSetText format ["Breaking into ATM [1%1]", "%"];
_progress progressSetPosition 0.01;

private _cP = 0.01;
private _success = false;
while {true} do {

    sleep 0.01;
    _cP = _cP + 0.0001;

    // -- Update Values
    _progress progressSetPosition _cP;
    _pgText ctrlSetText format ["Breaking into ATM [%1%2]", round (_cP * 100), "%"];

    // -- Checks
    if (_cp >= 1) exitWith {_success = true;};
    if (_robber distance _atm > 2.5 || {!alive _robber}) exitWith {};

};

// -- Remove Progress Bar
"ATM_Robbery" cutText ["","PLAIN"];

// -- Reset animation
_atm switchMove "";

// -- Delete robbery marker
deleteMarker "ATM_Robbery_Marker";

if (_successfull) then {
    // -- Set amount to give player if successfull
    private _amount = _amount + round (random _amount);

    // -- Add cash to player
    _cashvariable = _cashvariable + _amount;

    // -- Notify
    hint format ["You have successfully broken into the ATM and stolen"];

    // -- Make spawn here so rest of script can still continue
    [] spawn {
        scriptName "life_fnc_robATM: ATM Handler";

        life_use_atm = false;
        sleep (60 + random(180));
        life_use_atm = true;
    };
};

// -- Add to wanted list
[getPlayerUID _robber, name _robber, "211"] remoteExec ["life_fnc_wantedAdd",2];

// -- Handle Cooldown
[_action, _atm] spawn {
    scriptName "life_fnc_robATM: ATM Cooldown Handler";

    // -- Wait
    sleep _cooldown;

    // -- Add action to ATM once again
    _action = _atm addAction ["Break into ATM", life_fnc_robATM];
};

 

Do it work on 5.0 ?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.