Commit 87f30d16 authored by Razer's avatar Razer
Browse files

Updated DB Functions

parent 371a2aa6
......@@ -32,7 +32,7 @@ params [["_player",objNull,[objNull,""]],["_clanUUID","",[""]],["_rank",100,[0]]
if(_player isEqualTo objNull || _clanUUID == "") exitWith {diag_log "<ApmsDB>: ERROR: Cannot add player to clan, invalid params!";false};
private _pUUID = [_player,_player getVariable ["pUUID",""]] select (_player isEqualType objNull);
private _pUUID = if (_player isEqualType objNull) then {_player getVariable ["pUUID",""]} else {_player};
if (_pUUID == "") exitWith {diag_log "<ApmsDB>: ERROR: Unable to add player to clan, no pUUID found!"}; // Make sure player object has pUUID
private _request = [PROTOCOL_DBCALL_FUNCTION_ADD_CLAN_PLAYER,[
......@@ -46,13 +46,11 @@ private _return = [_request] call DB_fnc_sendRequest;
if (_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {false}; // Use select 1 for "real" error code?
// Update players clanUUID variable
if(_player isEqualType []) then {
// Check if player is online if pUUID was used
private _playerObj = allPlayers select {_x getVariable ["pUUID",""] == _pUUID};
// Return objNull for scripted events if player is not online
_player = [objNull,_playerObj select 0] select (count _playerObj > 0);
// Get player object from pUUID
if(_player isEqualType "") then {
private _allPlayers = allPlayers;
private _index = _allPlayers findIf {_x getVariable ["pUUID",""] == _pUUID};
_player = [objNull,_allPlayers select _index] select (_index != -1);
};
// Add player clanUUID
......
......@@ -9,6 +9,8 @@
* https://www.bistudio.com/monetization/
*/
// TODO
/*
DESCRIPTION:
This function is used to update players previous clan data (Rank or Comment), or to add player in clan.
......
/*
* Desolation Redux
* http://desolationredux.com/
* © 2016 - 2020 Desolation Dev Team
*
* This work is licensed under the Arma Public License Share Alike (APL-SA) + Bohemia monetization rights.
* To view a copy of this license, visit:
* https://www.bistudio.com/community/licenses/arma-public-license-share-alike/
* https://www.bistudio.com/monetization/
*/
params [["_player",objNull,[objNull,""]]];
if(_player isEqualTo objNull) exitWith {};
private _pUUID = if (_player isEqualType objNull) then {_player getVariable ["pUUID",""]} else {_player};
if(_pUUID == "") exitWith {};
private _clanUUID = if(_player isEqualType "") then {
// Player is pUUID (Check if player is online)
private _allPlayers = allPlayers;
private _index = _allPlayers findIf {_x getVariable ["pUUID",""] == _pUUID};
_player = [objNull,_allPlayers select _index] select (_index != -1);
if(isNull _player) exitWith {
// Load player data from DB (Player is offline)
private _playerData = [_pUUID] call DB_fnc_getPlayerInfo;
if!(isNil "_playerData") exitWith {
_playerData select 3;
};
"" // Error loading data (Character with this pUUID not found?)
};
_player getVariable ["clanUUID",""];
} else {
_player getVariable ["clanUUID",""];
};
if (_clanUUID == "") exitWith {}; // Unable to get player clan
private _clanData = [_clanUUID] call DB_fnc_getClanData;
if (isNil "_clanData") exitWith {};
(_clanData select 1) == _pUUID
\ No newline at end of file
......@@ -55,12 +55,11 @@ private _request = [PROTOCOL_DBCALL_FUNCTION_UPDATE_PLAYER_MAIN_CLAN,[
if (_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {false}; // Use select 1 for "real" error code?
if(_player isEqualType []) then {
// Check if player is online if pUUID was used
private _playerObj = allPlayers select {_x getVariable ["pUUID",""] == _pUUID};
// Return objNull for scripted events if player is not online
_player = [objNull,_playerObj select 0] select (count _playerObj > 0);
// Get player object from pUUID
if(_player isEqualType "") then {
private _allPlayers = allPlayers;
private _index = _allPlayers findIf {_x getVariable ["pUUID",""] == _pUUID};
_player = [objNull,_allPlayers select _index] select (_index != -1);
};
// Remove player clanUUID
......
......@@ -39,7 +39,8 @@ if(_player isEqualTo objNull) exitWith {diag_log "<ApmsDB>: ERROR: Cannot create
if(_clanName == "") exitWith {diag_log "<ApmsDB>: ERROR: Cannot create clan. Invalid params: (missing name)";"noName"};
// Check pUUID
private _pUUID = [_player,_player getVariable ["pUUID",""]] select (_player isEqualType objNull);
private _pUUID = if (_player isEqualType objNull) then {_player getVariable ["pUUID",""]} else {_player};
if(_pUUID == "") exitWith {
diag_log format ["<ApmsDB>: ERROR: Player (%1) has invalid pUUID!",name _player];
"error"
......@@ -59,6 +60,18 @@ if(_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {[
private _clanUUID = _return select 0;
// Get player object from pUUID
if(_player isEqualType "") then {
private _allPlayers = allPlayers;
private _index = _allPlayers findIf {_x getVariable ["pUUID",""] == _pUUID};
_player = [objNull,_allPlayers select _index] select (_index != -1);
};
// Add player clanUUID
if!(isNull _player) then {
_player setVariable ["clanUUID",(_return select 0),true];
};
// Update mainclan
private _request = [PROTOCOL_DBCALL_FUNCTION_UPDATE_PLAYER_MAIN_CLAN,[
PROTOCOL_DBCALL_ARGUMENT_CLAN_UUID,_clanUUID,
......@@ -66,13 +79,6 @@ private _request = [PROTOCOL_DBCALL_FUNCTION_UPDATE_PLAYER_MAIN_CLAN,[
]];
[_request] call DB_fnc_sendRequest;
// Update clan list (TODO REMOVE ONCE VARIABLES WORK)
_clanList = ["DB_ClanList",[]] call DB_fnc_getWorldData;
_clanList pushBack [_clanName,_clanUUID,[]]; // _clanList select 2 == clan variables (for later use)
["DB_ClanList",_clanList] call DB_fnc_setWorldData;
_player setVariable ["clanUUID",_clanUUID,true];
["DB_onClanCreated",[_clanUUID,_clanName]] spawn BASE_fnc_addEventHandler; // Execute on failed also? (with params: [])
......
......@@ -23,11 +23,6 @@
[_clanUUID,"NewClanNAme"] call DB_fnc_updateClanName;
RETURNS:
"error"
"noName"
"exists"
"maxLetters"
["CLANUUID"] - ARRAY <-- if works
"error" // General error. (SQF or libredex (If error not defined))
"noName" // SQF (No name provided as param)
......
......@@ -23,11 +23,6 @@
[_clanUUID,_player] call DB_fnc_updateClanOwner;
RETURNS:
"error"
"noName"
"exists"
"maxLetters"
["CLANUUID"] - ARRAY <-- if works
"error" // General error. (SQF or libredex (If error not defined))
"leaveFirst" // LIBREDEX (Player already in another clan)
......
......@@ -23,7 +23,7 @@ if((!isNil "_pw") && _pw isEqualType "") then {
if(_timer != -1) then {
diag_log format ["STOPPING SERVER IN %1 MINUTES",_timer];
_text = format ["SERVER RESTARTING IN: %1, MINUTES!",_timer];
_text = format ["SERVER RESTARTING IN: %1 MINUTES!",_timer];
[
[
[_text,"align = 'left' shadow = '1' size = '0.9' font='PuristaBold'"]
......
/*
* Desolation Redux
* http://desolationredux.com/
* © 2016 - 2020 Desolation Dev Team
*
* This work is licensed under the Arma Public License Share Alike (APL-SA) + Bohemia monetization rights.
* To view a copy of this license, visit:
* https://www.bistudio.com/community/licenses/arma-public-license-share-alike/
* https://www.bistudio.com/monetization/
*/
params [["_player",objNull,[objNull,""]]];
private _pUUID = [_player,_player getVariable ["pUUID",""]] select (_player isEqualType objNull);
if(_pUUID == "") exitWith {};
private _request = [PROTOCOL_DBCALL_FUNCTION_LOAD_PLAYER_INFO,[PROTOCOL_DBCALL_ARGUMENT_PLAYER_UUID,_pUUID]];
private _return = [_request] call DB_fnc_sendRequest;
if(_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {};
_return
\ No newline at end of file
......@@ -59,6 +59,7 @@ _severity = if(_severity isEqualType 0) then {
};
// Get plugin name based on caller functions tag
if (isNil "_fnc_scriptNameParent" || {_fnc_scriptNameParent == _fnc_scriptName}) exitWith {diag_log "<PluginManager>: ERROR: Unable to log message. Called from uknnown source!"};
private _tag = (_fnc_scriptNameParent splitString "_") select 0;
private _pluginName = (missionNamespace getVariable ["BASE_var_pluginList",[]]) select {_x select 1 == _tag}; // Array
_pluginName = ["UKNOWN",(_pluginName select 0) select 0] select (count _pluginName > 0); // Modify array to actual string name
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment