Friday, September 20, 2024 3:00:25 AM
> settings

Customize


Authenticate

> ExileServerManager_system_territory_handlePlayer.sqf
/**
 * ExileServerManager_system_territory_handlePlayer
 *
 * Bryan
 * www.arcasindustries.com
 * © 2017 Arcas Industries
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */

private["_option", "_flagID", "_playerUID", "_playerToBeProcessedUID", "_flagObject", "_territoryID", "_ownerUID", "_moderators", "_buildRights", "_currentBuildRights", "_territoryName"];
_option = _this select 0;
_flagID = parseNumber(_this select 1);
_playerUID = _this select 2;
_playerToBeProcessedUID = _this select 3;
try
{
	_flagObject = _flagID call ExileServerManager_util_getFlagObject;
	if (isNull _flagObject) then
	{
		throw format["Could not find territory flag for %1", _flagID];
	};
	_territoryID = _flagObject getVariable ["ExileDatabaseID", -1];
	if (_territoryID isEqualTo -1) then
	{
		throw "Territory has no database ID.";
	};
	_ownerUID = _flagObject getVariable ["ExileOwnerUID", ""];
	if (_option isEqualTo "kick") then
	{
		if (_playerToBeProcessedUID isEqualTo _ownerUID) then
		{
			throw "Owners cannot leave territories.";
		};
		_moderators = _flagObject getVariable ["ExileTerritoryModerators", []];
		_buildRights = _flagObject getVariable ["ExileTerritoryBuildRights", []];
		if (_playerToBeProcessedUID isEqualTo _playerUID) then
		{
			throw "Cannot kick yourself";
		};
		if !(_playerUID in _moderators) then
		{
			throw "Only moderators can kick.";
		};
		_moderators = _moderators - [_playerToBeProcessedUID];
		_buildRights = _buildRights - [_playerToBeProcessedUID];
		_flagObject setVariable ["ExileTerritoryModerators", _moderators, true];
		_flagObject setVariable ["ExileTerritoryBuildRights", _buildRights, true];
		format["updateTerritoryBuildRights:%1:%2", _buildRights, _territoryID] call ExileServer_system_database_query_fireAndForget;
		format["updateTerritoryModerators:%1:%2", _moderators, _territoryID] call ExileServer_system_database_query_fireAndForget;
		if (ESM_DebugEnabled) then
		{
			format["%1 kicked %2 from %3", _playerUID, _playerToBeProcessedUID, _territoryID] call ExileServerManager_util_log;
		};
	}
	else
	{
		if (_playerUID isEqualTo _playerToBeProcessedUID) then
		{
			throw "Trying to add yourself, huh?";
		};
		if (_ownerUID isEqualTo _playerToBeProcessedUID) then
		{
			throw "The owner of this territory, you dont need build rights.";
		};
		_currentBuildRights = _flagObject getVariable ["ExileTerritoryBuildRights", []];
		if (_playerToBeProcessedUID in _currentBuildRights) then
		{
			throw "This player already has build rights.";
		};
		_territoryID = _flagObject getVariable ["ExileDatabaseID", -1];
		_territoryName = _flagObject getVariable ["ExileTerritoryName", ""];
		if (_territoryID isEqualTo -1) then
		{
			throw "Territory has no database ID.";
		};
		_currentBuildRights pushBack _playerToBeProcessedUID;
		_flagObject setVariable ["ExileTerritoryBuildRights", _currentBuildRights, true];
		format["updateTerritoryBuildRights:%1:%2", _currentBuildRights, _territoryID] call ExileServer_system_database_query_fireAndForget;
		if (ESM_DebugEnabled) then
		{
			format["%1 added %2 to %3", _playerUID, _playerToBeProcessedUID, _territoryID] call ExileServerManager_util_log;
		};
	};
}
catch
{
	_exception call ExileServerManager_util_log;
};
true
All opinions represented herein are my own
- © 2024 itsthedevman
- build 340fbb8