Jump to content
suffer4real

[Tutorial] Jail time [4.4r3]

Recommended Posts

hello,
before you start on this you should create a back up


Source: Altisliferpg.com (cache recovery)

first off run this query

ALTER TABLE  `players` ADD (`jail_time` int(11) NOT NULL DEFAULT '0');


add these 2 lines under jail_sys in config.cpp this is located in your life_server


class jailTimer {};
class jailPlayer {};

it should look something like this :

 

class Jail_Sys {
 file = "\life_server\Functions\Jail";
 class jailSys {};
 class jailTimer {};
 class jailPlayer {};
 };



create a file called fn_JailPlayer.sqf

#include "\life_server\script_macros.hpp"
/*
 Sets jail values for player
*/
private["_player", "_playeruid", "_query", "_time"];
_player = _this select 0;
_playeruid = _this select 1;
_time = _this select 2;
_time = ceil _time; //to be sure
_player = owner _player;
_query = format["UPDATE players SET arrested='1', jail_time='%1' WHERE playerid='%2'", _time, _playeruid];
[_query,1] call DB_fnc_asyncCall;



create a file called fn_JailTimer.sqf

#include "\life_server\script_macros.hpp"
private["_player", "_playeruid", "_query", "_injail", "_queryResult"];
_player = _this select 0;
_playeruid = _this select 1;
_player = owner _player;
_query = format["UPDATE players SET jail_time=(jail_time - 1) WHERE playerid='%1'", _playeruid];
[_query,1] call DB_fnc_asyncCall;
_query = format["SELECT IF( remainingtime <= '0', TRUE, FALSE ) FROM players WHERE playerid='%1'", _playeruid];
_queryResult = [_query,2] call DB_fnc_asyncCall;

 
replace the code with this :
 

#include "\life_server\script_macros.hpp"
/*
 File: fn_jailSys.sqf
 Author: Bryan "Tonic" Boardwine
 Description:
 I forget?
*/
private["_unit","_bad","_id","_ret","_time"];
_unit = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _unit) exitWith {};
_bad = [_this,1,false,[false]] call BIS_fnc_param;
_time = [_this,2,15,[0]] call BIS_fnc_param;
if(_bad) then {//Load time from database
 _query = format["SELECT jail_time FROM players WHERE playerid='%2'", _time, getPlayerUID _unit];
 _result = [_query,2] call DB_fnc_asyncCall;
 _result = (_result select 0);
 _time = _result;
} else {
 _query = format["UPDATE players SET jail_time='%1' WHERE playerid='%2'", _time, getPlayerUID _unit];
 _result = [_query,1] call DB_fnc_asyncCall;
};
_id = owner _unit;
_ret = [_unit] call life_fnc_wantedPerson;
[_ret,_bad,_time] remoteExec ["life_fnc_jailMe",_id];


Now we go ahead and go to the mission file.
and go to the dialog folder and create a new file called : "jail_time.hpp" and paste the following code in it.
 

class jail_time
{
 idd = 26500;
 name = "jail_time";
 movingEnabled = false;
 enableSimulation = true;
 class controlsBackground {
 class Life_RscTitleBackground:Life_RscText {
 colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};
	 idc = -1;
	 x = 0.3;
	 y = 0.2;
	 w = 0.47;
	 h = (1 / 25);
 };
 
 class MainBackground:Life_RscText {
	 colorBackground[] = {0, 0, 0, 0.7};
	 idc = -1;
	 x = 0.3;
	 y = 0.2 + (11 / 250);
	 w = 0.47;
	 h = 0.3 - (22 / 250);
	};
 };
 
 class controls 
 {
 class Title: Life_RscTitle {
	 colorBackground[] = {0, 0, 0, 0};
	 idc = 2651;
	 text = "Put in Jail";
	 x = 0.3;
	 y = 0.2;
	 w = 0.6;
	 h = (1 / 25);
 };
 
 class InfoMsg: Life_RscText
 {
	 idc = 2601;
	 text = "Time in minutes:";
	 x = 0.3;
	 y = 0.163 + (11 / 250);
	 w = 0.45; 
	 h = 0.12;
 };
 
 class Textedit: Life_RscEdit 
 {
	 idc = 1400;
	 text = "15";
	 sizeEx = 0.030;
	 x = 0.40; 
	 y = 0.30;
	 w = 0.25; 
	 h = 0.03;
 };
 
 class payTicket: Life_RscButtonMenu 
 {
	 idc = 2402;
	 text = "Ok";
	 colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
	 onButtonClick="[] spawn life_fnc_arrestDialog_Arrest;";
	 x = 0.45;
	 y = 0.35;
	 w = (6.25 / 40);
	 h = (1 / 25);
 };
 
 class CloseButtonKey : Life_RscButtonMenu 
 {
	 idc = 2400;
	 text = "$STR_Global_Close";
	 onButtonClick = "closeDialog 0;";
	 x = 0.45;
	 y = 0.40;
	 w = (6.25 / 40);
	 h = (1 / 25);
		};
	};
};

