Skip to content

Commit

Permalink
Merge pull request #6 from Thomas-Smyth/beta
Browse files Browse the repository at this point in the history
SquadJS v1.0.1 Release
  • Loading branch information
Thomas-Smyth authored May 15, 2020
2 parents c2eb5e0 + e2543b3 commit 7004c04
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 74 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SquadJS relies on being able to access the Squad server log directory in order t
* [Discord Admin Cam Logs](https://github.com/Thomas-Smyth/SquadJS/tree/master/plugins/discord-admin-cam-logs) - Log admin cam usage to Discord.
* [Discord Chat](https://github.com/Thomas-Smyth/SquadJS/tree/master/plugins/discord-chat) - Log in game chat to Discord.
* [Discord Teamkill](https://github.com/Thomas-Smyth/SquadJS/tree/master/plugins/discord-teamkill) - Log teamkills to Discord.
* [Discord Server Status](https://github.com/Thomas-Smyth/SquadJS/tree/master/plugins/discord-server-status) - Add a server status embed to Discord.
* [Map Vote](https://github.com/Thomas-Smyth/SquadJS/tree/master/plugins/mapvote) - In-game chat map voting system.
* [InfluxDB Log](https://github.com/Thomas-Smyth/SquadJS/tree/master/plugins/influxdb-log) - Log server and player stats to InfluxDB.
* [MySQL Log](https://github.com/Thomas-Smyth/SquadJS/tree/master/plugins/mysql-log) - Log more in-depth server and player stats to MySQL.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SquadJS",
"version": "1.0.0",
"version": "1.0.1",
"repository": "https://github.com/Thomas-Smyth/SquadJS.git",
"author": "Thomas Smyth <https://github.com/Thomas-Smyth>",
"license": "MIT",
Expand Down
112 changes: 56 additions & 56 deletions plugins/discord-admin-cam-logs/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { COPYRIGHT_MESSAGE } from 'core/config';
import { LOG_PARSER_PLAYER_POSSESS } from 'squad-server/events/log-parser';
import { LOG_PARSER_PLAYER_POSSESS, LOG_PARSER_PLAYER_UNPOSSESS } from 'squad-server/events/log-parser';

export default async function plugin(
server,
Expand Down Expand Up @@ -30,68 +30,68 @@ export default async function plugin(
const adminsInCam = {};

server.on(LOG_PARSER_PLAYER_POSSESS, info => {
if (info.player === null) return;
if (info.player === null || info.possessClassname !== 'CameraMan') return;

if (info.possessClassname === 'CameraMan') {
adminsInCam[info.player.steamID] = info.time;
adminsInCam[info.player.steamID] = info.time;

channel.send({
embed: {
title: `Admin Entered Admin Camera`,
color: options.color,
fields: [
{
name: "Admin's Name",
value: info.player.name,
inline: true
},
{
name: "Admin's SteamID",
value: `[${info.player.steamID}](https://steamcommunity.com/profiles/${info.player.steamID})`,
inline: true
}
],
timestamp: info.time.toISOString(),
footer: {
text: COPYRIGHT_MESSAGE
channel.send({
embed: {
title: `Admin Entered Admin Camera`,
color: options.color,
fields: [
{
name: "Admin's Name",
value: info.player.name,
inline: true
},
{
name: "Admin's SteamID",
value: `[${info.player.steamID}](https://steamcommunity.com/profiles/${info.player.steamID})`,
inline: true
}
],
timestamp: info.time.toISOString(),
footer: {
text: COPYRIGHT_MESSAGE
}
});
} else {
if (!(info.player.steamID in adminsInCam)) return;
}
});
});

server.on(LOG_PARSER_PLAYER_UNPOSSESS, info => {
if (info.switchPossess === true || !(info.player.steamID in adminsInCam)) return;

channel.send({
embed: {
title: `Admin Left Admin Camera`,
color: options.color,
fields: [
{
name: "Admin's Name",
value: info.player.name,
inline: true
},
{
name: "Admin's SteamID",
value: `[${info.player.steamID}](https://steamcommunity.com/profiles/${info.player.steamID})`,
inline: true
},
{
name: 'Time in Admin Camera',
value: `${Math.round(
(info.time.getTime() -
adminsInCam[info.player.steamID].getTime()) /
60000
)} mins`
}
],
timestamp: info.time.toISOString(),
footer: {
text: COPYRIGHT_MESSAGE
channel.send({
embed: {
title: `Admin Left Admin Camera`,
color: options.color,
fields: [
{
name: "Admin's Name",
value: info.player.name,
inline: true
},
{
name: "Admin's SteamID",
value: `[${info.player.steamID}](https://steamcommunity.com/profiles/${info.player.steamID})`,
inline: true
},
{
name: 'Time in Admin Camera',
value: `${Math.round(
(info.time.getTime() -
adminsInCam[info.player.steamID].getTime()) /
60000
)} mins`
}
],
timestamp: info.time.toISOString(),
footer: {
text: COPYRIGHT_MESSAGE
}
});
}
});

delete adminsInCam[info.player.steamID];
}
delete adminsInCam[info.player.steamID];
});
}
2 changes: 1 addition & 1 deletion plugins/discord-teamkill/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default async function plugin(

channel.send({
embed: {
title: `Teamkill: ${info.attacker.name}`,
title: `${info.attacker.steamID === info.victim.steamID ? 'Suicide' : 'Teamkill'}: ${info.attacker.name}`,
color: options.color,
fields: [
{
Expand Down
19 changes: 10 additions & 9 deletions squad-server/events/log-parser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/** Occurs when an admin enters admin camera.
*
* Data:
* - time - Date object of when the event occurred.
* - player - PlayerObject of the admin.
*/
const LOG_PARSER_ADMIN_POSSESS_CAMERA = 'LOG_PARSER_ADMIN_POSSESS_CAMERA';

/** Occurs when a new layer is loaded.
*
* Data:
Expand Down Expand Up @@ -75,6 +67,15 @@ const LOG_PARSER_PLAYER_POSSESS = 'LOG_PARSER_PLAYER_POSSESS';
*/
const LOG_PARSER_PLAYER_REVIVED = 'LOG_PARSER_PLAYER_REVIVED';

/** Occurs when a player unpossess an object.
*
* Data:
* - time - Date object of when the event occurred.
* - player - PlayerObject of the admin.
* - switchPossess - True if switching a possess.
*/
const LOG_PARSER_PLAYER_UNPOSSESS = 'LOG_PARSER_PLAYER_UNPOSSESS';

/** Occurs when a player is teamkilled.
*
* Data:
Expand Down Expand Up @@ -110,13 +111,13 @@ const LOG_PARSER_PLAYER_WOUNDED = 'LOG_PARSER_PLAYER_WOUNDED';
const LOG_PARSER_SERVER_TICK_RATE = 'LOG_PARSER_SERVER_TICK_RATE';

export {
LOG_PARSER_ADMIN_POSSESS_CAMERA,
LOG_PARSER_NEW_GAME,
LOG_PARSER_PLAYER_CONNECTED,
LOG_PARSER_PLAYER_DAMAGED,
LOG_PARSER_PLAYER_DIED,
LOG_PARSER_PLAYER_POSSESS,
LOG_PARSER_PLAYER_REVIVED,
LOG_PARSER_PLAYER_UNPOSSESS,
LOG_PARSER_TEAMKILL,
LOG_PARSER_PLAYER_WOUNDED,
LOG_PARSER_SERVER_TICK_RATE
Expand Down
4 changes: 2 additions & 2 deletions squad-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export default class Server extends EventEmitter {
this.updateInterval
);

setTimeout(async () => {
setInterval(async () => {
const data = await this.rcon.getMapInfo();
this.currentLayer = data.currentLayer;
this.nextLayer = data.nextLayer;
this.emit(SERVER_LAYERS_UPDATED, data);
}, this.updateInterval);

setTimeout(async () => {
setInterval(async () => {
const data = await Gamedig.query({
type: 'squad',
host: this.host,
Expand Down
2 changes: 2 additions & 0 deletions squad-server/log-parser/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PlayerDamaged from './player-damaged.js';
import PlayerDied from './player-died.js';
import PlayerPossess from './player-possess.js';
import PlayerRevived from './player-revived.js';
import PlayerUnPossess from './player-un-possess.js';
import PlayerWounded from './player-wounded.js';
import ServerTickRate from './server-tick-rate.js';
import SteamIDConnected from './steamid-connected.js';
Expand All @@ -15,6 +16,7 @@ export default [
PlayerDied,
PlayerPossess,
PlayerRevived,
PlayerUnPossess,
PlayerWounded,
ServerTickRate,
SteamIDConnected
Expand Down
8 changes: 3 additions & 5 deletions squad-server/log-parser/rules/player-possess.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
LOG_PARSER_PLAYER_POSSESS,
LOG_PARSER_ADMIN_POSSESS_CAMERA
LOG_PARSER_PLAYER_POSSESS
} from '../../events/log-parser.js';

export default {
Expand All @@ -14,9 +13,8 @@ export default {
possessClassname: args[4]
};

logParser.server.emit(LOG_PARSER_PLAYER_POSSESS, data);
logParser.eventStore[args[3]] = args[2];

if (data.possessClassname === 'CameraMan')
logParser.server.emit(LOG_PARSER_ADMIN_POSSESS_CAMERA, data);
logParser.server.emit(LOG_PARSER_PLAYER_POSSESS, data);
}
};
21 changes: 21 additions & 0 deletions squad-server/log-parser/rules/player-un-possess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
LOG_PARSER_PLAYER_UNPOSSESS
} from '../../events/log-parser.js';

export default {
regex: /^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquadTrace: \[DedicatedServer](?:ASQPlayerController::)OnUnPossess\(\): PC=(.+)/,
onMatch: async (args, logParser) => {
const data = {
raw: args[0],
time: args[1],
chainID: args[2],
player: await logParser.server.getPlayerByName(args[3], true),
switchPossess: false
};

if(args[3] in logParser.eventStore && logParser.eventStore[args[3]] === args[2]) data.switchPossess = true;
delete logParser.eventStore[args[3]];

logParser.server.emit(LOG_PARSER_PLAYER_UNPOSSESS, data);
}
};

0 comments on commit 7004c04

Please sign in to comment.