initial commit

This commit is contained in:
Benjamin Kyd
2019-06-05 00:45:50 +01:00
commit c8014ec81e
610 changed files with 177002 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_insertGang.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Inserts the gang into the database.
*/
private ["_query","_queryResult","_gangMembers","_group"];
params [
["_ownerID",objNull,[objNull]],
["_uid","",[""]],
["_gangName","",[""]]
];
_group = group _ownerID;
if (isNull _ownerID || _uid isEqualTo "" || _gangName isEqualTo "") exitWith {}; //Fail
_gangName = [_gangName] call HC_fnc_mresString;
_query = format ["SELECT id FROM gangs WHERE name='%1' AND active='1'",_gangName];
_queryResult = [_query,2] call HC_fnc_asyncCall;
//Check to see if the gang name already exists.
if (!(count _queryResult isEqualTo 0)) exitWith {
[1,"There is already a gang created with that name please pick another name."] remoteExecCall ["life_fnc_broadcast",_ownerID];
life_action_gangInUse = nil;
_ownerID publicVariableClient "life_action_gangInUse";
};
_query = format ["SELECT id FROM gangs WHERE members LIKE '%2%1%2' AND active='1'",_uid,"%"];
_queryResult = [_query,2] call HC_fnc_asyncCall;
//Check to see if this person already owns or belongs to a gang.
if (!(count _queryResult isEqualTo 0)) exitWith {
[1,"You are currently already active in a gang, please leave the gang first."] remoteExecCall ["life_fnc_broadcast",_ownerID];
life_action_gangInUse = nil;
_ownerID publicVariableClient "life_action_gangInUse";
};
//Check to see if a gang with that name already exists but is inactive.
_query = format ["SELECT id, active FROM gangs WHERE name='%1' AND active='0'",_gangName];
_queryResult = [_query,2] call HC_fnc_asyncCall;
_gangMembers = [[_uid]] call HC_fnc_mresArray;
if (!(count _queryResult isEqualTo 0)) then {
_query = format ["UPDATE gangs SET active='1', owner='%1',members='%2' WHERE id='%3'",_uid,_gangMembers,(_queryResult select 0)];
} else {
_query = format ["INSERT INTO gangs (owner, name, members) VALUES('%1','%2','%3')",_uid,_gangName,_gangMembers];
};
_queryResult = [_query,1] call HC_fnc_asyncCall;
_group setVariable ["gang_name",_gangName,true];
_group setVariable ["gang_owner",_uid,true];
_group setVariable ["gang_bank",0,true];
_group setVariable ["gang_maxMembers",8,true];
_group setVariable ["gang_members",[_uid],true];
[_group] remoteExecCall ["life_fnc_gangCreated",_ownerID];
sleep 0.35;
_query = format ["SELECT id FROM gangs WHERE owner='%1' AND active='1'",_uid];
_queryResult = [_query,2] call HC_fnc_asyncCall;
_group setVariable ["gang_id",(_queryResult select 0),true];

View File

@@ -0,0 +1,21 @@
/*
File: fn_queryPlayerGang.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Queries to see if the player belongs to any gang.
*/
private ["_query","_queryResult"];
_query = format ["SELECT id, owner, name, maxmembers, bank, members FROM gangs WHERE active='1' AND members LIKE '%2%1%2'",_this,"%"];
_queryResult = [_query,2] call HC_fnc_asyncCall;
if !(count _queryResult isEqualTo 0) then {
_tmp = [_queryResult select 5] call HC_fnc_mresToArray;
if (_tmp isEqualType "") then {_tmp = call compile format ["%1",_tmp];};
_queryResult set[5, _tmp];
};
missionNamespace setVariable [format ["gang_%1",_this],_queryResult];

View File

@@ -0,0 +1,26 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_removeGang.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Blah
*/
private ["_group","_groupID"];
_group = param [0,grpNull,[grpNull]];
if (isNull _group) exitWith {};
_groupID = _group getVariable ["gang_id",-1];
if (_groupID isEqualTo -1) exitWith {};
[format ["UPDATE gangs SET active='0' WHERE id='%1'",_groupID],1] call HC_fnc_asyncCall;
_result = [format ["SELECT id FROM gangs WHERE active='1' AND id='%1'",_groupID],2] call HC_fnc_asyncCall;
if (count _result isEqualTo 0) then {
[_group] remoteExecCall ["life_fnc_gangDisbanded",(units _group)];
sleep 5;
deleteGroup _group;
};
["CALL deleteOldGangs",1] call DB_fnc_asyncCall;

View File

@@ -0,0 +1,63 @@
/*
File: fn_updateGang.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Updates the gang information?
*/
private ["_groupID","_bank","_maxMembers","_members","_membersFinal","_query","_owner"];
params [
["_mode",0,[0]],
["_group",grpNull,[grpNull]]
];
if (isNull _group) exitWith {}; //FAIL
_groupID = _group getVariable ["gang_id",-1];
if (_groupID isEqualTo -1) exitWith {};
switch (_mode) do {
case 0: {
_bank = [(_group getVariable ["gang_bank",0])] call HC_fnc_numberSafe;
_maxMembers = _group getVariable ["gang_maxMembers",8];
_members = [(_group getVariable "gang_members")] call HC_fnc_mresArray;
_owner = _group getVariable ["gang_owner",""];
if (_owner isEqualTo "") exitWith {};
_query = format ["UPDATE gangs SET bank='%1', maxmembers='%2', owner='%3' WHERE id='%4'",_bank,_maxMembers,_owner,_groupID];
};
case 1: {
_query = format ["UPDATE gangs SET bank='%1' WHERE id='%2'",([(_group getVariable ["gang_bank",0])] call HC_fnc_numberSafe),_groupID];
};
case 2: {
_query = format ["UPDATE gangs SET maxmembers='%1' WHERE id='%2'",(_group getVariable ["gang_maxMembers",8]),_groupID];
};
case 3: {
_owner = _group getVariable ["gang_owner",""];
if (_owner isEqualTo "") exitWith {};
_query = format ["UPDATE gangs SET owner='%1' WHERE id='%2'",_owner,_groupID];
};
case 4: {
_members = _group getVariable "gang_members";
if (count _members > (_group getVariable ["gang_maxMembers",8])) then {
_membersFinal = [];
for "_i" from 0 to _maxMembers -1 do {
_membersFinal pushBack (_members select _i);
};
} else {
_membersFinal = _group getVariable "gang_members";
};
_membersFinal = [_membersFinal] call HC_fnc_mresArray;
_query = format ["UPDATE gangs SET members='%1' WHERE id='%2'",_membersFinal,_groupID];
};
};
if (!isNil "_query") then {
[_query,1] call HC_fnc_asyncCall;
};

View File

