Skip to content

Instantly share code, notes, and snippets.

@indig0fox
Last active November 16, 2021 18:53
Show Gist options
  • Save indig0fox/4df34f214c8ba5006708c3a309b14841 to your computer and use it in GitHub Desktop.
Save indig0fox/4df34f214c8ba5006708c3a309b14841 to your computer and use it in GitHub Desktop.
Log server events
phx_fnc_systemTime = {
private _systemTimeFormat = ["%1-%2-%3T%4:%5:%6.%7Z"];
_systemTimeFormat append (systemTimeUTC apply {if (_x < 10) then {"0" + str _x} else {str _x}});
format _systemTimeFormat
};
phx_admin_fnc_logChat = {
params ["_channel","_text","_soldierName","_steamProfileName","_playerUID"];
private _path = "chatlog.json";
private _data = format["{
""time"": ""%1"",
""event"": ""CHAT"",
""channel"": ""%2"",
""text"": ""%3"",
""soldierName"": ""%4"",
""steamProfileName"": ""%5"",
""playerUID"": ""%6""
},
",
call phx_fnc_systemTime,
_channel,
_text,
_soldierName,
_steamProfileName,
_playerUID
];
"debug_console" callExtension (_data + "~0000");
};
phx_admin_fnc_logConnect = {
params ["_soldierName","_steamProfileName","_playerUID"];
private _path = "chatlog.json";
private _data = format["{
""time"": ""%1"",
""event"": ""CONNECT"",
""soldierName"": ""%4"",
""steamProfileName"": ""%5"",
""playerUID"": ""%6""
},
",
call phx_fnc_systemTime,
_soldierName,
_steamProfileName,
_playerUID
];
"debug_console" callExtension (_data + "~0000");
};
phx_admin_fnc_logKick = {
params ["_soldierName","_steamProfileName","_playerUID","_message"];
private _path = "chatlog.json";
private _data = format["{
""time"": ""%1"",
""event"": ""KICK"",
""message"": ""%2"",
""soldierName"": ""%3"",
""steamProfileName"": ""%4"",
""playerUID"": ""%5""
},
",
call phx_fnc_systemTime,
_message,
_soldierName,
_steamProfileName,
_playerUID
];
"debug_console" callExtension (_data + "~0000");
};
phx_admin_fnc_logAdmin = {
params ["_soldierName","_steamProfileName","_playerUID","_loggedIn","_votedIn"];
private _path = "chatlog.json";
private _data = format["{
""time"": ""%1"",
""event"": ""ADMIN"",
""loggedIn"": ""%2"",
""votedIn"": ""%3"",
""soldierName"": ""%4"",
""steamProfileName"": ""%5"",
""playerUID"": ""%6""
},
",
call phx_fnc_systemTime,
_loggedIn,
_votedIn,
_soldierName,
_steamProfileName,
_playerUID
];
"debug_console" callExtension (_data + "~0000");
};
addMissionEventHandler ["HandleChatMessage", {
params ["_channel", "_owner", "_from", "_text", "_person", "_name", "_strID", "_forcedDisplay", "_isPlayerMessage", "_sentenceType", "_chatMessageType"];
private _senderInfo = getUserInfo _strID;
_senderInfo params ["_networkId","_owner","_playerUID","_soldierName","_soldierNameInclSquad","_steamProfileName"];
[_channel,_text,_soldierName,_steamProfileName,_playerUID] remoteExec ["phx_admin_fnc_logChat",2];
false
}];
addMissionEventHandler ["OnUserConnected", {
params ["_networkId", "_clientStateNumber", "_clientState"];
private _senderInfo = getUserInfo _strID;
_senderInfo params ["_networkId","_owner","_playerUID","_soldierName","_soldierNameInclSquad","_steamProfileName"];
[_soldierName,_steamProfileName,_playerUID] remoteExec ["phx_admin_fnc_logConnect",2];
nil
}];
addMissionEventHandler ["OnUserKicked", {
params ["_networkId", "_kickTypeNumber", "_kickType", "_kickReason", "_kickMessageIncReason"];
private _senderInfo = getUserInfo _strID;
_senderInfo params ["_networkId","_owner","_playerUID","_soldierName","_soldierNameInclSquad","_steamProfileName"];
[_soldierName,_steamProfileName,_playerUID,_kickMessageIncReason] remoteExec ["phx_admin_fnc_logKick",2];
nil
}];
addMissionEventHandler ["OnUserAdminStateChanged", {
params ["_networkId", "_loggedIn", "_votedIn"];
private _senderInfo = getUserInfo _strID;
_senderInfo params ["_networkId","_owner","_playerUID","_soldierName","_soldierNameInclSquad","_steamProfileName"];
[_soldierName,_steamProfileName,_playerUID,_loggedIn,_votedIn] remoteExec ["phx_admin_fnc_logAdmin",2];
nil
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment