client/addons/org/functions/fnc_leave.sqf
Jacob Schmidt 613f05d52a Refactor: Database and Client Updates
This commit introduces several changes related to database interactions and client-side functionality:

*   **Database Response Handling:** Implements a mechanism to handle responses from server requests, specifically for database operations. This includes setting up a callback system to process results based on request IDs.
*   **Store Functionality:** Corrects a typo in the `fnc_buyItem.sqf` script, changing `EFUNC(armory,addArmoryItem)` to `EFUNC(arsenal,addArmoryItem)`.
*   **Inventory Management:** Improves the `fnc_moveInventory.sqf` script by correcting a conditional statement to ensure proper handling of inventory items.
*   **Configuration Updates:** Updates the mod configuration (`CfgMods.hpp`) to use the correct path for the mod picture.
*   **Client Initialization:** Adds a client registration call to the server during client post-initialization (`XEH_postInit_client.sqf`).
*   **Workflow Update:** Updates the build workflow to use the latest Ubuntu runner.
*   **Database Preparation:** Removes unnecessary preparations from `XEH_postInit.sqf` and `XEH_PREP.hpp`.
2025-03-28 09:46:24 -05:00

50 lines
1.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: forge_client_org_fnc_leave
* Author: J. Schmidt
*
* Description:
* Removes a player from an organization
*
* Arguments:
* 0: _ownerUID - Organization owner's UID <STRING>
* 1: _orgName - Organization name <STRING>
* 2: _playerUID - Player's UID who is leaving <STRING>
* 3: _playerName - Player's name who is leaving <STRING>
*
* Return Value:
* Success <BOOL>
*/
params [["_ownerUID", "", [""]], ["_orgName", "", [""]], ["_playerUID", "", [""]], ["_playerName", "", [""]]];
if (_ownerUID == "" || _orgName == "" || _playerUID == "" || _playerName == "") exitWith { TRACE_4("Invalid parameters for leaving organization",_ownerUID,_orgName,_playerUID,_playerName); false };
private _store = call FUNC(verifyOrgStore);
private _key = format ["%1_%2", _ownerUID, _orgName];
private _org = _store call ["getByKey", [_key]];
private _timestamp = systemTimeUTC apply { if (_x < 10) then { "0" + str _x } else { str _x }};
private _dateTime = format ["%1-%2-%3_%4:%5:%6.%7", _timestamp#0, _timestamp#1, _timestamp#2, _timestamp#3, _timestamp#4, _timestamp#5, _timestamp#6];
if (isNil "_org") exitWith { TRACE_1("Organization not found", _key); false };
private _members = _org get "members";
private _logs = _org get "logs";
if (isNil { _members get _playerUID }) exitWith { TRACE_2("Player not in this organization",_playerUID,_orgName); false };
private _memberData = _members get _playerUID;
if (_memberData get "rank" == "owner") exitWith { TRACE_2("Owner cannot leave organization, must transfer ownership first",_playerUID,_orgName); false };
_logs pushBack [_dateTime, "LEAVE", _playerName, _playerUID];
_org set ["logs", _logs];
_members deleteAt _playerUID;
_org set ["members", _members];
_store call ["post", [_ownerUID, _orgName]];
true