client/addons/org/functions/fnc_create.sqf
Jacob Schmidt c87deec60b
All checks were successful
Build / Build (push) Successful in 26s
Refactor: Organization Funds, Reputation, Tasks, and Player Saving
This commit refactors how organization funds and reputation are handled, updates task completion logic to use the new organization functions, and modifies player saving to include organization data. Additionally, it introduces string serialization/deserialization and fixes a player save loop.

*   **Organization Funds and Reputation:** Replaces direct server calls for handling funds and reputation with calls to the new organization functions (`EFUNC(org,addFunds)` and `EFUNC(org,addReputation)`). This centralizes fund and reputation management within the organization store.
*   **Task Completion Logic:** Updates task completion functions (`fnc_destroy.sqf`, `fnc_attack.sqf`, `fnc_hostage.sqf`, `fnc_hvt.sqf`, `fnc_defuse.sqf`) to use the new organization functions for adding funds and reputation upon task success or failure. Also adds notifications to inform the player of reputation and fund changes.
*   **Player Saving:** Modifies the player saving function (`fnc_playerDBSave.sqf`) to include the player's organization ID in the saved data.
*   **String Serialization/Deserialization:** Adds `serializeString` and `deserializeString` PREP macros to `XEH_PREP.hpp` and uses them in `fnc_handleOrgLoad.sqf` and `fnc_create.sqf` to handle special characters in organization and member names.
*   **Player Save Loop Fix:** Removes unnecessary brackets from the `call FUNC(playerDBSave)` in `fnc_playerSaveLoop.sqf`.
*   **Organization Purchase Verification:** Adds organization ownership verification to `fnc_handlePurchase.sqf` to ensure only the owner can make purchases using organization funds.
*   **Player Initialization:** Updates `fnc_initPlayer.sqf` to retrieve and set the player's organization upon initialization.
2025-04-05 14:16:24 -05:00

51 lines
1.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: J. Schmidt
* Creates a new organization for a player.
* Initializes the organization with the specified name, owner, and optional starting funds and reputation.
*
* Arguments:
* 0: Owner UID <STRING> - Player UID who will own the organization
* 1: Organization Name <STRING> - Name of the organization
* 2: Initial Funds <NUMBER> (Optional, default: 0) - Starting funds for the organization
* 3: Initial Reputation <NUMBER> (Optional, default: 0) - Starting reputation for the organization
*
* Return Value:
* Organization Data <HASHMAP> - The newly created organization data, or nil if creation failed
*
* Example:
* [getPlayerUID player, "Alpha Squad", 5000, 100] call forge_client_org_fnc_create
* [getPlayerUID player, "Bravo Team"] call forge_client_org_fnc_create // With default funds and reputation
*
* Public: Yes
*/
params [
["_ownerUID", "", [""]],
["_name", "", [""]],
["_initialFunds", 0, [0]],
["_initialReputation", 0, [0]]
];
// Validate input parameters
if (_ownerUID == "" || _name == "") exitWith {
["Invalid parameters for organization creation", "error", 5, "right"] call forge_client_misc_fnc_notify;
nil
};
// Get the organization store interface
private _store = call FUNC(verifyOrgStore);
// Create the organization with the provided parameters
private _orgData = _store call ["createOrg", [_ownerUID, _name, _initialFunds, _initialReputation]];
// Provide feedback based on success or failure
if (isNil "_orgData") then {
[format ["Failed to create organization '%1'", _name], "error", 5, "right"] call forge_client_misc_fnc_notify;
} else {
[format ["Organization '%1' created successfully", _name], "success", 5, "right"] call forge_client_misc_fnc_notify;
};
// Return the organization data for further operations
_orgData