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
This commit is contained in:
Focus 2024-02-22 22:57:41 +02:00 committed by GitHub
parent cf0144683d
commit 6bfc3426e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 3 deletions

View File

@ -8,6 +8,7 @@
* Farming Simulator 19 (2018) - Added support (By @Vito0912 #531) * Farming Simulator 19 (2018) - Added support (By @Vito0912 #531)
* Assetto Corsa - Fixed how `state.numplayers` is set (By @podrivo #538) * Assetto Corsa - Fixed how `state.numplayers` is set (By @podrivo #538)
* TeamSpeak 2 - Fixed how `state.name` is set (By @podrivo #544) * 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 ## 5.0.0-beta.2
* Fixed support for projects using `require`. * Fixed support for projects using `require`.

View File

@ -2446,7 +2446,7 @@ export const games = {
release_year: 2019, release_year: 2019,
options: { options: {
port: 7777, port: 7777,
protocol: 'samp' protocol: 'gtasao'
}, },
extra: { extra: {
old_id: 'saomp' old_id: 'saomp'

8
protocols/gtasao.js Normal file
View File

@ -0,0 +1,8 @@
import samp from './samp.js'
export default class gtasao extends samp {
constructor() {
super()
this.isOmp = true
}
}

View File

@ -19,6 +19,7 @@ import gamespy2 from './gamespy2.js'
import gamespy3 from './gamespy3.js' import gamespy3 from './gamespy3.js'
import geneshift from './geneshift.js' import geneshift from './geneshift.js'
import goldsrc from './goldsrc.js' import goldsrc from './goldsrc.js'
import gtasao from './gtasao.js'
import hexen2 from './hexen2.js' import hexen2 from './hexen2.js'
import jc2mp from './jc2mp.js' import jc2mp from './jc2mp.js'
import kspdmp from './kspdmp.js' import kspdmp from './kspdmp.js'
@ -58,7 +59,7 @@ import theisleevrima from './theisleevrima.js'
export { export {
armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, factorio, farmingsimulator, ffow, 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, minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, palworld, quake1, quake2, quake3, rfactor, samp,
savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve, savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,
vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima

View File

@ -7,6 +7,7 @@ export default class samp extends Core {
this.magicHeader = 'SAMP' this.magicHeader = 'SAMP'
this.responseMagicHeader = null this.responseMagicHeader = null
this.isVcmp = false this.isVcmp = false
this.isOmp = false
} }
async run (state) { async run (state) {
@ -40,13 +41,14 @@ export default class samp extends Core {
// read players // read players
// don't even bother if > 100 players, because the server won't respond // don't even bother if > 100 players, because the server won't respond
if (state.numplayers < 100) { if (state.numplayers < 100) {
if (this.isVcmp) { if (this.isVcmp || this.isOmp) {
const reader = await this.sendPacket('c', true) const reader = await this.sendPacket('c', true)
if (reader !== null) { if (reader !== null) {
const playerCount = reader.uint(2) const playerCount = reader.uint(2)
for (let i = 0; i < playerCount; i++) { for (let i = 0; i < playerCount; i++) {
const player = {} const player = {}
player.name = reader.pascalString(1) player.name = reader.pascalString(1)
player.score = reader.int(4)
state.players.push(player) state.players.push(player)
} }
} }