big refactor, WIP!
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
diag_log text "[MILSIM] (client) initializing Stats PFH";
|
||||
|
||||
_cpsPFH = [
|
||||
{
|
||||
[] call milsim_fnc_calculateClientStats;
|
||||
},
|
||||
"milsim_client_cps_interval" call CBA_settings_fnc_get,
|
||||
[],
|
||||
{ diag_log text format ["[MILSIM] (client) PFH loaded with interval %1 seconds", "milsim_client_cps_interval" call CBA_settings_fnc_get ] },
|
||||
{ diag_log text format ["[MILSIM] (client) PFH unloaded"] },
|
||||
{ "milsim_client_cps_enable" call CBA_settings_fnc_get },
|
||||
{ false },
|
||||
[]
|
||||
] call CBA_fnc_createPerFrameHandlerObject;
|
||||
|
||||
player setVariable ["milsim_client_cps_handler", _cpsPFH];
|
||||
@@ -1,87 +0,0 @@
|
||||
if ( !hasInterface ) exitWith {};
|
||||
|
||||
diag_log text "[MILSIM] (DNI) writing variable loop";
|
||||
|
||||
[] spawn {
|
||||
while {true} do {
|
||||
player setVariable ["DNI_PlayerFPS", floor diag_fps, true];
|
||||
sleep 1
|
||||
};
|
||||
};
|
||||
|
||||
diag_log text "[MILSIM] (DNI) variable loop complete";
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//Waits until curators are initalized in order to check//
|
||||
//if player is zeus to run the fps scripts //
|
||||
/////////////////////////////////////////////////////////
|
||||
diag_log text "[MILSIM] (DNI) waiting for curators";
|
||||
|
||||
waitUntil {
|
||||
private _hasCurators = (count allcurators) > 0;
|
||||
private _hasInitializedCurators = (count (call BIS_fnc_listCuratorPlayers)) > 0;
|
||||
private _curatorsInitialized = !_hasCurators || _hasInitializedCurators;
|
||||
((time > 2) || _curatorsInitialized)
|
||||
};
|
||||
|
||||
diag_log text "[MILSIM] (DNI) curator init complete";
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//If player is a curator it will run the script and each/
|
||||
//player will have their FPS appear beneath them //
|
||||
/////////////////////////////////////////////////////////
|
||||
if (player in (call bis_fnc_listcuratorplayers)) then {
|
||||
|
||||
diag_log text "[MILSIM] (DNI) player is in curator list, adding Draw3D handler";
|
||||
|
||||
addMissionEventHandler ["Draw3D", {
|
||||
{
|
||||
_distance = position curatorCamera distance _x;
|
||||
//if zeus camera is farther than 1200 meters away from the targets the text will not display
|
||||
if (_distance < 1200) then {
|
||||
_playerFPS = _x getVariable ["DNI_PlayerFPS",50];
|
||||
//if the FPS is below 20 it turns red and becomes more visible for zeus to see so they are aware
|
||||
if (_playerFPS <20) then
|
||||
{
|
||||
drawIcon3D
|
||||
[
|
||||
"",//Path to image displayed near text
|
||||
[1,0,0,0.7],//color of the text using RGBA
|
||||
position _x,//position of the text _x referring to the player in 'allPlayers'
|
||||
1,//Width
|
||||
2,//height from position, below
|
||||
0,//angle
|
||||
format["%1 FPS: %2", name _x, str _playerFPS],//text to be displayed
|
||||
0,//shadow on text, 0=none,1=shadow,2=outline
|
||||
0.05,//text size
|
||||
"PuristaMedium",//text font
|
||||
"center"//align text left, right, or center
|
||||
];
|
||||
}
|
||||
//if the FPS is above 20 text is smaller and less visible as to not conern zeus as much
|
||||
else
|
||||
{
|
||||
drawIcon3D
|
||||
[
|
||||
"",//Path to image displayed near text
|
||||
[1,1,1,0.3],//color of the text using RGBA
|
||||
position _x,//position of the text _x referring to the player in 'allPlayers'
|
||||
1,//Width
|
||||
2,//height from position, below
|
||||
0,//angle
|
||||
format["%1 FPS: %2", name _x, str _playerFPS],//text to be displayed
|
||||
0,//shadow on text, 0=none,1=shadow,2=outline
|
||||
0.03,//text size
|
||||
"PuristaMedium",//text font
|
||||
"center"//align text left, right, or center
|
||||
];
|
||||
};
|
||||
};
|
||||
} forEach allPlayers;
|
||||
//Here is the array of units you wish to display the FPS text for, it can be
|
||||
//changed to be an array of specific units or players if you wish
|
||||
}];
|
||||
};
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////End FPS Script//////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
@@ -1,29 +0,0 @@
|
||||
[] spawn {
|
||||
// warning: while loop without suspension executes multiple times per frame
|
||||
private _counter = 0;
|
||||
private _endTime = diag_tickTime + 5;
|
||||
private _frameNo = diag_frameNo;
|
||||
while { diag_tickTime < _endTime } do
|
||||
{
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
// in an empty mission, the _counter may go well over 2000 times per frame!
|
||||
diag_log text format ["[MILSIM] (client) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)];
|
||||
player setVariable ["milsim_player_raw_cps", _counter / (diag_frameNo - _frameNo), true];
|
||||
|
||||
// with suspension
|
||||
private _counter = 0;
|
||||
private _endTime = diag_tickTime + 5;
|
||||
private _frameNo = diag_frameNo;
|
||||
while { diag_tickTime < _endTime } do
|
||||
{
|
||||
_counter = _counter + 1;
|
||||
uiSleep 0.001; // waits at least 1 frame
|
||||
};
|
||||
// _counter says one per frame, as expected
|
||||
diag_log text format ["[MILSIM] (client) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)];
|
||||
player setVariable ["milsim_player_cps", _counter / (diag_frameNo - _frameNo), true];
|
||||
|
||||
};
|
||||
|
||||
nil;
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
if ( !hasInterface ) exitWith {};
|
||||
|
||||
player addEventHandler["Respawn",
|
||||
@@ -6,10 +8,11 @@ player addEventHandler["Respawn",
|
||||
private _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"];
|
||||
if (_killer == "respawn_button") then {
|
||||
[
|
||||
"client",
|
||||
LEVEL_INFO
|
||||
QUOTE(COMPONENT),
|
||||
"RESPAWNED WHILE UNCONSCIOUS",
|
||||
[_unit] call milsim_util_fnc_addPlayerInfoToArray
|
||||
] remoteExec ["milsim_util_fnc_log", 2];
|
||||
[_unit] call EFUNC(common,addPlayerInfoToArray)
|
||||
] remoteExec [QEFUNC(common,log), 2];
|
||||
// format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0];
|
||||
};
|
||||
}
|
||||
@@ -43,11 +46,11 @@ addMissionEventHandler ["HandleChatMessage",
|
||||
|
||||
|
||||
["ace_arsenal_displayClosed", {
|
||||
[player] remoteExec ["milsim_util_fnc_logPlayerInventory", 2];
|
||||
[player] remoteExec [QEFUNC(common,logPlayerInventory), 2];
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
[missionNamespace, "arsenalClosed", {
|
||||
[player] remoteExec ["milsim_util_fnc_logPlayerInventory", 2];
|
||||
[player] remoteExec [QEFUNC(common,logPlayerInventory), 2];
|
||||
}] call BIS_fnc_addScriptedEventHandler;
|
||||
|
||||
diag_log text "[MILSIM] (client) event handlers bound";
|
||||
3
framework/client/script_component.hpp
Normal file
3
framework/client/script_component.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#define COMPONENT client
|
||||
#define COMPONENT_BEAUTIFIED Client
|
||||
#include "../script_mod.hpp"
|
||||
Reference in New Issue
Block a user