now locate the file "masterhandler.hpp" and add this line to the bottom
 

#include "jail_time.hpp"

now go to Mission/core/cop and create  a file called : "fn_arrestDialog_Arrest.sqf"
and paste the following code in :
 

#include "..\..\script_macros.hpp"
/*
 Player clicked arrest/ok
*/
private ["_time"];
if(playerSide != west) exitWith {};
if(isNil "life_pInact_curTarget") exitWith {};
//Get minutes
_time = ctrlText 1400;
if(! ([_time] call TON_fnc_isnumber)) exitWith {
 hint localize "STR_ATM_notnumeric";
};
_time = parseNumber _time; //requested number
_time = round _time;
if(_time < 5 || _time > 120) exitWith { hint "You can only send to jail between 5-60 minutes!"; };
closeDialog 0;
[life_pInact_curTarget, _time] call life_fnc_arrestAction;

now in the same folder you create a file called : "fn_showArrestDialog.sqf"
and paste this code in :
 

#include "..\..\script_macros.hpp"
/*
 Shows cop arrest dialog
*/
if(playerSide != west) exitWith {};
createDialog "jail_time";

now we locate the folder Mission/core/civilian and edit the file "fn_jail.sqf" replace the code with this :
 

#include "..\..\script_macros.hpp"
/*
 File: fn_jail.sqf
 Author: Bryan "Tonic" Boardwine
 Description:
 Starts the initial process of jailing.
*/
private ["_illegalItems"];
params [
 ["_unit",objNull,[objNull]],
 ["_bad",false,[false]], //Hier ein ,
 ["_time",15,[0]] //und dies eingefügt
];
if (isNull _unit) exitWith {}; //Dafuq?
if (_unit != player) exitWith {}; //Dafuq?
if (life_is_arrested) exitWith {}; //Dafuq i'm already arrested
_illegalItems = LIFE_SETTINGS(getArray,"jail_seize_vItems");
player setVariable ["restrained",false,true];
player setVariable ["Escorting",false,true];
player setVariable ["transporting",false,true];
titleText[localize "STR_Jail_Warn","PLAIN"];
hint localize "STR_Jail_LicenseNOTF";
player setPos (getMarkerPos "jail_marker");
if (_bad) then {
 waitUntil {alive player};
 sleep 1;
};
//Check to make sure they goto check
if (player distance (getMarkerPos "jail_marker") > 40) then {
 player setPos (getMarkerPos "jail_marker");
};
[1] call life_fnc_removeLicenses;
{
 _amount = ITEM_VALUE(_x);
 if (_amount > 0) then {
 [false,_x,_amount] call life_fnc_handleInv;
 };
} forEach _illegalItems;
life_is_arrested = true;
if (LIFE_SETTINGS(getNumber,"jail_seize_inventory") isEqualTo 1) then {
 [] spawn life_fnc_seizeClient;
} else {
 removeAllWeapons player;
 {player removeMagazine _x} forEach (magazines player);
};
if (life_HC_isActive) then {
 [player,_bad,_time] remoteExecCall ["HC_fnc_jailSys",HC_Life]; //Hier wurde nur _time Hinzugefügt
} else {
 [player,_bad,_time] remoteExecCall ["life_fnc_jailSys",RSERV]; //Hier wurde nur _time Hinzugefügt
};
[5] call SOCK_fnc_updatePartial;


now in the same folder you edit the file : "fn_jailMe.sqf" and replace it with this :
 

