From 6bfc3426e7196171951c9716a9f76b812b954abf Mon Sep 17 00:00:00 2001 From: Focus <64330077+Focus04@users.noreply.github.com> Date: Thu, 22 Feb 2024 22:57:41 +0200 Subject: [PATCH] fix: Added c query requests for gtasao (open.mp) (#547) * Added full OMP support * Added a new protocol for OMP which extends SAMP * Edited the changelog --- CHANGELOG.md | 1 + lib/games.js | 2 +- protocols/gtasao.js | 8 ++++++++ protocols/index.js | 3 ++- protocols/samp.js | 4 +++- 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 protocols/gtasao.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 846a743..51ced60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Farming Simulator 19 (2018) - Added support (By @Vito0912 #531) * Assetto Corsa - Fixed how `state.numplayers` is set (By @podrivo #538) * TeamSpeak 2 - Fixed how `state.name` is set (By @podrivo #544) +* Grand Theft Auto: San Andreas OpenMP - Fixed `state.players` returning an empty array (By @Focus04 #547) ## 5.0.0-beta.2 * Fixed support for projects using `require`. diff --git a/lib/games.js b/lib/games.js index 97a3436..434638a 100644 --- a/lib/games.js +++ b/lib/games.js @@ -2446,7 +2446,7 @@ export const games = { release_year: 2019, options: { port: 7777, - protocol: 'samp' + protocol: 'gtasao' }, extra: { old_id: 'saomp' diff --git a/protocols/gtasao.js b/protocols/gtasao.js new file mode 100644 index 0000000..cb43f77 --- /dev/null +++ b/protocols/gtasao.js @@ -0,0 +1,8 @@ +import samp from './samp.js' + +export default class gtasao extends samp { + constructor() { + super() + this.isOmp = true + } +} diff --git a/protocols/index.js b/protocols/index.js index 8156718..cb34d55 100644 --- a/protocols/index.js +++ b/protocols/index.js @@ -19,6 +19,7 @@ import gamespy2 from './gamespy2.js' import gamespy3 from './gamespy3.js' import geneshift from './geneshift.js' import goldsrc from './goldsrc.js' +import gtasao from './gtasao.js' import hexen2 from './hexen2.js' import jc2mp from './jc2mp.js' import kspdmp from './kspdmp.js' @@ -58,7 +59,7 @@ import theisleevrima from './theisleevrima.js' export { armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, factorio, farmingsimulator, ffow, - fivem, gamespy1, gamespy2, gamespy3, geneshift, goldsrc, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft, + fivem, gamespy1, gamespy2, gamespy3, geneshift, goldsrc, gtasao, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft, minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, palworld, quake1, quake2, quake3, rfactor, samp, savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve, vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima diff --git a/protocols/samp.js b/protocols/samp.js index 517a904..cc45abd 100644 --- a/protocols/samp.js +++ b/protocols/samp.js @@ -7,6 +7,7 @@ export default class samp extends Core { this.magicHeader = 'SAMP' this.responseMagicHeader = null this.isVcmp = false + this.isOmp = false } async run (state) { @@ -40,13 +41,14 @@ export default class samp extends Core { // read players // don't even bother if > 100 players, because the server won't respond if (state.numplayers < 100) { - if (this.isVcmp) { + if (this.isVcmp || this.isOmp) { const reader = await this.sendPacket('c', true) if (reader !== null) { const playerCount = reader.uint(2) for (let i = 0; i < playerCount; i++) { const player = {} player.name = reader.pascalString(1) + player.score = reader.int(4) state.players.push(player) } }