Commit f1d0afea authored by Razer's avatar Razer
Browse files

Updated clan functions

parent ab3942b4
/*
* 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/
*/
/*
DESCRIPTION:
This function is used to get players main clan using pUUID.
PARAMS:
1 - OBJECT or STRING: Player object or pUUID
USAGE:
// Works even if player is offline
_clanUUID = [_pUUID] call DB_fnc_getPlayerClan;
_clanUUID = [_player] call DB_fnc_getPlayerClan;
// Same as (_player getVariable ["clanUUID",""]);
RETURNS:
Nil in case of error
STRING: ClanUUID (Empty string if not in a clan)
*/
// Client request
if(!isServer) exitWith {_this call DB_fnc_serverRequest};
#include "\ApmsDB\constants.hpp"
params [["_playerParam","",[objNull,""]]];
if (_playerParam isEqualType objNull) exitWith {
if (isNull _playerParam) exitWith {}; // error
_playerParam getVariable ["clanUUID",""]
};
private _request = [PROTOCOL_DBCALL_FUNCTION_LOAD_PLAYER_GROUPS,[PROTOCOL_DBCALL_ARGUMENT_PLAYER_UUID,_playerParam]];
private _return = [_request] call DB_fnc_sendRequest;
if (_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {};
private _clanUUID = _return select 0;
// Return data to client
if(isRemoteExecuted && {remoteExecutedOwner != 2}) exitWith {
[missionNamespace,[("DB_var_response_" + _fnc_scriptName),_clanUUID]] remoteExecCall ["setVariable",remoteExecutedOwner];
};
_clanUUID
\ No newline at end of file
......@@ -45,10 +45,8 @@ private _clanUUID = if(_player isEqualType "") then {
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;
};
private _playerClan = [_pUUID] call DB_fnc_getPlayerClan;
if!(isNil "_playerData") exitWith {_playerClan};
"" // Error loading data (Character with this pUUID not found?)
};
......@@ -62,9 +60,11 @@ if (_clanUUID == "") exitWith {false}; // Unable to get player clan
private _clanData = [_clanUUID] call DB_fnc_getClanData;
if (isNil "_clanData") exitWith {false};
private _result = (_clanData select 2) == _pUUID;
// Return data to client
if(isRemoteExecuted && {remoteExecutedOwner != 2}) exitWith {
[missionNamespace,[("DB_var_response_" + _fnc_scriptName),((_clanData select 2) == _pUUID)]] remoteExecCall ["setVariable",remoteExecutedOwner];
[missionNamespace,[("DB_var_response_" + _fnc_scriptName),_result]] remoteExecCall ["setVariable",remoteExecutedOwner];
};
(_clanData select 2) == _pUUID
\ No newline at end of file
_result
\ No newline at end of file
......@@ -58,7 +58,7 @@ private _request = [PROTOCOL_DBCALL_FUNCTION_CREATE_CLAN,[
PROTOCOL_DBCALL_ARGUMENT_CLANNAME,_clanName
]];
private _return = [_request] call DB_fnc_sendRequest; // Returns array: ["clanUUID"], or error code
if(_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {["error",_return select 1] select (_return select 1 != "")};
if(_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {["error",_return select 1] select (!((_return select 1) isEqualTo ""))};
private _clanUUID = _return select 0;
......
......@@ -50,7 +50,7 @@ private _request = [PROTOCOL_DBCALL_FUNCTION_GET_CLAN,[PROTOCOL_DBCALL_ARGUMENT_
private _return = [_request] call DB_fnc_sendRequest;
// Make sure data is correct
if (_return isEqualType [] && {_return select 0 isEqualTo "error"}) exitWith {};
if (_return isEqualType [] && {(_return select 0) isEqualTo "error"}) exitWith {};
// Redefine data based on settings (if used)
if (_option != "" && _option != "all") then {
......
/*
* 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
......@@ -164,6 +164,7 @@ class CfgFunctions
class addClanPlayer {};
class removeClanPlayer {};
class updateClanPlayer {};
class getPlayerClan {isGlobal = 1;};
class isClanOwner {isGlobal = 1;};
class isClanMember {isGlobal = 1;};
};
......
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