#include "..\script_component.hpp"

/*
 * Function: forge_client_org_fnc_disband
 * Author: J. Schmidt
 * 
 * Description:
 * Disbands an organization if requested by the owner
 *
 * Arguments:
 * 0: _uid - UID of the player attempting to disband <STRING>
 * 1: _name - Organization name <STRING>
 *
 * Return Value:
 * Success <BOOL>
 */

params [["_uid", "", [""]], ["_name", "", [""]]];

if (_uid == "" || _name == "") exitWith { TRACE_2("Invalid parameters for disbanding organization",_uid,_name); false };

private _store = call FUNC(verifyOrgStore);
private _key = format ["%1_%2", _uid, _name];
private _org = _store call ["getByKey", [_key]];

if (isNil "_org") exitWith { TRACE_1("Organization not found",_key); false };
if ((_org get "owner") != _uid) exitWith { TRACE_2("Player is not the owner of this organization",_uid,_name); false };

_store call ["delete", [_key]];

TRACE_1("Organization disbanded successfully",_name);

true