Skip to content

Commit

Permalink
Added support for new session tracking server
Browse files Browse the repository at this point in the history
Removed old remote statistic tracking
Added statistics for revives and enemy kills
Added build number to description.ext
  • Loading branch information
CaptainPStar committed Aug 29, 2023
1 parent 93a6fa3 commit d5ea228
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Code/Revive
5 changes: 4 additions & 1 deletion Code/description.ext
Expand Up @@ -22,6 +22,7 @@ EscapeIsland = ISLAND;
EscapeMod = MOD;
EscapeVersion = VERSION;
EscapeRelease = RELEASE;
EscapeBuild = BUILD;
cba_settings_hasSettingsFile = 1;

class Extended_PreInit_EventHandlers {
Expand Down Expand Up @@ -209,7 +210,9 @@ class RscTitles {
};
class CfgCommands {
allowedHTMLLoadURIs[] += {
"http://escape.anzp.de/track.php*"
"http://escape.anzp.de/track.php*",
"http://co10esc.anzp.de/api*",
"http://localhost:5093/api/session*"
};
};
class CfgLeaflets
Expand Down
2 changes: 1 addition & 1 deletion Code/functions/Server/fn_endMissionServer.sqf
@@ -1,4 +1,4 @@
params["_end"];

[_end] call A3E_fnc_EndSession;
[_end] call A3E_fnc_SaveStatistics;
_end call BIS_fnc_endMissionServer;
10 changes: 10 additions & 0 deletions Code/functions/Server/fn_initServer.sqf
Expand Up @@ -554,6 +554,16 @@ call A3E_fnc_InitTraps;
_unit unlinkItem _hmd;
_unit removeItem _hmd;
};

//Track kills
_unit addEventHandler ["Killed", {
params ["_unit", "_killer"];
if(isPlayer _killer) then {
private _killStats = missionNamespace getvariable ["A3E_Kill_Count",0];
missionNamespace setvariable ["A3E_Kill_Count",_killStats+1,false];
};
}];

//_unit setSkill a3e_var_Escape_enemyMinSkill;
//[_unit, a3e_var_Escape_enemyMinSkill] call EGG_EVO_skill;

Expand Down
13 changes: 12 additions & 1 deletion Code/functions/Spawning/fn_onEnemySoldierSpawn.sqf
Expand Up @@ -128,4 +128,15 @@ if ("Rangefinder" in (assignedItems _unit)) then {
};
if(A3E_Param_UseIntel==1) then {
[_unit] call A3E_fnc_AddIntel;
};
};



//Track kills
_unit addEventHandler ["Killed", {
params ["_unit", "_killer"];
if(isPlayer _killer) then {
private _killStats = missionNamespace getvariable ["A3E_Kill_Count",0];
missionNamespace setvariable ["A3E_Kill_Count",_killStats+1,false];
};
}];
36 changes: 36 additions & 0 deletions Code/functions/Statistics/fn_EndSession.sqf
@@ -0,0 +1,36 @@
params["_endtype"];


if(A3E_Param_SendStatistics == 1) then {

private _island = getText (missionConfigFile >> "EscapeIsland");
private _mod = getText (missionConfigFile >> "EscapeMod");
private _version = getText (missionConfigFile >> "EscapeVersion");
private _release = getText (missionConfigFile >> "EscapeRelease");
private _build = getText (missionConfigFile >> "EscapeBuild");
private _players = str count(call BIS_fnc_listPlayers);
private _servername = serverName;
private _guid = missionNamespace getvariable ["A3E_SessionGUID","00000000000-00000000000"];
private _revives = missionNamespace getvariable ["A3E_Revive_Count",0];
private _kills = missionNamespace getvariable ["A3E_Kill_Count",0];
// replace with the actual server URL where your API is hosted

private _baseURL = "http://co10esc.anzp.de/api/session/";


private _uri = _baseURL + "endsession?"
+"uid="+_guid
+"&kills="+str _kills
+"&revives="+str _revives
+"&end=" + _endtype;

"DummyLayer" cutRsc ["RscTitleDisplayEmpty", "PLAIN"];
private _emptyDisplay = uiNamespace getVariable "RscTitleDisplayEmpty";
private _html = _emptyDisplay ctrlCreate ["RscHTML", -1];
_html ctrlSetBackgroundColor [0,0,0,1];
_html ctrlSetPosition [0,0,0,0];
_html ctrlCommit 0;
_html htmlLoad _uri;
_emptyDisplay closeDisplay 1;

};
17 changes: 4 additions & 13 deletions Code/functions/Statistics/fn_SaveStatistics.sqf
@@ -1,5 +1,9 @@
params["_endType"];



private _statisticsCollected = missionNamespace getvariable ["A3E_EndStatisticsCollected",false];

