initial commit
This commit is contained in:
54
life_server/Functions/MySQL/fn_asyncCall.sqf
Normal file
54
life_server/Functions/MySQL/fn_asyncCall.sqf
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "\life_server\script_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;
|
||||
26
life_server/Functions/MySQL/fn_bool.sqf
Normal file
26
life_server/Functions/MySQL/fn_bool.sqf
Normal 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};
|
||||
};
|
||||
};
|
||||
};
|
||||
57
life_server/Functions/MySQL/fn_insertRequest.sqf
Normal file
57
life_server/Functions/MySQL/fn_insertRequest.sqf
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "\life_server\script_macros.hpp"
|
||||
/*
|
||||
File: fn_insertRequest.sqf
|
||||
Author: Bryan "Tonic" Boardwine
|
||||
|
||||
Description:
|
||||
Adds a player to the database upon first joining of the server.
|
||||
Recieves information from core\sesison\fn_insertPlayerInfo.sqf
|
||||
*/
|
||||
private ["_queryResult","_query","_alias"];
|
||||
params [
|
||||
"_uid",
|
||||
"_name",
|
||||
["_money",-1,[0]],
|
||||
["_bank",-1,[0]],
|
||||
["_returnToSender",objNull,[objNull]]
|
||||
];
|
||||
|
||||
//Error checks
|
||||
if ((_uid isEqualTo "") || (_name isEqualTo "")) exitWith {systemChat "Bad UID or name";}; //Let the client be 'lost' in 'transaction'
|
||||
if (isNull _returnToSender) exitWith {systemChat "ReturnToSender is Null!";}; //No one to send this to!
|
||||
|
||||
_query = format ["SELECT pid, name FROM players WHERE pid='%1'",_uid];
|
||||
|
||||
|
||||
_tickTime = diag_tickTime;
|
||||
_queryResult = [_query,2] call DB_fnc_asyncCall;
|
||||
|
||||
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
|
||||
diag_log "------------- Insert 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 "------------------------------------------------";
|
||||
};
|
||||
|
||||
//Double check to make sure the client isn't in the database...
|
||||
if (_queryResult isEqualType "") exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];}; //There was an entry!
|
||||
if !(count _queryResult isEqualTo 0) exitWith {[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];};
|
||||
|
||||
//Clense and prepare some information.
|
||||
_name = [_name] call DB_fnc_mresString; //Clense the name of bad chars.
|
||||
_alias = [[_name]] call DB_fnc_mresArray;
|
||||
_money = [_money] call DB_fnc_numberSafe;
|
||||
_bank = [_bank] call DB_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 DB_fnc_asyncCall;
|
||||
[] remoteExecCall ["SOCK_fnc_dataQuery",(owner _returnToSender)];
|
||||
24
life_server/Functions/MySQL/fn_insertVehicle.sqf
Normal file
24
life_server/Functions/MySQL/fn_insertVehicle.sqf
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
File: fn_insertVehicle.sqf
|
||||
Author: Bryan "Tonic" Boardwine
|
||||
|
||||
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 DB_fnc_asyncCall;
|
||||
27
life_server/Functions/MySQL/fn_mresArray.sqf
Normal file
27
life_server/Functions/MySQL/fn_mresArray.sqf
Normal 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));
|
||||
21
life_server/Functions/MySQL/fn_mresString.sqf
Normal file
21
life_server/Functions/MySQL/fn_mresString.sqf
Normal 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;
|
||||
26
life_server/Functions/MySQL/fn_mresToArray.sqf
Normal file
26
life_server/Functions/MySQL/fn_mresToArray.sqf
Normal 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;
|
||||
28
life_server/Functions/MySQL/fn_numberSafe.sqf
Normal file
28
life_server/Functions/MySQL/fn_numberSafe.sqf
Normal 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
|
||||
160
life_server/Functions/MySQL/fn_queryRequest.sqf
Normal file
160
life_server/Functions/MySQL/fn_queryRequest.sqf
Normal file
@@ -0,0 +1,160 @@
|
||||
#include "\life_server\script_macros.hpp"
|
||||
/*
|
||||
File: fn_queryRequest.sqf
|
||||
Author: Bryan "Tonic" Boardwine
|
||||
|
||||
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 {};
|
||||
_ownerID = owner _ownerID;
|
||||
|
||||
_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 DB_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 {
|
||||
[] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
|
||||
};
|
||||
|
||||
if (count _queryResult isEqualTo 0) exitWith {
|
||||
[] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
|
||||
};
|
||||
|
||||
//Blah conversion thing from a2net->extdb
|
||||
_tmp = _queryResult select 2;
|
||||
_queryResult set[2,[_tmp] call DB_fnc_numberSafe];
|
||||
_tmp = _queryResult select 3;
|
||||
_queryResult set[3,[_tmp] call DB_fnc_numberSafe];
|
||||
|
||||
//Parse licenses (Always index 6)
|
||||
_new = [(_queryResult select 6)] call DB_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 DB_fnc_bool)]];
|
||||
};
|
||||
|
||||
_queryResult set[6,_old];
|
||||
|
||||
_new = [(_queryResult select 8)] call DB_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 DB_fnc_bool)];
|
||||
|
||||
//Parse Stats
|
||||
_new = [(_queryResult select 10)] call DB_fnc_mresToArray;
|
||||
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
|
||||
_queryResult set[10,_new];
|
||||
|
||||
//Playtime
|
||||
_new = [(_queryResult select 11)] call DB_fnc_mresToArray;
|
||||
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
|
||||
_index = TON_fnc_playtime_values_request find [_uid, _new];
|
||||
if (_index != -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];
|
||||
};
|
||||
[_uid,_new select 0] call TON_fnc_setPlayTime;
|
||||
};
|
||||
|
||||
case civilian: {
|
||||
_queryResult set[7,([_queryResult select 7,1] call DB_fnc_bool)];
|
||||
|
||||
//Parse Stats
|
||||
_new = [(_queryResult select 9)] call DB_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 DB_fnc_bool)];
|
||||
_new = [(_queryResult select 11)] call DB_fnc_mresToArray;
|
||||
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
|
||||
_queryResult set[11,_new];
|
||||
|
||||
//Playtime
|
||||
_new = [(_queryResult select 12)] call DB_fnc_mresToArray;
|
||||
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
|
||||
_index = TON_fnc_playtime_values_request find [_uid, _new];
|
||||
if (_index != -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];
|
||||
};
|
||||
[_uid,_new select 2] call TON_fnc_setPlayTime;
|
||||
|
||||
/* Make sure nothing else is added under here */
|
||||
_houseData = _uid spawn TON_fnc_fetchPlayerHouses;
|
||||
waitUntil {scriptDone _houseData};
|
||||
_queryResult pushBack (missionNamespace getVariable [format ["houses_%1",_uid],[]]);
|
||||
_gangData = _uid spawn TON_fnc_queryPlayerGang;
|
||||
waitUntil{scriptDone _gangData};
|
||||
_queryResult pushBack (missionNamespace getVariable [format ["gang_%1",_uid],[]]);
|
||||
|
||||
};
|
||||
|
||||
case independent: {
|
||||
//Parse Stats
|
||||
_new = [(_queryResult select 9)] call DB_fnc_mresToArray;
|
||||
if (_new isEqualType "") then {_new = call compile format ["%1", _new];};
|
||||
_queryResult set[9,_new];
|
||||
|
||||
//Playtime
|
||||
_new = [(_queryResult select 10)] call DB_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];
|
||||
};
|
||||
[_uid,_new select 1] call TON_fnc_setPlayTime;
|
||||
};
|
||||
};
|
||||
|
||||
publicVariable "TON_fnc_playtime_values_request";
|
||||
|
||||
_keyArr = missionNamespace getVariable [format ["%1_KEYS_%2",_uid,_side],[]];
|
||||
_queryResult pushBack _keyArr;
|
||||
|
||||
_queryResult remoteExec ["SOCK_fnc_requestReceived",_ownerID];
|
||||
86
life_server/Functions/MySQL/fn_updatePartial.sqf
Normal file
86
life_server/Functions/MySQL/fn_updatePartial.sqf
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
File: fn_updatePartial.sqf
|
||||
Author: Bryan "Tonic" Boardwine
|
||||
|
||||
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 DB_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 DB_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 DB_fnc_bool;
|
||||
_value set[_i,[(_value select _i) select 0,_bool]];
|
||||
};
|
||||
_value = [_value] call DB_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 DB_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 DB_fnc_bool;
|
||||
_value2 = [_this,4,[],[[]]] call BIS_fnc_param;
|
||||
_value2 = if (count _value2 isEqualTo 3) then {_value2} else {[0,0,0]};
|
||||
_value2 = [_value2] call DB_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 DB_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 DB_fnc_numberSafe;
|
||||
_value2 = [_value2] call DB_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] call TON_fnc_keyManagement;
|
||||
};
|
||||
};
|
||||
|
||||
if (_query isEqualTo "") exitWith {};
|
||||
|
||||
[_query,1] call DB_fnc_asyncCall;
|
||||
64
life_server/Functions/MySQL/fn_updateRequest.sqf
Normal file
64
life_server/Functions/MySQL/fn_updateRequest.sqf
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
File: fn_updateRequest.sqf
|
||||
Author: Bryan "Tonic" Boardwine
|
||||
|
||||
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","_thread"];
|
||||
_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 DB_fnc_mresString;
|
||||
_gear = [_gear] call DB_fnc_mresArray;
|
||||
_stats = [_stats] call DB_fnc_mresArray;
|
||||
_cash = [_cash] call DB_fnc_numberSafe;
|
||||
_bank = [_bank] call DB_fnc_numberSafe;
|
||||
_position = if (_side isEqualTo civilian) then {[_position] call DB_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 DB_fnc_bool;
|
||||
_licenses set[_i,[(_licenses select _i) select 0,_bool]];
|
||||
};
|
||||
|
||||
_licenses = [_licenses] call DB_fnc_mresArray;
|
||||
|
||||
//PLAYTIME
|
||||
_playtime = [_uid] call TON_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 DB_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 DB_fnc_bool,_stats,[_alive] call DB_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 DB_fnc_asyncCall;
|
||||
Reference in New Issue
Block a user