English Fuel station robbery system

  • Auteur de la discussion Auteur de la discussion I'm the Boss
  • Date de début Date de début

I'm the Boss

Leader
Membre du personnel
2/1/20
701
3
44
1 100
This tutorial allows you to add a fully customizable and functional gas stations system!​
___

1 - Installation of the system in the mission

In your function.hpp file, add below file = "core\actions"; this :
class robSystem {};

In the folder core\actions, create a file fn_robSystem.sqf and put the code below in it :
Code:
#include "..\..\script_macros.hpp"
/*
    Author: Jean- Baptiste for The Programmer Forum

    Description : gas station robbery
*/
params [
    ["_shop",ObjNull],
    ["_robber",ObjNull],
    ["_action",-1]
];

/*========Configuration=========*/
_number_cop = 0; //Minimum number of police officers to be able to rob
_add_interpol = true; //Add or not the crime in the interpol
_marker_create = true; //Creation of a marker
_money_fix = 5000; //Fixed money collected
_blocked_time = 300; // Time before the next robbery
_money_random = 20000; //Random money received + fixed money
_time = 90; //Time of the robbery
_temps_atm = 5; //Time before the robber can deposit his money in the ATM (in minutes)
/*=============================*/

if (side _robber != civilian) exitWith {hint "You must be a civilian !"};
if ((west countSide playableUnits) < _number_cop) exitWith {hint "There are not enough policemen !"};
if (_robber distance _shop > 5) exitWith {hint "You are too far away (5m max !"};
if (vehicle player != _robber) exitWith {hint "You have to get out of your vehicle !"};
if !(alive _robber) exitWith {};
if (currentWeapon _robber isEqualTo "") exitWith {hint "You need a gun to rob !"};
if (_shop getVariable ["robbery_progress",false]) exitWith {hint "There's already a robbery in progress"};

_exit = false;
_money = _money_fix + round (random _money_random);
_title = _shop actionParams _action;
_shop removeAction _action;
_shop setVariable ["robbery_progress",true,true];

_fn_create_Marker = {
    _action = _this select 0;
    _shop = _this select 1;
    _marker = createMarker [format ["marker_var_%1",_action], _shop];
    _marker setMarkerColor "ColorRed";
    _marker setMarkerText "WARNING: ROBBERY IN PROGRESS !";
    _marker setMarkerType "mil_warning";
};

if ((random 100) >= 50) then {
    [1,"ROBBERY ALERT : A silent alarm has just been triggered at a gas station !"] remoteExec ["life_fnc_broadcast",west];
    [_action,_shop] call _fn_create_Marker;
};

disableSerialization;

"progressBar" cutRsc ["life_progress","PLAIN"];
_ui = uiNamespace getVariable "life_progress";
_progress = _ui displayCtrl 38201;
_pgText = _ui displayCtrl 38202;
_pgText ctrlSetText "Robbery in progress stay close ! (5m) (1%)...";
_progress progressSetPosition 0.01;
_cP = 0.01;

if (_marker_create) then {
    [_action,_shop] call _fn_create_Marker;
};

for "_i" from 0 to 1 step 0 do {
    uiSleep (_time / 100);

    _cP = _cP + 0.01;
    _progress progressSetPosition _cP;
    _pgText ctrlSetText format ["Robbery in progress stay close ! (5m)  (%1%2)...",round (_cP * 100), "%"];

    if (_cP >= 1) exitWith {};
    if (_robber distance _shop > 5) exitWith {_exit = true};
    if (!alive _robber) exitWith {};
    if (_robber getVariable "restrained") exitWith {_exit = true};
    if (life_istazed) exitWith {_exit = true};                                
};

if (_exit) exitWith {
    "progressBar" cutText ["","PLAIN"];
    hint "The store was closed and the police were notified !";
    [1,format["A person just tried to steal a gas station !",_robber,name _robber, _shop]] remoteExec ["life_fnc_broadcast",west];

    playSound3D ["A3\Sounds_F\sfx\alarm_independent.wss", _robber];
    deleteMarker format ["marker_var_%1",_action];
    _shop setVariable ["robbery_progress",false,true];

    if (_add_interpol) then {
        [getPlayerUID _robber, _robber getVariable ["realname", name _robber], "211"] remoteExecCall ["life_fnc_wantedAdd", RSERV];
    };
};