if(!_statisticsCollected) then {
missionNamespace setvariable ["A3E_EndStatisticsCollected",true];
private _island = getText (missionConfigFile >> "EscapeIsland");
Expand All @@ -14,17 +18,4 @@ if(!_statisticsCollected) then {
profileNamespace setVariable ["A3E_Statistics", _statistics];
missionNamespace setvariable ["A3E_EndStatistics",[_statistics] call A3E_fnc_parseStatistics,true];
saveProfileNamespace;

if(A3E_Param_SendStatistics == 1) then {
"DummyLayer" cutRsc ["RscTitleDisplayEmpty", "PLAIN"];
private _emptyDisplay = uiNamespace getVariable "RscTitleDisplayEmpty";
private _html = _emptyDisplay ctrlCreate ["RscHTML", -1];
_html ctrlSetBackgroundColor [0,0,0,1];
_html ctrlSetPosition [0,0,0,0];
_html ctrlCommit 0;
private _uri = "http://escape.anzp.de/track.php?event=endmission&map=" + _island + "&mod=" + _mod + "&version=" + _version + "&players="+str count(call A3E_fnc_GetPlayers)+"&end="+_endType+"&t1="+str A3E_Task_Prison_Complete+"&t2="+str A3E_Task_Map_Complete+"&t3="+str A3E_Task_ComCenter_Complete+"&t4="+str A3E_Task_Exfil_Complete+"&server="+serverName+"&time="+str round(time)+"&release="+ _release;
diag_log(_uri);
_html htmlLoad _uri;
_emptyDisplay closeDisplay 1;
};
};
47 changes: 47 additions & 0 deletions Code/functions/Statistics/fn_StartSession.sqf
@@ -0,0 +1,47 @@
private _fnc_guid = {
params["_servername"];
private _guid = hashValue(_servername)+"-"+hashValue(systemTimeUTC);
_guid;
};


if(A3E_Param_SendStatistics == 1) then {

private _island = getText (missionConfigFile >> "EscapeIsland");
private _mod = getText (missionConfigFile >> "EscapeMod");
private _version = getText (missionConfigFile >> "EscapeVersion");
private _release = getText (missionConfigFile >> "EscapeRelease");
private _build = getText (missionConfigFile >> "EscapeBuild");
private _players = str count(call BIS_fnc_listPlayers);
private _servername = serverName;
if(_servername == "") then {
_servername = "Local";
};
private _guid = _servername call _fnc_guid;
missionNamespace setvariable ["A3E_SessionGUID",_guid];

// replace with the actual server URL where your API is hosted

private _baseURL = "http://co10esc.anzp.de/api/session/";


private _uri = _baseURL + "startsession?"
+"uid="+_guid
+"&server="+_servername
+"&missionVersion="+_version
+"&server=" + _servername
+"&build=" + _build
+"&players=" + _players
+"&mod=" + _mod
+"&terrain=" + _island;

"DummyLayer" cutRsc ["RscTitleDisplayEmpty", "PLAIN"];
private _emptyDisplay = uiNamespace getVariable "RscTitleDisplayEmpty";
private _html = _emptyDisplay ctrlCreate ["RscHTML", -1];
_html ctrlSetBackgroundColor [0,0,0,1];
_html ctrlSetPosition [0,0,0,0];
_html ctrlCommit 0;
_html htmlLoad _uri;
_emptyDisplay closeDisplay 1;

};
26 changes: 1 addition & 25 deletions Code/functions/Statistics/fn_StartStatistics.sqf
@@ -1,25 +1 @@

if(A3E_Param_SendStatistics == 1) then {

private _island = getText (missionConfigFile >> "EscapeIsland");
private _mod = getText (missionConfigFile >> "EscapeMod");
private _version = getText (missionConfigFile >> "EscapeVersion");
private _release = getText (missionConfigFile >> "EscapeRelease");

"DummyLayer" cutRsc ["RscTitleDisplayEmpty", "PLAIN"];
private _emptyDisplay = uiNamespace getVariable "RscTitleDisplayEmpty";
private _html = _emptyDisplay ctrlCreate ["RscHTML", -1];
_html ctrlSetBackgroundColor [0,0,0,1];
_html ctrlSetPosition [0,0,0,0];
_html ctrlCommit 0;
private _uri = "http://escape.anzp.de/track.php?event=startmission&map=" + _island + "&mod=" + _mod + "&version=" + _version + "&players="+str count(call BIS_fnc_listPlayers)+"&server="+serverName+"&release="+ _release;
_html htmlLoad _uri;
_emptyDisplay closeDisplay 1;

private _trigger = createTrigger["EmptyDetector", [0,0,0], false];
_trigger setTriggerInterval 300;
_trigger setTriggerActivation["NONE","PRESENT",true];
_trigger setTriggerArea[0, 0, 0, false];
missionnamespace setvariable ["A3E_var_PingTrg",true,false];
_trigger setTriggerStatements["A3E_var_PingTrg", "[] spawn A3E_fnc_PingStatistics;A3E_var_PingTrg = false;", "A3E_var_PingTrg=true;"];
};
[] call A3E_fnc_StartSession;
1 change: 1 addition & 0 deletions Code/include/defines.hpp
Expand Up @@ -4,6 +4,7 @@
#define MOD "{* MOD *}"
#define ISLAND "{* ISLANDNAME *}"
#define RELEASE "{* RELEASE *}"
#define BUILD "{* COMMIT *}"
//#define GAMETYPE {* GAMETYPE *}

//--- [Controls Style Preprocessors]
Expand Down
2 changes: 2 additions & 0 deletions Code/include/functions.hpp
Expand Up @@ -252,6 +252,8 @@ class CfgFunctions
class SaveStatistics {};
class ParseStatistics {};
class PingStatistics {};
class StartSession {};
class EndSession {};
};
class Searchleader
{
Expand Down

0 comments on commit d5ea228

Please sign in to comment.