#include "..\..\script_macros.hpp"
/*
 Author Bryan "Tonic" Boardwine
 Description:
 Once word is received by the server the rest of the jail execution is completed.
*/
private["_time","_bail","_esc","_countDown"];
params [
 ["_ret",[],[[]]],
 ["_bad",false,[false]],
 ["_time",15,[0]]
];
_time = time + (_time * 60);
if (count _ret > 0) then { life_bail_amount = (_ret select 2); } else { life_bail_amount = 1500; };
_esc = false;
_bail = false;
if(_time <= 0) then { _time = time + (15 * 60); hintC "Please Report to Admin: JAIL_FALLBACK_15, time is zero!"; };
[_bad,_time] spawn {
 life_canpay_bail = false;
 life_bail_amount = life_bail_amount * 5;
 if(_this select 0) then {
 sleep ( (_this select 1) * 0.5 );
 } else {
 sleep ( (_this select 1) * 0.2 );
 };
 life_canpay_bail = nil;
};
while {true} do {
 if((round(_time - time)) > 0) then {
 _countDown = if(round (_time - time) > 60) then {format["%1 Minuten",round(round(_time - time) / 60)]} else {format["%1 Sekunden",round(_time - time)]};
 if(isNil "life_canpay_bail") then {
 hintSilent format["Time Remaining:\n %1\n\nCan pay Bail: %3\nBail Amount: $%2",_countDown,[life_bail_amount] call life_fnc_numberText, "dass"];
 } else {
 hintSilent format["Time Remaining:\n %1\n",_countDown];
 };
 };
 if(player distance (getMarkerPos "jail_marker") > 60) exitWith {
 _esc = true;
 };
 if(life_bail_paid) exitWith {
 _bail = true;
 };
 if((round(_time - time)) < 1) exitWith {hint ""};
 if(!alive player && ((round(_time - time)) > 0)) exitWith {};
 sleep 1;
};
switch (true) do {
 case (_bail): {
 life_is_arrested = false;
 life_bail_paid = false;
 hint localize "STR_Jail_Paid";
 serv_wanted_remove = [player];
 player setPos (getMarkerPos "jail_release");
 [getPlayerUID player] remoteExecCall ["life_fnc_wantedRemove",RSERV];
 [5] call SOCK_fnc_updatePartial;
 };
 case (_esc): {
 life_is_arrested = false;
 hint localize "STR_Jail_EscapeSelf";
 [0,"STR_Jail_EscapeNOTF",true,[profileName]] remoteExecCall ["life_fnc_broadcast",RCLIENT];
 [getPlayerUID player,profileName,"901"] remoteExecCall ["life_fnc_wantedAdd",RSERV];
 [5] call SOCK_fnc_updatePartial;
 };
 case (alive player && !_esc && !_bail): {
 life_is_arrested = false;
 hint localize "STR_Jail_Released";
 [getPlayerUID player] remoteExecCall ["life_fnc_wantedRemove",RSERV];
 player setPos (getMarkerPos "jail_release");
 [5] call SOCK_fnc_updatePartial;
 };
};

now you locate to the actions folder and search for : "fn_arrestAction.sqf" and replace with the following :
 

#include "..\..\script_macros.hpp"
/*
 File: fn_arrestAction.sqf
 Author:
 Description:
 Arrests the targeted person.
*/
private["_unit","_id","_time"]; // Hier ist ,"_time" hinzugekommen
_unit = param [0,objNull,[objNull]];
_time = param [1,30]; //das ist auch neu!
if (isNull _unit) exitWith {}; //Not valid
if (isNil "_unit") exitWith {}; //Not Valid
if (!(_unit isKindOf "Man")) exitWith {}; //Not a unit
if (!isPlayer _unit) exitWith {}; //Not a human
if (!(_unit getVariable "restrained")) exitWith {}; //He's not restrained.
if (!((side _unit) in [civilian,independent,east])) exitWith {}; // Hier habe ich die Fraktion East hinzugefügt, dies ist nur für mein Projekt wichtig
if (isNull _unit) exitWith {}; //Not valid
if (life_HC_isActive) then {
 if(_time < 1) exitwith {}; //diese Abfrage wurde hinzugefügt.
 [getPlayerUID _unit,_unit,player,false] remoteExecCall ["HC_fnc_wantedBounty",HC_Life];
} else {
 if(_time < 1) exitwith {}; //so wie diese Abfrage.
 [getPlayerUID _unit,_unit,player,false] remoteExecCall ["life_fnc_wantedBounty",RSERV];
};
if (isNull _unit) exitWith {}; //Not valid
detach _unit;
/*
[_unit,false] remoteExecCall ["life_fnc_jail",_unit];
[0,"STR_NOTF_Arrested_1",true, [_unit getVariable ["realname",name _unit], profileName]] remoteExecCall ["life_fnc_broadcast",RCLIENT];
*/ 
//Das obere hab ich ausgeklammert. Wollte es nicht löschen.
[_unit,false,_time] remoteExecCall ["life_fnc_jail",_unit]; //Dafür kam dies hinzu
[0,"STR_NOTF_Arrested_1",true, [_unit getVariable ["realname",name _unit], profileName]] remoteExecCall ["life_fnc_broadcast",RCLIENT]; // Das ist zwar das gleiche wie oben das auskommentierte. Wieso Warum es hier ist kA. :D
if (LIFE_SETTINGS(getNumber,"player_advancedLog") isEqualTo 1) then {
 if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then {
 advanced_log = format [localize "STR_DL_AL_Arrested_BEF",_unit getVariable ["realname",name _unit]];
 } else {
 advanced_log = format [localize "STR_DL_AL_Arrested",profileName,(getPlayerUID player),_unit getVariable ["realname",name _unit]];
 };
 publicVariableServer "advanced_log";
};