"progressBar" cutText ["","PLAIN"];
titleText[format["You stole %1 $, now run away before the police arrive !",[_money] call life_fnc_numberText], "PLAIN"];
playSound3D ["A3\Sounds_F\sfx\alarm_independent.wss", _robber];
[1, format["News : A Gas Station has just been robbed of %1 $",[_money] call life_fnc_numberText]] remoteExec ["life_fnc_broadcast", west];

if (_add_interpol) then {
    [getPlayerUID _robber, _robber getVariable ["realname",name _robber], "211"] remoteExecCall ["life_fnc_wantedAdd", RSERV];
};

life_cash = life_cash + _money;
call SOCK_fnc_updatePartial;
deleteMarker format ["marker_var_%1",_action];
_shop setVariable ["robbery_progress",false,true];

[_shop,_title,_blocked_time] spawn {
    sleep (_this select 2);
    (_this select 0) addAction [((_this select 1) select 0),life_fnc_robSystem];
};

sleep (_temps_atm * 60);
life_use_atm = true;
___
2 - Installation of the system in the map
  • Create an object or a PNG and put in the init this line:
Code:
this addAction["Rob the gas station",life_fnc_robSystem];

You can configure the system by changing lines 13 to 21


Congratulations! You have just finished the installation of the script, don't hesitate to ask me your questions !​
 
Dernière édition par un modérateur:
Pour éviter que le joueur puisse braquer sans munition ou avec des jumelles:
Remplacer la ligne 29 par

Code:
if ((player ammo (currentWeapon player)) isequalto 0) exitwith {hint "you need a weapon with ammo"};
 
Dernière édition par un modérateur:
Pour éviter que le joueur puisse braquer sans munition ou avec des jumelles:
Remplacer la ligne 29 par

If (ammo weapon player isequalto 0) exitwith{hint "you need a weapon with ammo"};


Can not work normally
 
Pour éviter que le joueur puisse braquer sans munition ou avec des jumelles:
Remplacer la ligne 29 par

If (ammo weapon player isequalto 0) exitwith{hint "you need a weapon with ammo"};


2020/03/04, 23:45:55 Error in expression <};if!(alive _robber) exitWith{};If(ammo weapon player isequalto 0) exitwith{hint>
2020/03/04, 23:45:55 Error position: <weapon player isequalto 0) exitwith{hint>
2020/03/04, 23:45:55 Error Missing )
2020/03/04, 23:45:55 File core\actions\fn_robSystem.sqf [life_fnc_robSystem]..., line 34
2020/03/04, 23:45:55 Error in expression <};if!(alive _robber) exitWith{};If(ammo weapon player isequalto 0) exitwith{hint>
2020/03/04, 23:45:55 Error position: <weapon player isequalto 0) exitwith{hint>
2020/03/04, 23:45:55 Error Missing )
2020/03/04, 23:45:55 File core\actions\fn_robSystem.sqf [life_fnc_robSystem]..., line 34
 
if (ammo weapon _robber == "") exitWith { hint "HaHa, vous ne me menacez pas ! Sors d'ici, clochard !" };

essye ceci, sa fonction niquel pour moi

edit: j'avais pas vue en faisant copier coller merci Maxence Maxence
 
Dernière édition:
Bonjour je cherche comment ajouté une fonction ou la police est prévenue comme il y a un braquage en cours car il pence pas a regarder la carte un message qui s'affichent au haut a gauche de l’ecrent
 
Bonjour je cherche comment ajouté une fonction ou la police est prévenue comme il y a un braquage en cours car il pence pas a regarder la carte un message qui s'affichent au haut a gauche de l’ecrent
Tu dois regarder du côté des remoteExec
Tu peux remote un hint sur le side blufor. Tu insert la ligne dans le script de vol de station