Thursday, June 04, 2026 5:16:10 AM
> project show esm_alpha
The experimental first version of ESM that connected Arma 3 Exile servers to a PHP website. This college project prototype established the core concepts that would evolve into the ESM ecosystem.
Details
> payTerritory.sqf
/*
	Bryan
	Exile Server Manager
	Fires from a request when a player wants to pay a territory
*/


_flagID = parseNumber(_this select 0);
_playerUID = _this select 1;

try
{
	_flagObject = _flagID call ExileServerManager_util_getFlagObject;

	if (isNull _flagObject) then
	{
		throw "Invalid flag object";
	};

	_flagStolen = _flagObject getVariable ["ExileFlagStolen", 0];

	if (_flagStolen isEqualTo 1) then
	{
		throw "Flag stolen!";
	};

	// Calculate required amounts
	_territoryDatabaseID = _flagObject getVariable ["ExileDatabaseID", 0];
	_radius = _flagObject getVariable ["ExileTerritorySize", 15];
	_level = _flagObject getVariable ["ExileTerritoryLevel", 1];

	// Not needed anymore
	//_objectsInTerritory = 1 + (count (_flagObject nearObjects ["Exile_Construction_Abstract_Static", _radius]));
	_objectsInTerritory = _flagObject getVariable ["ExileTerritoryNumberOfConstructions", 0];

	// Calculate the amount of pop tabs required
	_popTabAmountPerObject = getNumber (missionConfigFile >> "CfgTerritories" >> "popTabAmountPerObject");
	_totalPopTabAmount = _level * _popTabAmountPerObject * _objectsInTerritory;

	_playerObject = _playerUID call ExileClient_util_player_objectFromPlayerUID;

	// The player is online
	if !(isNull(_playerObject)) then
	{
		_playerMoney = _playerObject getVariable ["ExileLocker",0];

		if (_playerMoney < _territoryPrice) then
		{
			throw "Not enough pop tabs!";
		};

		_playerMoney = _playerMoney - _totalPopTabAmount;
		_playerObject setVariable ["ExileLocker", _playerMoney];
	}
	else
	{
		_playerMoney = format["getLocker:%1", _playerUID] call ExileServer_system_database_query_selectSingleField;

		if (_playerMoney < _totalPopTabAmount) then
		{
			throw "Not enough pop tabs!";
		};

		_playerMoney = _playerMoney - _totalPopTabAmount;
	};

	format["updateLocker:%1:%2", _playerMoney, _playerUID] call ExileServer_system_database_query_fireAndForget;

	// Extend the due date of the territory
	_currentTimestamp = call ExileServer_util_time_currentTime;
	_flagObject setVariable ["ExileTerritoryLastPayed", _currentTimestamp];
	_flagObject call ExileServer_system_territory_maintenance_recalculateDueDate;

	// Save the due date in the database
	format["maintainTerritory:%1", _territoryDatabaseID] call ExileServer_system_database_query_fireAndForget;

	//extDB2 logging
	_logging = getNumber(configFile >> "CfgSettings" >> "Logging" >> "territoryLogging");
	if (_logging isEqualTo 1) then
	{
		_territoryLog = format ["PLAYER ( %1 ) PAID %2 POP TABS VIA THE ONLINE PORTAL TO PROTECT TERRITORY #%3 | PLAYER TOTAL POP TABS: %4",_playerUID,_totalPopTabAmount,_territoryDatabaseID,_playerMoney];
		"extDB2" callExtension format["1:TERRITORY:%1",_territoryLog];
	};

	// Send a broadcast on the XM8
	_flagObject call ExileServer_system_xm8_sendProtectionMoneyPaid;
}
catch
{
	// Log the error message in the database so we know whats up
	_exception call ExileServerManager_util_log;
};
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 4294fb2