Hold on we are almost finished !

now open your Functions.h and under the class cop you add :
 

class showArrestDialog {};
class arrestDialog_Arrest {};

now the final step.
locate the file "fn_copInteractionsMenu.sqf" and replace :

 

_Btn6 ctrlSetText localize "STR_pInAct_Arrest";
_Btn6 buttonSetAction "[life_pInact_curTarget] call life_fnc_arrestAction; closeDialog 0;";
_Btn6 ctrlEnable false;

with
 

_Btn6 ctrlSetText localize "STR_pInAct_Arrest";
_Btn6 buttonSetAction "closeDialog 0; [] call life_fnc_showArrestDialog;";
_Btn6 ctrlEnable false;


And you are Done, Congratz !

Edited by suffer4real
a part of the tuto was deleted somehow
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Your jail_time.hpp is broken.

Here is the fixed version:

class jail_time
{
 idd = 26500;
 name = "jail_time";
 movingEnabled = false;
 enableSimulation = true;
 class controlsBackground {
 class Life_RscTitleBackground:Life_RscText {
 colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};
	 idc = -1;
	 x = 0.3;
	 y = 0.2;
	 w = 0.47;
	 h = (1 / 25);
 };
 
 class MainBackground:Life_RscText {
	 colorBackground[] = {0, 0, 0, 0.7};
	 idc = -1;
	 x = 0.3;
	 y = 0.2 + (11 / 250);
	 w = 0.47;
	 h = 0.3 - (22 / 250);
	};
 };
 
 class controls 
 {
 class Title: Life_RscTitle {
	 colorBackground[] = {0, 0, 0, 0};
	 idc = 2651;
	 text = "Put in Jail";
	 x = 0.3;
	 y = 0.2;
	 w = 0.6;
	 h = (1 / 25);
 };
 
 class InfoMsg: Life_RscText
 {
	 idc = 2601;
	 text = "Time in minutes:";
	 x = 0.3;
	 y = 0.163 + (11 / 250);
	 w = 0.45; 
	 h = 0.12;
 };
 
 class Textedit: Life_RscEdit 
 {
	 idc = 1400;
	 text = "15";
	 sizeEx = 0.030;
	 x = 0.40; 
	 y = 0.30;
	 w = 0.25; 
	 h = 0.03;
 };
 
 class payTicket: Life_RscButtonMenu 
 {
	 idc = 2402;
	 text = "Ok";
	 colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};
	 onButtonClick="[] spawn life_fnc_arrestDialog_Arrest;";
	 x = 0.45;
	 y = 0.35;
	 w = (6.25 / 40);
	 h = (1 / 25);
 };
 
 class CloseButtonKey : Life_RscButtonMenu 
 {
	 idc = 2400;
	 text = "$STR_Global_Close";
	 onButtonClick = "closeDialog 0;";
	 x = 0.45;
	 y = 0.40;
	 w = (6.25 / 40);
	 h = (1 / 25);
		};
	};
};

 

Share this post


Link to post
Share on other sites

@suffer4real

CREATE TABLE IF NOT EXISTS `players` (
 `jail_time` int(11) NOT NULL DEFAULT '0'
)

This is wrong this is trying to make a table. Not add to it.

Instead use this:

ALTER TABLE  `players` ADD (`jail_time` int(11) NOT NULL DEFAULT '0');

 

Edited by AlaskaVet

Share this post


Link to post
Share on other sites
2 minutes ago, AlaskaVet said:

@suffer4real

CREATE TABLE IF NOT EXISTS `players` (
 `jail_time` int(11) NOT NULL DEFAULT '0'
)

This is wrong this is trying to make a table. Not add to it.

Instead use this:

ALTER TABLE  `players` ADD (`jail_time` int(11) NOT NULL DEFAULT '0');

 

oknice AlaskeViet please suffer4real edit your topic. Thank

Share this post


Link to post
Share on other sites

Thanks. It's work but i can send guy only 15 minutes! If i want change time (max 15 min) where i change it? I testing change fn_JailMe and fn_Jail and i don't work. I want send jail 1-60 minutes... Thanks a lot and sorry for my english ;)

Edited by ArashTaFace

Share this post


Link to post
Share on other sites

Thanks a lot for this! Just what i needed :D
Any way to make certain cop levels have differnet amount of max time? ALso do you know how i can make different cop levels spawn with different gear? 

Tanks :D:D

Share this post


Link to post
Share on other sites
11 minutes ago, [TRF] EnglishMan said:

What do you do with the fn_JailTimer and fn_JailPlayer?

nvm about that, When I send someone to jail, it comes up with how long i can set, but when I set say 5 minutes, it says 15 minutes for them, anyone know why?

Share this post


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.