@@ -0,0 +1,54 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_asyncCall.sqf
Author: Bryan "Tonic" Boardwine
Description:
Commits an asynchronous call to ExtDB
Parameters:
0: STRING (Query to be ran).
1: INTEGER (1 = ASYNC + not return for update/insert, 2 = ASYNC + return for query's).
3: BOOL (True to return a single array, false to return multiple entries mainly for garage).
*/
private ["_queryStmt","_mode","_multiarr","_queryResult","_key","_return","_loop"];
_queryStmt = [_this,0,"",[""]] call BIS_fnc_param;
_mode = [_this,1,1,[0]] call BIS_fnc_param;
_multiarr = [_this,2,false,[false]] call BIS_fnc_param;
_key = EXTDB format ["%1:%2:%3",_mode,FETCH_CONST(life_sql_id),_queryStmt];
if (_mode isEqualTo 1) exitWith {true};
_key = call compile format ["%1",_key];
_key = (_key select 1);
_queryResult = EXTDB format ["4:%1", _key];
//Make sure the data is received
if (_queryResult isEqualTo "[3]") then {
for "_i" from 0 to 1 step 0 do {
if (!(_queryResult isEqualTo "[3]")) exitWith {};
_queryResult = EXTDB format ["4:%1", _key];
};
};
if (_queryResult isEqualTo "[5]") then {
_loop = true;
for "_i" from 0 to 1 step 0 do { // extDB3 returned that result is Multi-Part Message
_queryResult = "";
for "_i" from 0 to 1 step 0 do {
_pipe = EXTDB format ["5:%1", _key];
if (_pipe isEqualTo "") exitWith {_loop = false};
_queryResult = _queryResult + _pipe;
};
if (!_loop) exitWith {};
};
};
_queryResult = call compile _queryResult;
if ((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB3: Protocol Error: %1", _queryResult]; []};
_return = (_queryResult select 1);
if (!_multiarr && count _return > 0) then {
_return = (_return select 0);
};
_return;

View File

@@ -0,0 +1,26 @@
/*
File: fn_bool.sqf
Author: TAW_Tonic
Description:
Handles bool conversion for MySQL since MySQL doesn't support 'true' or 'false'
instead MySQL uses Tinyint for BOOLEAN (0 = false, 1 = true)
*/
private ["_bool","_mode"];
_bool = [_this,0,0,[false,0]] call BIS_fnc_param;
_mode = [_this,1,0,[0]] call BIS_fnc_param;
switch (_mode) do {
case 0: {
if (_bool isEqualType 0) exitWith {0};
if (_bool) then {1} else {0};
};
case 1: {
if (!(_bool isEqualType 0)) exitWith {false};
switch (_bool) do {
case 0: {false};
case 1: {true};
};
};
};

View File

@@ -0,0 +1,69 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_cleanup.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Server-side cleanup script on vehicles.
Sort of a lame way but whatever.
*/
private "_deleted";
_deleted = false;
for "_i" from 0 to 1 step 0 do {
private ["_veh","_units","_fuel"];
sleep (60 * 60);
{
_protect = false;
_veh = _x;
_vehicleClass = getText(configFile >> "CfgVehicles" >> (typeOf _veh) >> "vehicleClass");
_fuel = 1;
if (!isNil {_veh getVariable "NPC"} && {_veh getVariable "NPC"}) then {_protect = true;};
if ((_vehicleClass in ["Car","Air","Ship","Armored","Submarine"]) && {!(_protect)}) then {
if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then {_fuel = (fuel _veh);};
_dbInfo = _veh getVariable ["dbInfo",[]];
_units = {(_x distance _veh < 300)} count playableUnits;
if (crew _x isEqualTo []) then {
switch (true) do {
case ((_x getHitPointDamage "HitEngine") > 0.7 && _units isEqualTo 0) : {deleteVehicle _x; _deleted = true;};
case ((_x getHitPointDamage "HitLFWheel") > 0.98 && _units isEqualTo 0) : {deleteVehicle _x; _deleted = true;};
case ((_x getHitPointDamage "HitLF2Wheel") > 0.98 && _units isEqualTo 0) : {deleteVehicle _x; _deleted = true;};
case ((_x getHitPointDamage "HitRFWheel") > 0.98 && _units isEqualTo 0) : {deleteVehicle _x; _deleted = true;};
case ((_x getHitPointDamage "HitRF2Wheel") > 0.98 && _units isEqualTo 0) : {deleteVehicle _x; _deleted = true;};
case (_units isEqualTo 0): {deleteVehicle _x; _deleted = true;};
};
};
if (_deleted) then {
waitUntil {isNull _veh};
_deleted = false;
};
if (isNull _veh) then {
if (count _dbInfo > 0) then {
_uid = _dbInfo select 0;
_plate = _dbInfo select 1;
_query = format ["UPDATE vehicles SET active='0', fuel='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_fuel];
[_query,1] call HC_fnc_asyncCall;
};
};
};
} forEach vehicles;
sleep (3 * 60); //3 minute cool-down before next cycle.
{
if ((typeOf _x) in ["Land_BottlePlastic_V1_F","Land_TacticalBacon_F","Land_Can_V3_F","Land_CanisterFuel_F", "Land_Can_V3_F","Land_Money_F","Land_Suitcase_F"]) then {
deleteVehicle _x;
};
} forEach (allMissionObjects "Thing");
sleep (2 * 60);
{
deleteVehicle _x;
} forEach (allMissionObjects "GroundWeaponHolder");
};

View File

@@ -0,0 +1,55 @@
/*
File: fn_huntingZone.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Spawns animals around the marker when a player
is near. Very basic WIP
TODO:
Change it up so animals repopulate over time.
*/
private ["_animalList","_dist","_radius","_zoneName","_unitsNear","_animalsActive"];
params [
["_zoneName","",[""]],
["_maxAnimals",10,[0]]
];
if (_zoneName isEqualTo "") exitWith {};
_animalList = ["Sheep_random_F","Goat_random_F","Hen_random_F","Cock_random_F"];
_radius = (getMarkerSize _zoneName) select 0;
_dist = _radius + 100;
_zone = getMarkerPos _zoneName;
if (!isNil "animals" && {!(count animals isEqualTo 0)}) then {
_maxAnimals = _maxAnimals - count(animals);
} else {
animals = [];
};
_unitsNear = false;
_animalsActive = false;
for "_i" from 0 to 1 step 0 do {
{if ((_x distance _zone) < _dist) exitWith {_unitsNear = true;}; _unitsNear = false;} forEach playableUnits;
if (_unitsNear && !_animalsActive) then {
_animalsActive = true;
for "_i" from 1 to _maxAnimals do {
_animalClass = selectRandom _animalList;
_position = [((_zone select 0) - _radius + random (_radius * 2)), ((_zone select 1) - _radius + random (_radius * 2)),0];
_animal = createAgent [_animalClass,_position,[],0,"FORM"];
_animal setDir (random 360);
animals pushBack _animal;
};
} else {
if (!_unitsNear && _animalsActive) then {
{deleteVehicle _x;} forEach animals;
animals = [];
_animalsActive = false;
};
};
sleep (3 + random 2);
_maxAnimals = param [1,10,[0]];
publicVariableServer "animals";
};

View File

@@ -0,0 +1,50 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_insertRequest.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Does something with inserting... Don't have time for
descriptions... Need to write it...
*/
private ["_queryResult","_query","_alias"];
params [
"_uid",
"_name",
["_money",-1,[0]],
["_bank",-1,[0]],
["_returnToSender",objNull,[objNull]]
];
//Error checks
if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {};
if (isNull _returnToSender) exitWith {};
_query = format ["SELECT pid, name FROM players WHERE pid='%1'",_uid];
_tickTime = diag_tickTime;
_queryResult = [_query,2] call HC_fnc_asyncCall;
//Double check to make sure the client isn't in the database...
if (_queryResult isEqualType "") exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",_returnToSender];}; //There was an entry!
if !(count _queryResult isEqualTo 0) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",_returnToSender];};
//Clense and prepare some information.
_name = [_name] call HC_fnc_mresString; //Clense the name of bad chars.
_alias = [[_name]] call HC_fnc_mresArray;
_money = [_money] call HC_fnc_numberSafe;
_bank = [_bank] call HC_fnc_numberSafe;
//Prepare the query statement..
_query = format ["INSERT INTO players (pid, name, cash, bankacc, aliases, cop_licenses, med_licenses, civ_licenses, civ_gear, cop_gear, med_gear) VALUES('%1', '%2', '%3', '%4', '%5','""[]""','""[]""','""[]""','""[]""','""[]""','""[]""')",
_uid,
_name,
_money,
_bank,
_alias
];
[_query,1] call HC_fnc_asyncCall;
[] remoteExecCall ["SOCK_fnc_dataQuery",_returnToSender];

View File

@@ -0,0 +1,25 @@
/*
File: fn_insertVehicle.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Inserts the vehicle into the database
*/
private ["_query","_sql"];
params [
"_uid",
"_side",
"_type",
"_className",
["_color",-1,[0]],
["_plate",-1,[0]]
];
//Stop bad data being passed.
if (_uid isEqualTo "" || _side isEqualTo "" || _type isEqualTo "" || _className isEqualTo "" || _color isEqualTo -1 || _plate isEqualTo -1) exitWith {};
_query = format ["INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage) VALUES ('%1', '%2', '%3', '%4', '1','1','""[[],0]""', '%5', '%6','""[]""','""[]""')",_side,_className,_type,_uid,_color,_plate];
[_query,1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,27 @@
/*
File: fn_mresArray.sqf
Author: Bryan "Tonic" Boardwine";
Description:
Acts as a mres (MySQL Real Escape) for arrays so they
can be properly inserted into the database without causing
any problems. The return method is 'hacky' but it's effective.
*/
private ["_array"];
_array = [_this,0,[],[[]]] call BIS_fnc_param;
_array = str _array;
_array = toArray(_array);
for "_i" from 0 to (count _array)-1 do
{
_sel = _array select _i;
if (!(_i isEqualTo 0) && !(_i isEqualTo ((count _array)-1))) then
{
if (_sel isEqualTo 34) then
{
_array set[_i,96];
};
};
};
str(toString(_array));

View File

@@ -0,0 +1,21 @@
/*
File: fn_mresString.sqf
Author: Bryan "Tonic" Boardwine
Description:
Makes the string safe to be passed to MySQL (strips various stuff).
*/
private ["_string","_filter"];
_string = [_this,0,"",[""]] call BIS_fnc_param;
_filter = "'/\`:|;,{}-""<>";
_string = toArray _string; //Blow it up to an array
_filter = toArray _filter; //Blow it up to an array
{
if (_x in _filter) then {
_string deleteAt _forEachIndex;
};
} forEach _string;
toString _string;

View File

@@ -0,0 +1,26 @@
/*
File: fn_mresToArray.sqf
Author: Bryan "Tonic" Boardwine";
Description:
Acts as a mres (MySQL Real Escape) for arrays so they
can be properly inserted into the database without causing
any problems. The return method is 'hacky' but it's effective.
*/
private ["_array"];
_array = [_this,0,"",[""]] call BIS_fnc_param;
if (_array isEqualTo "") exitWith {[]};
_array = toArray(_array);
for "_i" from 0 to (count _array)-1 do
{
_sel = _array select _i;
if (_sel == 96) then
{
_array set[_i,39];
};
};
_array = toString(_array);
_array = call compile format ["%1", _array];
_array;

View File

@@ -0,0 +1,28 @@
/*
File: fn_numberSafe.sqf
Author: Karel Moricky
Description:
Convert a number into string (avoiding scientific notation)
Parameter(s):
_this: NUMBER
Returns:
STRING
*/
private ["_number","_mod","_digots","_digitsCount","_modBase","_numberText"];
_number = [_this,0,0,[0]] call bis_fnc_param;
_mod = [_this,1,3,[0]] call bis_fnc_param;
_digits = _number call bis_fnc_numberDigits;
_digitsCount = count _digits - 1;
_modBase = _digitsCount % _mod;
_numberText = "";
{
_numberText = _numberText + str _x;
if ((_foreachindex - _modBase) % (_mod) isEqualTo 0 && !(_foreachindex isEqualTo _digitsCount)) then {_numberText = _numberText + "";};
} forEach _digits;
_numberText

View File

@@ -0,0 +1,159 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_queryRequest.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Handles the incoming request and sends an asynchronous query
request to the database.
Return:
ARRAY - If array has 0 elements it should be handled as an error in client-side files.
STRING - The request had invalid handles or an unknown error and is logged to the RPT.
*/
private ["_uid","_side","_query","_queryResult","_tickTime","_tmp"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_side = [_this,1,sideUnknown,[civilian]] call BIS_fnc_param;
_ownerID = [_this,2,objNull,[objNull]] call BIS_fnc_param;
if (isNull _ownerID) exitWith {};
_query = switch (_side) do {
// West - 11 entries returned
case west: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE pid='%1'",_uid];};
// Civilian - 12 entries returned
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];};
// Independent - 10 entries returned
case independent: {format ["SELECT pid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE pid='%1'",_uid];};
};
_tickTime = diag_tickTime;
_queryResult = [_query,2] call HC_fnc_asyncCall;
if (_queryResult isEqualType "") exitWith {
[] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
};
if (_queryResult isEqualTo []) exitWith {
[] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
};
//Blah conversion thing from a2net->extdb
_tmp = _queryResult select 2;
_queryResult set[2,[_tmp] call HC_fnc_numberSafe];
_tmp = _queryResult select 3;
_queryResult set[3,[_tmp] call HC_fnc_numberSafe];
//Parse licenses (Always index 6)
_new = [(_queryResult select 6)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_queryResult set[6,_new];
//Convert tinyint to boolean
_old = _queryResult select 6;
for "_i" from 0 to (count _old)-1 do {
_data = _old select _i;
_old set[_i,[_data select 0, ([_data select 1,1] call HC_fnc_bool)]];
};
_queryResult set[6,_old];
_new = [(_queryResult select 8)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_queryResult set[8,_new];
//Parse data for specific side.
switch (_side) do {
case west: {
_queryResult set[9,([_queryResult select 9,1] call HC_fnc_bool)];
//Parse Stats
_new = [(_queryResult select 10)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_queryResult set[10,_new];
//Playtime
_new = [(_queryResult select 11)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_index = TON_fnc_playtime_values_request find [_uid, _new];
if !(_index isEqualTo -1) then {
TON_fnc_playtime_values_request set[_index,-1];
TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1];
TON_fnc_playtime_values_request pushBack [_uid, _new];
} else {
TON_fnc_playtime_values_request pushBack [_uid, _new];
};
_new = _new select 0;
[_uid, _new] call HC_fnc_setPlayTime;
};
case civilian: {
_queryResult set[7,([_queryResult select 7,1] call HC_fnc_bool)];
//Parse Stats
_new = [(_queryResult select 9)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_queryResult set[9,_new];
//Position
_queryResult set[10,([_queryResult select 10,1] call HC_fnc_bool)];
_new = [(_queryResult select 11)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_queryResult set[11,_new];
//Playtime
_new = [(_queryResult select 12)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_index = TON_fnc_playtime_values_request find [_uid, _new];
if !(_index isEqualTo -1) then {
TON_fnc_playtime_values_request set[_index,-1];
TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1];
TON_fnc_playtime_values_request pushBack [_uid, _new];
} else {
TON_fnc_playtime_values_request pushBack [_uid, _new];
};
_new = _new select 2;
[_uid, _new] call HC_fnc_setPlayTime;
_houseData = _uid spawn HC_fnc_fetchPlayerHouses;
waitUntil {scriptDone _houseData};
_queryResult pushBack (missionNamespace getVariable [format ["houses_%1",_uid],[]]);
_gangData = _uid spawn HC_fnc_queryPlayerGang;
waitUntil{scriptDone _gangData};
_queryResult pushBack (missionNamespace getVariable [format ["gang_%1",_uid],[]]);
};
case independent: {
//Parse Stats
_new = [(_queryResult select 9)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_queryResult set[9,_new];
//Playtime
_new = [(_queryResult select 10)] call HC_fnc_mresToArray;
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
_index = TON_fnc_playtime_values_request find [_uid, _new];
if !(_index isEqualTo -1) then {
TON_fnc_playtime_values_request set[_index,-1];
TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1];
TON_fnc_playtime_values_request pushBack [_uid, _new];
} else {
TON_fnc_playtime_values_request pushBack [_uid, _new];
};
_new = _new select 1;
[_uid, _new] call HC_fnc_setPlayTime;
};
};
publicVariable "TON_fnc_playtime_values_request";
life_keyreceived = false;
life_keyreceivedvar = [];
[_uid,_side] remoteExecCall ["TON_fnc_recupKeyForHC",RSERV];
waitUntil {life_keyreceived};
_keyArr = life_keyreceivedvar;
_queryResult pushBack _keyArr;
_queryResult remoteExec ["SOCK_fnc_requestReceived",_ownerID];

View File

@@ -0,0 +1,14 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_receivekeyofServer.sqf
Author: NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Recup the key of player when reconnect
*/
private ["_keyArr","_uid","_side"];
_keyArr = _this select 0;
life_keyreceivedvar = _keyArr;
life_keyreceived = true;

View File

@@ -0,0 +1,88 @@
/*
File: fn_updatePartial.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Takes partial data of a player and updates it, this is meant to be
less network intensive towards data flowing through it for updates.
*/
private ["_uid","_side","_value","_value1","_value2","_mode","_query"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_side = [_this,1,sideUnknown,[civilian]] call BIS_fnc_param;
_mode = [_this,3,-1,[0]] call BIS_fnc_param;
if (_uid isEqualTo "" || _side isEqualTo sideUnknown) exitWith {}; //Bad.
_query = "";
switch (_mode) do {
case 0: {
_value = [_this,2,0,[0]] call BIS_fnc_param;
_value = [_value] call HC_fnc_numberSafe;
_query = format ["UPDATE players SET cash='%1' WHERE pid='%2'",_value,_uid];
};
case 1: {
_value = [_this,2,0,[0]] call BIS_fnc_param;
_value = [_value] call HC_fnc_numberSafe;
_query = format ["UPDATE players SET bankacc='%1' WHERE pid='%2'",_value,_uid];
};
case 2: {
_value = [_this,2,[],[[]]] call BIS_fnc_param;
//Does something license related but I can't remember I only know it's important?
for "_i" from 0 to count(_value)-1 do {
_bool = [(_value select _i) select 1] call HC_fnc_bool;
_value set[_i,[(_value select _i) select 0,_bool]];
};
_value = [_value] call HC_fnc_mresArray;
switch (_side) do {
case west: {_query = format ["UPDATE players SET cop_licenses='%1' WHERE pid='%2'",_value,_uid];};
case civilian: {_query = format ["UPDATE players SET civ_licenses='%1' WHERE pid='%2'",_value,_uid];};
case independent: {_query = format ["UPDATE players SET med_licenses='%1' WHERE pid='%2'",_value,_uid];};
};
};
case 3: {
_value = [_this,2,[],[[]]] call BIS_fnc_param;
_value = [_value] call HC_fnc_mresArray;
switch (_side) do {
case west: {_query = format ["UPDATE players SET cop_gear='%1' WHERE pid='%2'",_value,_uid];};
case civilian: {_query = format ["UPDATE players SET civ_gear='%1' WHERE pid='%2'",_value,_uid];};
case independent: {_query = format ["UPDATE players SET med_gear='%1' WHERE pid='%2'",_value,_uid];};
};
};
case 4: {
_value = [_this,2,false,[true]] call BIS_fnc_param;
_value = [_value] call HC_fnc_bool;
_value2 = [_this,4,[],[[]]] call BIS_fnc_param;
_value2 = if (count _value2 isEqualTo 3) then {_value2} else {[0,0,0]};
_value2 = [_value2] call HC_fnc_mresArray;
_query = format ["UPDATE players SET civ_alive='%1', civ_position='%2' WHERE pid='%3'",_value,_value2,_uid];
};
case 5: {
_value = [_this,2,false,[true]] call BIS_fnc_param;
_value = [_value] call HC_fnc_bool;
_query = format ["UPDATE players SET arrested='%1' WHERE pid='%2'",_value,_uid];
};
case 6: {
_value1 = [_this,2,0,[0]] call BIS_fnc_param;
_value2 = [_this,4,0,[0]] call BIS_fnc_param;
_value1 = [_value1] call HC_fnc_numberSafe;
_value2 = [_value2] call HC_fnc_numberSafe;
_query = format ["UPDATE players SET cash='%1', bankacc='%2' WHERE pid='%3'",_value1,_value2,_uid];
};
case 7: {
_array = [_this,2,[],[[]]] call BIS_fnc_param;
[_uid,_side,_array,0] remoteExecCall ["TON_fnc_keyManagement",RSERV];
};
};
if (_query isEqualTo "") exitWith {};
[_query,1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,65 @@
/*
File: fn_updateRequest.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Updates ALL player information in the database.
Information gets passed here from the client side file: core\session\fn_updateRequest.sqf
*/
private ["_uid","_side","_cash","_bank","_licenses","_gear","_stats","_name","_alive","_position","_query"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_name = [_this,1,"",[""]] call BIS_fnc_param;
_side = [_this,2,sideUnknown,[civilian]] call BIS_fnc_param;
_cash = [_this,3,0,[0]] call BIS_fnc_param;
_bank = [_this,4,5000,[0]] call BIS_fnc_param;
_licenses = [_this,5,[],[[]]] call BIS_fnc_param;
_gear = [_this,6,[],[[]]] call BIS_fnc_param;
_stats = [_this,7,[100,100],[[]]] call BIS_fnc_param;
_alive = [_this,9,false,[true]] call BIS_fnc_param;
_position = [_this,10,[],[[]]] call BIS_fnc_param;
//Get to those error checks.
if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {};
//Parse and setup some data.
_name = [_name] call HC_fnc_mresString;
_gear = [_gear] call HC_fnc_mresArray;
_stats = [_stats] call HC_fnc_mresArray;
_cash = [_cash] call HC_fnc_numberSafe;
_bank = [_bank] call HC_fnc_numberSafe;
_position = if (_side isEqualTo civilian) then {[_position] call HC_fnc_mresArray} else {[]};
//Does something license related but I can't remember I only know it's important?
for "_i" from 0 to count(_licenses)-1 do {
_bool = [(_licenses select _i) select 1] call HC_fnc_bool;
_licenses set[_i,[(_licenses select _i) select 0,_bool]];
};
_licenses = [_licenses] call HC_fnc_mresArray;
//PLAYTIME
_playtime = [_uid] call HC_fnc_getPlayTime;
_playtime_update = [];
{
if ((_x select 0) isEqualTo _uid) exitWith
{
_playtime_update pushBack [_x select 1];
};
} forEach TON_fnc_playtime_values_request;
_playtime_update = (_playtime_update select 0) select 0;
switch (_side) do {
case west: {_playtime_update set[0,_playtime];};
case civilian: {_playtime_update set[2,_playtime];};
case independent: {_playtime_update set[1,_playtime];};
};
_playtime_update = [_playtime_update] call HC_fnc_mresArray;
switch (_side) do {
case west: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', cop_gear='%4', cop_licenses='%5', cop_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_gear,_licenses,_stats,_playtime_update,_uid];};
case civilian: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', civ_licenses='%4', civ_gear='%5', arrested='%6', civ_stats='%7', civ_alive='%8', civ_position='%9', playtime='%10' WHERE pid='%11'",_name,_cash,_bank,_licenses,_gear,[_this select 8] call HC_fnc_bool,_stats,[_alive] call HC_fnc_bool,_position,_playtime_update,_uid];};
case independent: {_query = format ["UPDATE players SET name='%1', cash='%2', bankacc='%3', med_licenses='%4', med_gear='%5', med_stats='%6', playtime='%7' WHERE pid='%8'",_name,_cash,_bank,_licenses,_gear,_stats,_playtime_update,_uid];};
};
_queryResult = [_query,1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,31 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_addContainer.sqf
Author: NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Add container in Database.
*/
private ["_containerPos","_query","_className","_dir"];
params [
["_uid","",[""]],
["_container",objNull,[objNull]]
];
if (isNull _container || _uid isEqualTo "") exitWith {};
_containerPos = getPosATL _container;
_className = typeOf _container;
_dir = [vectorDir _container, vectorUp _container];
_query = format ["INSERT INTO containers (pid, pos, classname, inventory, gear, owned, dir) VALUES('%1', '%2', '%3', '""[[],0]""', '""[]""', '1', '%4')",_uid,_containerPos,_className,_dir];
[_query,1] call HC_fnc_asyncCall;
sleep 0.3;
_query = format ["SELECT id FROM containers WHERE pos='%1' AND pid='%2' AND owned='1'",_containerPos,_uid];
_queryResult = [_query,2] call HC_fnc_asyncCall;
_container setVariable ["container_id",(_queryResult select 0),true];

View File

@@ -0,0 +1,28 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_addHouse.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Blah
*/
private ["_housePos","_query"];
params [
["_uid","",[""]],
["_house",objNull,[objNull]]
];
if (isNull _house || _uid isEqualTo "") exitWith {};
_housePos = getPosATL _house;
_query = format ["INSERT INTO houses (pid, pos, owned) VALUES('%1', '%2', '1')",_uid,_housePos];
[_query,1] call HC_fnc_asyncCall;
sleep 0.3;
_query = format ["SELECT id FROM houses WHERE pos='%1' AND pid='%2' AND owned='1'",_housePos,_uid];
_queryResult = [_query,2] call HC_fnc_asyncCall;
_house setVariable ["house_id",(_queryResult select 0),true];

View File

@@ -0,0 +1,28 @@
/*
File : fn_deleteDBContainer.sqf
Author: NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Delete Container and remove Container in Database
*/
private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"];
_container = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _container) exitWith {diag_log "container null";};
_containerID = _container getVariable ["container_id",-1];
if (_containerID isEqualTo -1) then {
_containerPos = getPosATL _container;
_ownerID = (_container getVariable "container_owner") select 0;
_query = format ["UPDATE containers SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_containerPos];
} else {
_query = format ["UPDATE containers SET owned='0', pos='[]' WHERE id='%1'",_containerID];
};
_container setVariable ["container_id",nil,true];
_container setVariable ["container_owner",nil,true];
[_query,1] call HC_fnc_asyncCall;
["CALL deleteOldContainers",1] call HC_fnc_asyncCall;
deleteVehicle _container;

View File

@@ -0,0 +1,86 @@
#include "\life_hc\hc_macros.hpp"
/*
File : fn_fetchPlayerHouses.sqf
Author: Bryan "Tonic" Boardwine
Modified : NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
1. Fetches all the players houses and sets them up.
2. Fetches all the players containers and sets them up.
*/
private ["_query","_containers","_containerss","_houses"];
params [
["_uid","",[""]]
];
if (_uid isEqualTo "") exitWith {};
_query = format ["SELECT pid, pos, classname, inventory, gear, dir, id FROM containers WHERE pid='%1' AND owned='1'",_uid];
_containers = [_query,2,true] call HC_fnc_asyncCall;
_containerss = [];
{
_position = call compile format ["%1",_x select 1];
_house = nearestObject [_position, "House"];
_direction = call compile format ["%1",_x select 5];
_trunk = [_x select 3] call HC_fnc_mresToArray;
if (_trunk isEqualType "") then {_trunk = call compile format ["%1", _trunk];};
_gear = [_x select 4] call HC_fnc_mresToArray;
if (_gear isEqualType "") then {_gear = call compile format ["%1", _gear];};
_container = createVehicle[_x select 2,[0,0,999],[],0,"NONE"];
waitUntil {!isNil "_container" && {!isNull _container}};
_containerss pushBack _container;
_container allowDamage false;
_container setPosATL _position;
_container setVectorDirAndUp _direction;
//Fix position for more accurate positioning
_posX = _position select 0;
_posY = _position select 1;
_posZ = _position select 2;
_currentPos = getPosATL _container;
_fixX = (_currentPos select 0) - _posX;
_fixY = (_currentPos select 1) - _posY;
_fixZ = (_currentPos select 2) - _posZ;
_container setPosATL [(_posX - _fixX), (_posY - _fixY), (_posZ - _fixZ)];
_container setVectorDirAndUp _direction;
_container setVariable ["Trunk",_trunk,true];
_container setVariable ["container_owner",[_x select 0],true];
_container setVariable ["container_id",_x select 6,true];
clearWeaponCargoGlobal _container;
clearItemCargoGlobal _container;
clearMagazineCargoGlobal _container;
clearBackpackCargoGlobal _container;
if (count _gear > 0) then {
_items = _gear select 0;
_mags = _gear select 1;
_weapons = _gear select 2;
_backpacks = _gear select 3;
for "_i" from 0 to ((count (_items select 0)) - 1) do {
_container addItemCargoGlobal [((_items select 0) select _i), ((_items select 1) select _i)];
};
for "_i" from 0 to ((count (_mags select 0)) - 1) do {
_container addMagazineCargoGlobal [((_mags select 0) select _i), ((_mags select 1) select _i)];
};
for "_i" from 0 to ((count (_weapons select 0)) - 1) do {
_container addWeaponCargoGlobal [((_weapons select 0) select _i), ((_weapons select 1) select _i)];
};
for "_i" from 0 to ((count (_backpacks select 0)) - 1) do {
_container addBackpackCargoGlobal [((_backpacks select 0) select _i), ((_backpacks select 1) select _i)];
};
};
_house setVariable ["containers",_containerss,true];
} forEach _containers;
_query = format ["SELECT pid, pos FROM houses WHERE pid='%1' AND owned='1'",_uid];
_houses = [_query,2,true] call HC_fnc_asyncCall;
_return = [];
{
_pos = call compile format ["%1",_x select 1];
_house = nearestObject [_pos, "House"];
_house allowDamage false;
_return pushBack [_x select 1,_containerss];
} forEach _houses;
missionNamespace setVariable [format ["houses_%1",_uid],_return];

View File

@@ -0,0 +1,22 @@
/*
File: fn_houseCleanup.sqf
Author: NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Cleans up containers inside in house of player.
*/
private ["_query","_containers"];
_query = format ["SELECT pid, pos FROM containers WHERE pid='%1' AND owned='1'",_this];
_containers = [_query,2,true] call HC_fnc_asyncCall;
if (_containers isEqualTo []) exitWith {};
{
_pos = call compile format ["%1",_x select 1];
_container = nearestObjects[_pos,["Box_IND_Grenades_F","B_supplyCrate_F"],12];
{
deleteVehicle _x;
} forEach _container;
} forEach _containers;

View File

@@ -0,0 +1,32 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_houseGarage.sqf
Author: BoGuu
Description:
Database functionality for house garages - HC
*/
params [
["_uid","",[""]],
["_house",objNull,[objNull]],
["_mode",-1,[0]]
];
if (_uid isEqualTo "") exitWith {};
if (isNull _house) exitWith {};
if (_mode isEqualTo -1) exitWith {};
private _housePos = getPosATL _house;
private "_query";
if (_mode isEqualTo 0) then {
_query = format ["UPDATE houses SET garage='1' WHERE pid='%1' AND pos='%2'",_uid,_housePos];
} else {
_query = format ["UPDATE houses SET garage='0' WHERE pid='%1' AND pos='%2'",_uid,_housePos];
};
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
diag_log format ["Query: %1",_query];
};
[_query,1] call DB_fnc_asyncCall;

View File

@@ -0,0 +1,29 @@
/*
File: fn_sellHouse.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Used in selling the house, sets the owned to 0 and will cleanup with a
stored procedure on restart.
*/
private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"];
_house = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _house) exitWith {};
_houseID = _house getVariable ["house_id",-1];
if (_houseID isEqualTo -1) then {
_housePos = getPosATL _house;
_ownerID = (_house getVariable "house_owner") select 0;
_query = format ["UPDATE houses SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_housePos];
} else {
_query = format ["UPDATE houses SET owned='0', pos='[]' WHERE id='%1'",_houseID];
};
_house setVariable ["house_id",nil,true];
_house setVariable ["house_owner",nil,true];
[_query,1] call HC_fnc_asyncCall;
_house setVariable ["house_sold",nil,true];
["CALL deleteOldHouses",1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,29 @@
/*
File : fn_sellHouseContainer.sqf
Author: NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Used in selling the house, container sets the owned to 0 and will cleanup with a
stored procedure on restart.
*/
private ["_house","_houseID","_ownerID","_housePos","_query","_radius","_containers"];
_container = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _container) exitWith {};
_containerID = _container getVariable ["container_id",-1];
if (_containerID isEqualTo -1) then {
_containerPos = getPosATL _container;
_ownerID = (_container getVariable "container_owner") select 0;
_query = format ["UPDATE containers SET owned='0', pos='[]' WHERE pid='%1' AND pos='%2' AND owned='1'",_ownerID,_containerPos];
} else {
_query = format ["UPDATE containers SET owned='0', pos='[]' WHERE id='%1'",_containerID];
};
_container setVariable ["container_id",nil,true];
_container setVariable ["container_owner",nil,true];
deleteVehicle _container;
[_query,1] call HC_fnc_asyncCall;
["CALL deleteOldContainers",1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,26 @@
/*
File : fn_updateHouseContainers.sqf
Author: NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Update inventory "i" in container
*/
private ["_containerID","_containers","_query","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo"];
_container = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _container) exitWith {};
_containerID = _container getVariable ["container_id",-1];
if (_houseID isEqualTo -1) exitWith {};
_vehItems = getItemCargo _container;
_vehMags = getMagazineCargo _container;
_vehWeapons = getWeaponCargo _container;
_vehBackpacks = getBackpackCargo _container;
_cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks];
_cargo = [_cargo] call HC_fnc_mresArray;
_query = format ["UPDATE containers SET gear='%1' WHERE id='%2'",_cargo,_containerID];
[_query,1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,22 @@
/*
File : fn_updateHouseTrunk.sqf
Author: NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Update inventory "y" in container
*/
private ["_house"];
_container = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _container) exitWith {};
_trunkData = _container getVariable ["Trunk",[[],0]];
_containerID = _container getVariable ["container_id",-1];
if (_containerID isEqualTo -1) exitWith {}; //Dafuq?
_trunkData = [_trunkData] call HC_fnc_mresArray;
_query = format ["UPDATE containers SET inventory='%1' WHERE id='%2'",_trunkData,_containerID];
[_query,1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,24 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_spikeStrip.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
This is the server-side part of it which constantly monitors the spike strip and vehicles near it.
First originally tried triggers but I was never any good at those nor do I like them as they
have a global effect.
*/
private ["_nearVehicles","_spikeStrip"];
_spikeStrip = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _spikeStrip) exitWith {}; //Bad vehicle type passed.
waitUntil {_nearVehicles = nearestObjects[getPos _spikeStrip,["Car"],5]; count _nearVehicles > 0 || isNull _spikeStrip};
if (isNull _spikeStrip) exitWith {}; //It was picked up?
_vehicle = _nearVehicles select 0;
if (isNil "_vehicle") exitWith {deleteVehicle _spikeStrip;};
[_vehicle] remoteExec ["life_fnc_spikeStripEffect",_vehicle];
deleteVehicle _spikeStrip;

View File

@@ -0,0 +1,17 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_jailSys.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
I forget?
*/
private ["_unit","_bad","_ret"];
_unit = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _unit) exitWith {};
_bad = [_this,1,false,[false]] call BIS_fnc_param;
_ret = [_unit] call HC_fnc_wantedPerson;
[_ret,_bad] remoteExec ["life_fnc_jailMe",_unit];

View File

@@ -0,0 +1,40 @@
/*
File : fn_getPlayTime.sqf
Author : NiiRoZz
This file is for Nanou's HeadlessClient.
Description :
Gets playtime for player with UID
GATHERED - Loaded from DB and NOT changed
JOIN - Time, the player joined - the newly gathered playtime will be calculated using difference
*/
private ["_uid", "_time_gathered", "_time_join","_time"];
_uid = _this select 0;
_time_gathered = nil;
_time_join = nil;
{
if ((_x select 0) isEqualTo _uid) exitWith {
_time_gathered = _x select 1;
_time_join = _x select 2;
};
} forEach TON_fnc_playtime_values;
if (isNil "_time_gathered" || isNil "_time_join") then {
_time_gathered = 0;
_time_join = time;
TON_fnc_playtime_values pushBack [_uid, _time_gathered, _time_join];
};
publicVariable "TON_fnc_playtime_values";
_time = (time - _time_join); //return time
_time = _time + _time_gathered;
_time = round (_time/60);
_time;

View File

@@ -0,0 +1,29 @@
/*
File : fn_setPlayTime.sqf
Author : NiiRoZz
This file is for Nanou's HeadlessClient.
Description :
Sets gathered time of player
GATHERED - Loaded from DB and NOT changed
JOIN - Time, the player joined - the newly gathered playtime will be calculated using difference
*/
private ["_uid", "_time_gathered"];
_uid = _this select 0;
_time_gathered = ((_this select 1) * 60);
//create value using get
[_uid] call HC_fnc_getPlayTime;
//set value no 1
{
if ((_x select 0) isEqualTo _uid) exitWith {
_x set [1, _time_gathered];
_x set [2, time];
};
} forEach TON_fnc_playtime_values;

View File

@@ -0,0 +1,42 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_chopShopSell.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Checks whether or not the vehicle is persistent or temp and sells it.
*/
private ["_unit","_vehicle","_price","_cash","_ownerUnit"];
_unit = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_vehicle = [_this,1,objNull,[objNull]] call BIS_fnc_param;
_price = [_this,2,500,[0]] call BIS_fnc_param;
_cash = [_this,3,0,[0]] call BIS_fnc_param;
_ownerUnit = _unit getVariable "life_clientID";
//Error checks
if (isNull _vehicle || isNull _unit) exitWith {
life_action_inUse = false;
_ownerUnit publicVariableClient "life_action_inUse";
};
_displayName = FETCH_CONFIG2(getText,"CfgVehicles",typeOf _vehicle, "displayName");
_dbInfo = _vehicle getVariable ["dbInfo",[]];
if (count _dbInfo > 0) then {
_uid = (_dbInfo select 0);
_plate = (_dbInfo select 1);
_query = format ["UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'",_uid,_plate];
_sql = [_query,1] call HC_fnc_asyncCall;
};
deleteVehicle _vehicle;
life_action_inUse = false;
_ownerUnit publicVariableClient "life_action_inUse";
CASH = _cash;
_ownerUnit publicVariableClient "life_cash";
[2,"STR_NOTF_ChopSoldCar",true,[_displayName,[_price] call life_fnc_numberText]] remoteExecCall ["life_fnc_broadcast",_unit];

View File

@@ -0,0 +1,44 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_getVehicles.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Sends a request to query the database information and returns vehicles.
*/
private ["_pid","_side","_type","_unit","_ret","_tickTime","_queryResult"];
_pid = [_this,0,"",[""]] call BIS_fnc_param;
_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param;
_type = [_this,2,"",[""]] call BIS_fnc_param;
_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param;
//Error checks
if (_pid isEqualTo "" || _side isEqualTo sideUnknown || _type isEqualTo "" || isNull _unit) exitWith {
if (!isNull _unit) then {
[[]] remoteExec ["life_fnc_impoundMenu",_unit];
};
};
_side = switch (_side) do {
case west:{"cop"};
case civilian: {"civ"};
case independent: {"med"};
default {"Error"};
};
if (_side == "Error") exitWith {
[[]] remoteExec ["life_fnc_impoundMenu",_unit];
};
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND side='%2' AND type='%3'",_pid,_side,_type];
_tickTime = diag_tickTime;
_queryResult = [_query,2,true] call HC_fnc_asyncCall;
if (_queryResult isEqualType "") exitWith {
[[]] remoteExec ["life_fnc_impoundMenu",_unit];
};
[_queryResult] remoteExec ["life_fnc_impoundMenu",_unit];

View File

@@ -0,0 +1,45 @@
/*
File: fn_keyManagement.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Keeps track of an array locally on the server of a players keys.
*/
private ["_uid","_side","_input","_mode","_arr"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_side = [_this,1,sideUnknown,[sideUnknown]] call BIS_fnc_param;
_mode = [_this,3,0,[0]] call BIS_fnc_param;
if (_uid isEqualTo "" || _side isEqualTo sideUnknown) exitWith {}; //BAAAAAAAAADDDDDDDD
switch (_mode) do {
case 0: {
_input = [_this,2,[],[[]]] call BIS_fnc_param;
_arr = [];
{
if (!isNull _x && {!(_x isKindOf "House")}) then {
_arr pushBack _x;
};
} forEach _input;
_arr = _arr - [objNull];
missionNamespace setVariable [format ["%1_KEYS_%2",_uid,_side],_arr];
};
case 1: {
_input = [_this,2,objNull,[objNull]] call BIS_fnc_param;
if (isNull _input || _input isKindOf "House") exitWith {};
_arr = missionNamespace getVariable [format ["%1_KEYS_%2",_uid,_side],[]];
_arr pushBack _input;
_arr = _arr - [objNull];
missionNamespace setVariable [format ["%1_KEYS_%2",_uid,_side],_arr];
};
case 2: {
_arr = missionNamespace getVariable [format ["%1_KEYS_%2",_uid,_side],[]];
_arr = _arr - [objNull];
missionNamespace setVariable [format ["%1_KEYS_%2",_uid,_side],_arr];
};
};

View File

@@ -0,0 +1,190 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_spawnVehicle.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Sends the query request to the database, if an array is returned then it creates
the vehicle if it's not in use or dead.
*/
private ["_vid","_sp","_pid","_query","_sql","_vehicle","_nearVehicles","_name","_side","_tickTime","_dir","_servIndex","_damage","_wasIllegal","_location"];
_vid = [_this,0,-1,[0]] call BIS_fnc_param;
_pid = [_this,1,"",[""]] call BIS_fnc_param;
_sp = [_this,2,[],[[],""]] call BIS_fnc_param;
_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param;
_price = [_this,4,0,[0]] call BIS_fnc_param;
_dir = [_this,5,0,[0]] call BIS_fnc_param;
_spawntext = _this select 6;
_ownerID = _unit getVariable ["life_clientID",-1];
_unit_return = _unit;
_name = name _unit;
_side = side _unit;
//_unit = owner _unit;
if (_vid isEqualTo -1 || _pid isEqualTo "") exitWith {};
if (_vid in serv_sv_use) exitWith {};
serv_sv_use pushBack _vid;
_servIndex = serv_sv_use find _vid;
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid];
_tickTime = diag_tickTime;
_queryResult = [_query,2] call HC_fnc_asyncCall;
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
diag_log "------------- Client Query Request -------------";
diag_log format ["QUERY: %1",_query];
diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
diag_log format ["Result: %1",_queryResult];
diag_log "------------------------------------------------";
};
if (_queryResult isEqualType "") exitWith {};
_vInfo = _queryResult;
if (isNil "_vInfo") exitWith {serv_sv_use deleteAt _servIndex;};
if (count _vInfo isEqualTo 0) exitWith {serv_sv_use deleteAt _servIndex;};
if ((_vInfo select 5) isEqualTo 0) exitWith {
serv_sv_use deleteAt _servIndex;
[1,"STR_Garage_SQLError_Destroyed",true,[_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit];
};
if ((_vInfo select 6) isEqualTo 1) exitWith {
serv_sv_use deleteAt _servIndex;
[1,"STR_Garage_SQLError_Active",true,[_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit];
};
if (!(_sp isEqualType "")) then {
_nearVehicles = nearestObjects[_sp,["Car","Air","Ship"],10];
} else {
_nearVehicles = [];
};
if (count _nearVehicles > 0) exitWith {
serv_sv_use deleteAt _servIndex;
[_price,_unit_return] remoteExecCall ["life_fnc_garageRefund",_unit];
[1,"STR_Garage_SpawnPointError",true] remoteExecCall ["life_fnc_broadcast",_unit];
};
_query = format ["UPDATE vehicles SET active='1', damage='""[]""' WHERE pid='%1' AND id='%2'",_pid,_vid];
_trunk = [(_vInfo select 9)] call HC_fnc_mresToArray;
_gear = [(_vInfo select 10)] call HC_fnc_mresToArray;
_damage = [(_vInfo select 12)] call HC_fnc_mresToArray;
_wasIllegal = (_vInfo select 13);
_wasIllegal = if (_wasIllegal isEqualTo 1) then { true } else { false };
[_query,1] call HC_fnc_asyncCall;
if (_sp isEqualType "") then {
_vehicle = createVehicle[(_vInfo select 2),[0,0,999],[],0,"NONE"];
waitUntil {!isNil "_vehicle" && {!isNull _vehicle}};
_vehicle allowDamage false;
_hs = nearestObjects[getMarkerPos _sp,["Land_Hospital_side2_F"],50] select 0;
_vehicle setPosATL (_hs modelToWorld [-0.4,-4,12.65]);
sleep 0.6;
} else {
_vehicle = createVehicle [(_vInfo select 2),_sp,[],0,"NONE"];
waitUntil {!isNil "_vehicle" && {!isNull _vehicle}};
_vehicle allowDamage false;
_vehicle setPos _sp;
_vehicle setVectorUp (surfaceNormal _sp);
_vehicle setDir _dir;
};
_vehicle allowDamage true;
//Send keys over the network.
[_vehicle] remoteExecCall ["life_fnc_addVehicle2Chain",_unit];
/*[_pid,_side,_vehicle,1] call HC_fnc_keyManagement;*/
[_pid,_side,_vehicle,1] remoteExecCall ["TON_fnc_keyManagement",RSERV];
_vehicle lock 2;
//Reskin the vehicle
[_vehicle,_vInfo select 8] remoteExecCall ["life_fnc_colorVehicle",_unit];
_vehicle setVariable ["vehicle_info_owners",[[_pid,_name]],true];
_vehicle setVariable ["dbInfo",[(_vInfo select 4),(_vInfo select 7)],true];
_vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive.
[_vehicle] call life_fnc_clearVehicleAmmo;
if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then {
_vehicle setVariable ["Trunk",_trunk,true];
if (_wasIllegal) then {
private _refPoint = if (_sp isEqualType "") then {getMarkerPos _sp;} else {_sp;};
private _distance = 100000;
private "_location";
{
private _tempLocation = nearestLocation [_refPoint, _x];
private _tempDistance = _refPoint distance _tempLocation;
if (_tempDistance < _distance) then {
_location = _tempLocation;
_distance = _tempDistance;
};
false
} count ["NameCityCapital", "NameCity", "NameVillage"];
_location = text _location;
[1,"STR_NOTF_BlackListedVehicle",true,[_location,_name]] remoteExecCall ["life_fnc_broadcast",west];
_query = format ["UPDATE vehicles SET blacklist='0' WHERE id='%1' AND pid='%2'",_vid,_pid];
_thread = [_query,1] call HC_fnc_asyncCall;
};
} else {
_vehicle setVariable ["Trunk",[[],0],true];
};
if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then {
_vehicle setFuel (_vInfo select 11);
}else{
_vehicle setFuel 1;
};
if (count _gear > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1)) then {
_items = _gear select 0;
_mags = _gear select 1;
_weapons = _gear select 2;
_backpacks = _gear select 3;
for "_i" from 0 to ((count (_items select 0)) - 1) do {
_vehicle addItemCargoGlobal [((_items select 0) select _i), ((_items select 1) select _i)];
};
for "_i" from 0 to ((count (_mags select 0)) - 1) do {
_vehicle addMagazineCargoGlobal [((_mags select 0) select _i), ((_mags select 1) select _i)];
};
for "_i" from 0 to ((count (_weapons select 0)) - 1) do {
_vehicle addWeaponCargoGlobal [((_weapons select 0) select _i), ((_weapons select 1) select _i)];
};
for "_i" from 0 to ((count (_backpacks select 0)) - 1) do {
_vehicle addBackpackCargoGlobal [((_backpacks select 0) select _i), ((_backpacks select 1) select _i)];
};
};
if (count _damage > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1)) then {
_parts = getAllHitPointsDamage _vehicle;
for "_i" from 0 to ((count _damage) - 1) do {
_vehicle setHitPointDamage [format ["%1",((_parts select 0) select _i)],_damage select _i];
};
};
//Sets of animations
if ((_vInfo select 1) isEqualTo "civ" && ((_vInfo select 2)) isEqualTo "B_Heli_Light_01_F" && !((_vInfo select 8) isEqualTo 13)) then {
[_vehicle,"civ_littlebird",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit];
};
if ((_vInfo select 1) isEqualTo "cop" && ((_vInfo select 2)) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","B_Heli_Light_01_F","B_Heli_Transport_01_F"]) then {
[_vehicle,"cop_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit];
};
if ((_vInfo select 1) isEqualTo "med" && ((_vInfo select 2)) isEqualTo "C_Offroad_01_F") then {
[_vehicle,"med_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit];
};
[1,_spawntext] remoteExecCall ["life_fnc_broadcast",_unit];
serv_sv_use deleteAt _servIndex;

View File

@@ -0,0 +1,37 @@
/*
File: fn_vehicleCreate.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Answers the query request to create the vehicle in the database.
*/
private ["_uid","_side","_type","_classname","_color","_plate"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param;
_vehicle = [_this,2,objNull,[objNull]] call BIS_fnc_param;
_color = [_this,3,-1,[0]] call BIS_fnc_param;
//Error checks
if (_uid isEqualTo "" || _side isEqualTo sideUnknown || isNull _vehicle) exitWith {};
if (!alive _vehicle) exitWith {};
_className = typeOf _vehicle;
_type = switch (true) do {
case (_vehicle isKindOf "Car"): {"Car"};
case (_vehicle isKindOf "Air"): {"Air"};
case (_vehicle isKindOf "Ship"): {"Ship"};
};
_side = switch (_side) do {
case west:{"cop"};
case civilian: {"civ"};
case independent: {"med"};
default {"Error"};
};
_plate = round(random(1000000));
[_uid,_side,_type,_classname,_color,_plate] call HC_fnc_insertVehicle;
_vehicle setVariable ["dbInfo",[_uid,_plate],true];

View File

@@ -0,0 +1,23 @@
/*
File: fn_vehicleDelete.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Doesn't actually delete since we don't give our DB user that type of
access so instead we set it to alive=0 so it never shows again.
*/
diag_log "Script VehicleDelete HC";
private ["_vid","_sp","_pid","_query","_sql","_type","_thread"];
_vid = [_this,0,-1,[0]] call BIS_fnc_param;
_pid = [_this,1,"",[""]] call BIS_fnc_param;
_sp = [_this,2,2500,[0]] call BIS_fnc_param;
_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param;
_type = [_this,4,"",[""]] call BIS_fnc_param;
if (_vid isEqualTo -1 || _pid isEqualTo "" || _sp isEqualTo 0 || isNull _unit || _type isEqualTo "") exitWith {};
_query = format ["UPDATE vehicles SET alive='0' WHERE pid='%1' AND id='%2'",_pid,_vid];
_thread = [_query,1] call HC_fnc_asyncCall;

View File

@@ -0,0 +1,154 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_vehicleStore.sqf
Author: Bryan "Tonic" Boardwine
This file is for Nanou's HeadlessClient.
Description:
Stores the vehicle in the 'Garage'
*/
private ["_vehicle","_impound","_vInfo","_vInfo","_plate","_uid","_query","_sql","_unit","_trunk","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo","_saveItems","_storetext","_resourceItems","_fuel","_damage","_itemList","_totalweight","_weight"];
_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_impound = [_this,1,false,[true]] call BIS_fnc_param;
_unit = [_this,2,objNull,[objNull]] call BIS_fnc_param;
_storetext = [_this,3,"",[""]] call BIS_fnc_param;
_ownerID = _unit getVariable ["life_clientID",-1];
_resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items");
if (isNull _vehicle || isNull _unit) exitWith {life_impound_inuse = false; _ownerID publicVariableClient "life_impound_inuse";life_garage_store = false;_ownerID publicVariableClient "life_garage_store";}; //Bad data passed.
_vInfo = _vehicle getVariable ["dbInfo",[]];
if (count _vInfo > 0) then {
_plate = _vInfo select 1;
_uid = _vInfo select 0;
};
// save damage.
if (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1) then {
_damage = getAllHitPointsDamage _vehicle;
_damage = _damage select 2;
} else {
_damage = [];
};
_damage = [_damage] call HC_fnc_mresArray;
// because fuel price!
if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then {
_fuel = (fuel _vehicle);
} else {
_fuel = 1;
};
if (_impound) exitWith {
if (_vInfo isEqualTo []) then {
life_impound_inuse = false;
_ownerID publicVariableClient "life_impound_inuse";
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
} else { // no free repairs!
_query = format ["UPDATE vehicles SET active='0', fuel='%3', damage='%4' WHERE pid='%1' AND plate='%2'",_uid , _plate, _fuel, _damage];
_thread = [_query,1] call HC_fnc_asyncCall;
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
life_impound_inuse = false;
_ownerID publicVariableClient "life_impound_inuse";
};
};
// not persistent so just do this!
if (_vInfo isEqualTo []) exitWith {
[1,"STR_Garage_Store_NotPersistent",true] remoteExecCall ["life_fnc_broadcast",_ownerID];
life_garage_store = false;
_ownerID publicVariableClient "life_garage_store";
};
if !(_uid isEqualTo getPlayerUID _unit) exitWith {
[1,"STR_Garage_Store_NoOwnership",true] remoteExecCall ["life_fnc_broadcast",_ownerID];
life_garage_store = false;
_ownerID publicVariableClient "life_garage_store";
};
// sort out whitelisted items!
_trunk = _vehicle getVariable ["Trunk", [[], 0]];
_itemList = _trunk select 0;
_totalweight = 0;
_items = [];
if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then {
if (LIFE_SETTINGS(getNumber,"save_vehicle_illegal") isEqualTo 1) then {
_blacklist = false;
_profileQuery = format ["SELECT name FROM players WHERE pid='%1'", _uid];
_profileName = [_profileQuery, 2] call HC_fnc_asyncCall;
_profileName = _profileName select 0;
{
_isIllegal = M_CONFIG(getNumber,"VirtualItems",_x select 0,"illegal");
_isIllegal = if (_isIllegal isEqualTo 1) then { true } else { false };
if (((_x select 0) in _resourceItems) || (_isIllegal)) then {
_items pushBack[_x select 0, _x select 1];
_weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1);
_totalweight = _weight + _totalweight;
};
if (_isIllegal) then {
_blacklist = true;
};
}
foreach _itemList;
if (_blacklist) then {
[_uid, _profileName, "481"] remoteExecCall["HC_fnc_wantedAdd", HC_Life];
_query = format ["UPDATE vehicles SET blacklist='1' WHERE pid='%1' AND plate='%2'", _uid, _plate];
_thread = [_query, 1] call HC_fnc_asyncCall;
};
}
else {
{
if ((_x select 0) in _resourceItems) then {
_items pushBack[_x select 0,_x select 1];
_weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1);
_totalweight = _weight + _totalweight;
};
}
forEach _itemList;
};
_trunk = [_items, _totalweight];
}
else {
_trunk = [[], 0];
};
if (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1) then {
_vehItems = getItemCargo _vehicle;
_vehMags = getMagazineCargo _vehicle;
_vehWeapons = getWeaponCargo _vehicle;
_vehBackpacks = getBackpackCargo _vehicle;
_cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks];
// no items? clean the array so the database looks pretty
if (((_vehItems select 0) isEqualTo []) && ((_vehMags select 0) isEqualTo []) && ((_vehWeapons select 0) isEqualTo []) && ((_vehBackpacks select 0) isEqualTo [])) then {_cargo = [];};
} else {
_cargo = [];
};
// prepare
_trunk = [_trunk] call HC_fnc_mresArray;
_cargo = [_cargo] call HC_fnc_mresArray;
// update
_query = format ["UPDATE vehicles SET active='0', inventory='%3', gear='%4', fuel='%5', damage='%6' WHERE pid='%1' AND plate='%2'", _uid, _plate, _trunk, _cargo, _fuel, _damage];
_thread = [_query,1] call HC_fnc_asyncCall;
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
life_garage_store = false;
_ownerID publicVariableClient "life_garage_store";
[1,_storetext] remoteExecCall ["life_fnc_broadcast",_ownerID];

View File

@@ -0,0 +1,55 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_vehicleUpdate.sqf
Author : NiiRoZz
This file is for Nanou's HeadlessClient.
Description:
Tells the database that this vehicle need update inventory.
*/
private ["_vehicle","_plate","_uid","_query","_sql","_dbInfo","_thread","_cargo","_trunk","_resourceItems","_itemList","_totalweight","_weight"];
_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_mode = [_this,1,1,[0]] call BIS_fnc_param;
if (isNull _vehicle) exitWith {}; //NULL
_dbInfo = _vehicle getVariable ["dbInfo",[]];
if (_dbInfo isEqualTo []) exitWith {};
_uid = _dbInfo select 0;
_plate = _dbInfo select 1;
switch (_mode) do {
case 1: {
_vehItems = getItemCargo _vehicle;
_vehMags = getMagazineCargo _vehicle;
_vehWeapons = getWeaponCargo _vehicle;
_vehBackpacks = getBackpackCargo _vehicle;
_cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks];
// Keep it clean!
if (((_vehItems select 0) isEqualTo []) && ((_vehMags select 0) isEqualTo []) && ((_vehWeapons select 0) isEqualTo []) && ((_vehBackpacks select 0) isEqualTo [])) then {_cargo = [];};
_cargo = [_cargo] call HC_fnc_mresArray;
_query = format ["UPDATE vehicles SET gear='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_cargo];
_thread = [_query,1] call HC_fnc_asyncCall;
};
case 2: {
_resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items");
_trunk = _vehicle getVariable ["Trunk",[[],0]];
_totalweight = 0;
_items = [];
{
if ((_x select 0) in _resourceItems) then {
_items pushBack [(_x select 0),(_x select 1)];
_weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1);
_totalweight = _weight + _totalweight;
};
}forEach (_trunk select 0);
_trunk = [_items,_totalweight];
_trunk = [_trunk] call HC_fnc_mresArray;
_query = format ["UPDATE vehicles SET inventory='%3' WHERE pid='%1' AND plate='%2'",_uid,_plate,_trunk];
_thread = [_query,1] call HC_fnc_asyncCall;
};
};

View File

@@ -0,0 +1,97 @@
/*
File: fn_wantedAdd.sqf
Author: Bryan "Tonic" Boardwine"
Database Persistence By: ColinM
Assistance by: Paronity
Stress Tests by: Midgetgrimm
This file is for Nanou's HeadlessClient.
Description:
Adds or appends a unit to the wanted list.
*/
private ["_uid","_type","_index","_data","_crime","_val","_customBounty","_name","_pastCrimes","_query","_queryResult"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_name = [_this,1,"",[""]] call BIS_fnc_param;
_type = [_this,2,"",[""]] call BIS_fnc_param;
_customBounty = [_this,3,-1,[0]] call BIS_fnc_param;
if (_uid isEqualTo "" || _type isEqualTo "" || _name isEqualTo "") exitWith {}; //Bad data passed.
//What is the crime?
switch (_type) do
{
case "187V": {_type = ["187V",650]};
case "187": {_type = ["187",2000]};
case "901": {_type = ["901",450]};
case "215": {_type = ["215",200]};
case "213": {_type = ["213",1000]};
case "211": {_type = ["211",100]};
case "207": {_type = ["207",350]};
case "207A": {_type = ["207A",200]};
case "390": {_type = ["390",1500]};
case "487": {_type = ["487",150]};
case "488": {_type = ["488",70]};
case "480": {_type = ["480",100]};
case "481": {_type = ["481",100]};
case "482": {_type = ["482",500]};
case "483": {_type = ["483",950]};
case "459": {_type = ["459",650]};
case "666": {_type = ["666",200]};
case "667": {_type = ["667",4500]};
case "668": {_type = ["668",1500]};
case "1": {_type = ["1",250]};
case "2": {_type = ["2",100]};
case "3": {_type = ["3",75]};
case "4": {_type = ["4",125]};
case "5": {_type = ["5",50]};
case "6": {_type = ["6",40]};
case "7": {_type = ["7",75]};
case "8": {_type = ["8",2500]};
case "9": {_type = ["9",2500]};
case "10": {_type = ["10",7500]};
case "11": {_type = ["11",5000]};
case "12": {_type = ["12",1250]};
case "13": {_type = ["13",750]};
case "14": {_type = ["14",250]};
case "15": {_type = ["15",1250]};
case "16": {_type = ["16",750]};
case "17": {_type = ["17",50]};
case "18": {_type = ["18",750]};
case "19": {_type = ["19",1250]};
case "20": {_type = ["20",250]};
case "21": {_type = ["21",250]};
case "22": {_type = ["22",1000]};
case "23": {_type = ["23",2500]};
case "24": {_type = ["24",5000]};
case "25": {_type = ["25",10000]};
default {_type = [];};
};
if (_type isEqualTo []) exitWith {}; //Not our information being passed...
//Is there a custom bounty being sent? Set that as the pricing.
if !(_customBounty isEqualTo -1) then {_type set[1,_customBounty];};
//Search the wanted list to make sure they are not on it.
_query = format ["SELECT wantedID FROM wanted WHERE wantedID='%1'",_uid];
_queryResult = [_query,2,true] call HC_fnc_asyncCall;
_val = [_type select 1] call HC_fnc_numberSafe;
_number = _type select 0;
if !(count _queryResult isEqualTo 0) then
{
_crime = format ["SELECT wantedCrimes, wantedBounty FROM wanted WHERE wantedID='%1'",_uid];
_crimeresult = [_crime,2] call HC_fnc_asyncCall;
_pastcrimess = [_crimeresult select 0] call HC_fnc_mresToArray;
if (_pastcrimess isEqualType "") then {_pastcrimess = call compile format ["%1", _pastcrimess];};
_pastCrimes = _pastcrimess;
_pastCrimes pushBack _number;
_pastCrimes = [_pastCrimes] call HC_fnc_mresArray;
_query = format ["UPDATE wanted SET wantedCrimes = '%1', wantedBounty = wantedBounty + '%2', active = '1' WHERE wantedID='%3'",_pastCrimes,_val,_uid];
[_query,1] call HC_fnc_asyncCall;
} else {
_crime = [_type select 0];
_crime = [_crime] call HC_fnc_mresArray;
_query = format ["INSERT INTO wanted (wantedID, wantedName, wantedCrimes, wantedBounty, active) VALUES('%1', '%2', '%3', '%4', '1')",_uid,_name,_crime,_val];
[_query,1] call HC_fnc_asyncCall;
};

View File

@@ -0,0 +1,33 @@
/*
File: fn_wantedBounty.sqf
Author: Bryan "Tonic" Boardwine"
Database Persistence By: ColinM
Assistance by: Paronity
Stress Tests by: Midgetgrimm
This file is for Nanou's HeadlessClient.
Description:
Checks if the person is on the bounty list and awards the cop for killing them.
*/
private ["_civ","_cop","_id","_half","_result","_queryResult","_amount"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_civ = [_this,1,objNull,[objNull]] call BIS_fnc_param;
_cop = [_this,2,objNull,[objNull]] call BIS_fnc_param;
_half = [_this,3,false,[false]] call BIS_fnc_param;
if (isNull _civ || isNull _cop) exitWith {};
_query = format ["SELECT wantedID, wantedName, wantedCrimes, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_uid];
_queryResult = [_query,2] call HC_fnc_asyncCall;
if !(count _queryResult isEqualTo 0) then
{
_amount = _queryResult select 3;
if !(_amount isEqualTo 0) then {
if (_half) then {
[((_amount) / 2),_amount] remoteExecCall ["life_fnc_bountyReceive",_cop];
} else {
[_amount,_amount] remoteExecCall ["life_fnc_bountyReceive",_cop];
};
};
};

View File

@@ -0,0 +1,80 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_wantedCrimes.sqf
Author: ColinM
Assistance by: Paronity
Stress Tests by: Midgetgrimm
This file is for Nanou's HeadlessClient.
Description:
Grabs a list of crimes committed by a person.
*/
private ["_display","_criminal","_tab","_queryResult","_result","_ret","_crimesDb","_crimesArr","_type"];
disableSerialization;
_ret = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_criminal = [_this,1,[],[]] call BIS_fnc_param;
_query = format ["SELECT wantedCrimes, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_criminal select 0];
_queryResult = [_query,2] call HC_fnc_asyncCall;
_crimesArr = [];
_type = [_queryResult select 0] call HC_fnc_mresToArray;
if (_type isEqualType "") then {_type = call compile format ["%1", _type];};
{
switch (_x) do
{
case "187V": {_x = "STR_Crime_187V"};
case "187": {_x = "STR_Crime_187"};
case "901": {_x = "STR_Crime_901"};
case "215": {_x = "STR_Crime_215"};
case "213": {_x = "STR_Crime_213"};
case "211": {_x = "STR_Crime_211"};
case "207": {_x = "STR_Crime_207"};
case "207A": {_x = "STR_Crime_207A"};
case "390": {_x = "STR_Crime_390"};
case "487": {_x = "STR_Crime_487"};
case "488": {_x = "STR_Crime_488"};
case "480": {_x = "STR_Crime_480"};
case "481": {_x = "STR_Crime_481"};
case "482": {_x = "STR_Crime_482"};
case "483": {_x = "STR_Crime_483"};
case "459": {_x = "STR_Crime_459"};
case "666": {_x = "STR_Crime_666"};
case "667": {_x = "STR_Crime_667"};
case "668": {_x = "STR_Crime_668"};
case "919": {_x = "STR_Crime_919"};
case "919A": {_x = "STR_Crime_919A"};
case "1": {_x = "STR_Crime_1"};
case "2": {_x = "STR_Crime_2"};
case "3": {_x = "STR_Crime_3"};
case "4": {_x = "STR_Crime_4"};
case "5": {_x = "STR_Crime_5"};
case "6": {_x = "STR_Crime_6"};
case "7": {_x = "STR_Crime_7"};
case "8": {_x = "STR_Crime_8"};
case "9": {_x = "STR_Crime_9"};
case "10": {_x = "STR_Crime_10"};
case "11": {_x = "STR_Crime_11"};
case "12": {_x = "STR_Crime_12"};
case "13": {_x = "STR_Crime_13"};
case "14": {_x = "STR_Crime_14"};
case "15": {_x = "STR_Crime_15"};
case "16": {_x = "STR_Crime_16"};
case "17": {_x = "STR_Crime_17"};
case "18": {_x = "STR_Crime_18"};
case "19": {_x = "STR_Crime_19"};
case "20": {_x = "STR_Crime_20"};
case "21": {_x = "STR_Crime_21"};
case "22": {_x = "STR_Crime_22"};
case "23": {_x = "STR_Crime_23"};
case "24": {_x = "STR_Crime_24"};
case "25": {_x = "STR_Crime_25"};
};
_crimesArr pushBack _x;
}forEach _type;
_queryResult set[0,_crimesArr];
[_queryResult] remoteExec ["life_fnc_wantedInfo",_ret];

View File

@@ -0,0 +1,49 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_wantedFetch.sqf
Author: Bryan "Tonic" Boardwine"
Database Persistence By: ColinM
Assistance by: Paronity
Stress Tests by: Midgetgrimm
This file is for Nanou's HeadlessClient.
Description:
Displays wanted list information sent from the server.
*/
private ["_ret","_list","_result","_queryResult","_units","_inStatement"];
_ret = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _ret) exitWith {};
_inStatement = "";
_list = [];
_units = [];
{if ((side _x) isEqualTo civilian) then {_units pushBack (getPlayerUID _x)};} forEach playableUnits;
if (_units isEqualTo []) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];};
{
if (count _units > 1) then {
if (_inStatement isEqualTo "") then {
_inStatement = "'" + _x + "'";
} else {
_inStatement = _inStatement + ", '" + _x + "'";
};
} else {
_inStatement = _x;
};
} forEach _units;
_query = format ["SELECT wantedID, wantedName FROM wanted WHERE active='1' AND wantedID in (%1)",_inStatement];
_queryResult = [_query,2,true] call HC_fnc_asyncCall;
diag_log format ["Query: %1",_query];
{
_list pushBack (_x);
}
forEach _queryResult;
if (_list isEqualTo []) exitWith {[_list] remoteExec ["life_fnc_wantedList",_ret];};
[_list] remoteExec ["life_fnc_wantedList",_ret];

View File

@@ -0,0 +1,21 @@
/*
File: fn_wantedPerson.sqf
Author: Bryan "Tonic" Boardwine"
Database Persistence By: ColinM
Assistance by: Paronity
Stress Tests by: Midgetgrimm
This file is for Nanou's HeadlessClient.
Description:
Fetches a specific person from the wanted array.
*/
private ["_unit","_index","_queryResult","_result"];
_unit = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _unit) exitWith {[]};
_uid = getPlayerUID player;
_query = format ["SELECT wantedID, wantedName, wantedBounty FROM wanted WHERE active='1' AND wantedID='%1'",_uid];
_queryResult = [_query,2] call HC_fnc_asyncCall;
if (_queryResult isEqualTo []) exitWith {[]};
_queryResult;

View File

@@ -0,0 +1,27 @@
#include "\life_hc\hc_macros.hpp"
/*
File: fn_wantedProfUpdate.sqf
Author: [midgetgrimm]
Persistence by: ColinM
This file is for Nanou's HeadlessClient.
Description:
Updates name of player if they change profiles
*/
private ["_uid","_name","_query","_tickTime","_wantedCheck","_wantedQuery"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
_name = [_this,1,"",[""]] call BIS_fnc_param;
//Bad data check
if (_uid isEqualTo "" || _name isEqualTo "") exitWith {};
_wantedCheck = format ["SELECT wantedName FROM wanted WHERE wantedID='%1'",_uid];
_wantedQuery = [_wantedCheck,2] call HC_fnc_asyncCall;
if (_wantedQuery isEqualTo []) exitWith {};
_wantedQuery = call compile format ["%1",_wantedQuery];
if !(_name isEqualTo (_wantedQuery select 0)) then {
_query = format ["UPDATE wanted SET wantedName='%1' WHERE wantedID='%2'",_name,_uid];
[_query,2] call HC_fnc_asyncCall;
};

View File

@@ -0,0 +1,18 @@
/*
File: fn_wantedRemove.sqf
Author: Bryan "Tonic" Boardwine"
Database Persistence By: ColinM
Assistance by: Paronity
Stress Tests by: Midgetgrimm
This file is for Nanou's HeadlessClient.
Description:
Removes a person from the wanted list.
*/
private ["_uid","_query"];
_uid = [_this,0,"",[""]] call BIS_fnc_param;
if (_uid isEqualTo "") exitWith {}; //Bad data
_query = format ["UPDATE wanted SET active = '0', wantedCrimes = '[]', wantedBounty = 0 WHERE wantedID='%1'",_uid];
[_query,2] call HC_fnc_asyncCall;