client/addons/init/functions/fnc_initPlayer.sqf
Jacob Schmidt d474b3676a
All checks were successful
Build / Build (push) Successful in 28s
Refactor: Standardize function descriptions and variable handling
This commit refactors several client-side functions to improve code consistency and readability.

- Standardizes function descriptions by removing redundant "Function: forge_client..." prefixes and "[Description]" sections, focusing on concise descriptions of the function's purpose.
- Updates variable handling in arsenal functions to use GVAR and EGVARS for default values, improving consistency and reducing code duplication.
- Removes the bank init function as it is no longer needed.
- Adds a done variable to the preinit file.
2025-05-25 11:30:26 -05:00

78 lines
2.3 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Initialize player
*
* Arguments:
* N/A
*
* Return Value:
* N/A
*
* Examples:
* [] call forge_client_init_fnc_initPlayer (Server or Singleplayer Only)
* [] remoteExecCall ["forge_client_init_fnc_initPlayer", 2, false] (Multiplayer Only)
*
* Public: Yes
*/
waitUntil { !isNull player };
waitUntil { player == player };
waitUntil { alive player };
removeAllWeapons player;
removeAllAssignedItems player;
removeUniform player;
removeVest player;
removeBackpack player;
removeGoggles player;
removeHeadgear player;
SETPVAR(player,GVAR(done),false);
cutText ["Loading In...", "BLACK", 1];
// ["hgetall", "", "", -1, [], "forge_client_init_fnc_handlePlayerLoad", true] spawn dragonfly_db_fnc_addTask;
["hgetallid", getPlayerUID player, "", -1, [], "forge_client_init_fnc_handlePlayerLoad", true, netId player] remoteExec ["dragonfly_db_fnc_addTask", 2, false];
[] spawn FUNC(playerSaveLoop);
[] spawn EFUNC(interaction,initInteraction);
waitUntil { GETVAR(player,GVAR(done),false) };
cutText ["", "PLAIN", 1];
waitUntil { !(isNull (findDisplay 46)) };
(findDisplay 46) displayAddEventHandler ["KeyDown", {
switch (_this select 1) do {
// Interaction Interface (default key TAB)
case ((configFile >> "CfgPatches" >> "forge_client_main" >> "interactionKey") call BFUNC(getCfgData)): {
[] call EFUNC(interaction,openInteraction);
false;
};
// Holster/Unholster (default key H)
case ((configFile >> "CfgPatches" >> "forge_client_main" >> "holsterKey") call BFUNC(getCfgData)): {
if ((currentWeapon player) != "" && !(GETVAR(player,FORGE_Holster_Weapon,true))) then {
player action ["SwitchWeapon", player, player, 299];
SETPVAR(player,FORGE_Holster_Weapon,true);
} else {
private _weapon = switch (true) do {
case ((primaryWeapon player) != ""): { primaryWeapon player };
case ((handgunWeapon player) != ""): { handgunWeapon player };
case ((secondaryWeapon player) != ""): { secondaryWeapon player };
default {""};
};
if (_weapon != "") then { player selectWeapon _weapon };
SETPVAR(player,FORGE_Holster_Weapon,false);
};
false;
};
// Open Phone (default key P)
case ((configFile >> "CfgPatches" >> "forge_client_main" >> "phoneKey") call BFUNC(getCfgData)): {
[] spawn EFUNC(phone,openPhone);
false;
};
default {
false;
};
};
}];