Version: Altis Life 5.0
Schwierigkeitsgrad: 2
Was es tut:
Cops können die Zeit festlegen, die ein Spieler im Gefängnis sein soll. Dies wird in die Datenbank übergeben und dort auch geupdated (dies fehlte im 4.4 R3 Tutorial). Wenn die Zeit um ist wird der Spieler automatisch wieder aus dem Gefängnis entlassen.
Rechtlicher Hinweis: Es handelt sich hierbei um eine Verbesserung und ein Update des [Tutorial] Jail Time für 4.4 R3. Ein Großteil der Update Arbeit geht mal wieder an moeck
Bevor wir anfangen nicht vergessen: Erst ein Backup machen!
Mission Teil (alle Dateipfade sind relativ zum Missionsordner)
Schritt 1:
Legt im Pfad \dialog die Datei jail_time.hpp an, Inhalt:
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 = "Ins Gefängnis stecken";
x = 0.3;
y = 0.2;
w = 0.6;
h = (1 / 25);
};
class InfoMsg : Life_RscText
{
idc = 2601;
text = "Zeit in Minuten:";
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);
};
};
};
Alles anzeigen
Schritt 2:
Selber Pfad in der MasterHandler.hpp fügt ihr #include "jail_time.hpp" ganz unten hinzu
Schritt 3:
Danach in \core\cop erstellt ihr eine fn_arrestDialog_Arrest.sqf
#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 "Die Zeit muss zwischen 5 und 120 Minuten sein!"; };
closeDialog 0;
[life_pInact_curTarget, _time] call life_fnc_arrestAction;
Alles anzeigen
Schritt 4:
Im selben Verzeichnis noch die fn_showArrestDialog.sqf anlegen
#include "..\..\script_macros.hpp"
/*
Shows cop arrest dialog
*/
if(playerSide != west) exitWith {};
createDialog "jail_time";
Schritt 5:
Des weiteren geht ihr hier in die fn_copInteractionsMenu.sqf und sucht dort nach
_Btn6 ctrlSetText localize "STR_pInAct_Arrest";
_Btn6 buttonSetAction "[life_pInact_curTarget] call life_fnc_arrestAction; closeDialog 0;";
_Btn6 ctrlEnable false;
und ändert es in
_Btn6 ctrlSetText localize "STR_pInAct_Arrest";
_Btn6 buttonSetAction "closeDialog 0; [] call life_fnc_showArrestDialog;";
_Btn6 ctrlEnable false;
Schritt 6:
/core/civillian die Datei fn_jail.sqf suchen und ersetzen
#include "..\..\script_macros.hpp"
/*
File: fn_jail.sqf
Author: Bryan "Tonic" Boardwine
Description:
Starts the initial process of jailing.
*/
params [
["_unit",objNull,[objNull]],
["_bad",false,[false]],
["_time",15,[0]]
];
if (isNull _unit) exitWith {}; //Dafuq?
if !(_unit isEqualTo player) exitWith {}; //Dafuq?
if (life_is_arrested) exitWith {}; //Dafuq i'm already arrested
if !((_unit getVariable ["JailTime",0]) isEqualTo 0) then {_time = (_unit getVariable ["JailTime",0])};
private _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"];
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");
};
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];
} else {
[player,_bad,_time] remoteExecCall ["life_fnc_jailSys",RSERV];
};
[5] call SOCK_fnc_updatePartial;
Alles anzeigen
Schritt 7:
Hier findet ihr auch die fn_jailMe.sqf, auch diese ersetzen
#include "..\..\script_macros.hpp"
/*
File: fn_jailMe.sqf
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 = true;
};
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(life_canpay_bail) then {
hintSilent format["Verbleibende Zeit:\n %1\n\n Sie können die Kaution jetzt bezahlen \n Kaution: %2 %3",_countDown,[life_bail_amount] call life_fnc_numberText, localize "STR_Item_Money"];
} else {
hintSilent format["Verbleibende Zeit:\n %1\n",_countDown];
};
};
_remain = (round(_time - time));
if ((_remain % 60) isEqualTo 0) then {
player setVariable ["JailTime", (round(_remain / 60)) ];
[5] call SOCK_fnc_updatePartial;
};
if (LIFE_SETTINGS(getNumber,"jail_forceWalk") isEqualTo 1) then {
player forceWalk true;
};
private _escDist = [[["Altis", 60], ["Tanoa", 145], ["Malden", 100]]] call TON_fnc_terrainSort;
if (player distance (getMarkerPos "jail_marker") > _escDist) 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 0.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");
player setVariable ["JailTime",0];
if (life_HC_isActive) then {
[getPlayerUID player] remoteExecCall ["HC_fnc_wantedRemove",HC_Life];
} else {
[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",west];
player setVariable ["JailTime",0];
if (life_HC_isActive) then {
[getPlayerUID player,profileName,"901"] remoteExecCall ["HC_fnc_wantedAdd",HC_Life];
} else {
[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";
if (life_HC_isActive) then {
[getPlayerUID player] remoteExecCall ["HC_fnc_wantedRemove",HC_Life];
} else {
[getPlayerUID player] remoteExecCall ["life_fnc_wantedRemove",RSERV];
};
player setPos (getMarkerPos "jail_release");
[5] call SOCK_fnc_updatePartial;
};
};
player forceWalk false; // Enable running & jumping
Alles anzeigen
Schritt 8:
Die Datei fn_arrestAction.sqf im Pfad \core\actions austausche
#include "..\..\script_macros.hpp"
/*
File: fn_arrestAction.sqf
Author:
Description:
Arrests the targeted person.
*/
private ["_unit","_id","_time"];
_unit = param [0,objNull,[objNull]];
_time = param [1,30];
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 {}; //Not a civ
if (isNull _unit) exitWith {}; //Not valid
if (life_HC_isActive) then {
if(_time < 1) exitwith {};
[getPlayerUID _unit,_unit,player,false] remoteExecCall ["HC_fnc_wantedBounty",HC_Life];
} else {
if(_time < 1) exitwith {};
[getPlayerUID _unit,_unit,player,false] remoteExecCall ["life_fnc_wantedBounty",RSERV];
};
if (isNull _unit) exitWith {}; //Not valid
detach _unit;
[_unit,false,_time] remoteExecCall ["life_fnc_jail",_unit];
[0,"STR_NOTF_Arrested_1",true, [_unit getVariable ["realname",name _unit], profileName]] remoteExecCall ["life_fnc_broadcast",west];
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";
};
Alles anzeigen
Schritt 9:
In der Functions.hpp im Hauptordner unter class cop noch class showArrestDialog {}; und class arrestDialog_Arrest {}; eintragen, sollte dann so aussehen
class Cop {
file = "core\cop";
class bountyReceive {};
class containerInvSearch {};
class copInteractionMenu {};
class copLights {};
class copLoadout {};
class copMarkers {};
class copSearch {};
class copSiren {};
class doorAnimate {};
class fedCamDisplay {};
class licenseCheck {};
class licensesRead {};
class questionDealer {};
class radar {};
class repairDoor {};
class restrain {};
class searchClient {};
class seizeClient {};
class sirenLights {};
class spikeStripEffect {};
class ticketGive {};
class ticketPaid {};
class ticketPay {};
class ticketPrompt {};
class vehInvSearch {};
class wantedGrab {};
class showArrestDialog {};
class arrestDialog_Arrest {};
};
Alles anzeigen
Schritt 10:
\core\session in der fn_updatePartial.sqf den case 5 anpassen
case 5: {
_packet set[2,life_is_arrested];
_packet set[4,(player getVariable ["JailTime",0])];
};
Schritt 11:
Im selben Verzeichnis die fn_requestReceived.sqf im case civilian vor der if-Schleife player setVariable ["JailTime",(_this select 13),true]; hinzufügen.
ACHTUNG: Hier ist zu beachten, dass das nur geht, wenn ihr ein unbearbeitetes Framework habt. Falls nicht achtet bitte auf Schritt 3 im vom life_server Teil weiter unten.
life_server Teil (alle Dateipfade sind relativ zum life_server Ordner)
Schritt 1:
Die Datei fn_jailSys.sqf öffnen und austauschen
#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 pid='%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 pid='%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];
Alles anzeigen
Schritt 2:
\Functions\MySQL fn_updatePartial.sqf case 5 ersetzen/erweitern
case 5: {
_value = [_this,2,false,[true]] call BIS_fnc_param;
_value = [_value] call DB_fnc_bool;
_value2 = [_this,4,0,[0]] call BIS_fnc_param;
_query = format ["UPDATE players SET arrested='%1',jail_time ='%2' WHERE pid='%3'",_value,_value2,_uid];
};
Schritt 3:
\Functions\MySQL fn_queryRequest.sqf case civilian suchen
case civilian: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE pid='%1'",_uid];};
und mit dem hier ersetzen/erweitern
case civilian: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime, jail_time FROM players WHERE pid='%1'",_uid];};
weiter unten in der Datei im case civilian ÜBER /* Make sure nothing else is added under here */ einfügen
!!! Hier und auch im Mission Ordner in der fn_requestRecieve.sqf bitte schauen, ob es mit dem obigen Array übereinstimmt. Gezählt wird ab null.
Also
pid (0), name (1), cash (2), bankacc (3), adminlevel (4), donorlevel (5), civ_licenses (6), arrested (7), civ_gear (8), civ_stats (9), civ_alive (10), civ_position (11), playtime (12), jail_time (13)
Außerdem findet ihr oben in der Datei _ownerID = owner _ownerID; daüber fügt ihr noch private _player = _ownerID; ein.
Datenbank Teil:
Führt Folgendes in der Datenbank aus
Wenn ihr nun alles richtig gemacht habt so funktioniert dann auch alles bei euch Sollte es doch nicht so sein gerne hier nach Hilfe fragen.