diff --git a/client/index.mjs b/client/index.mjs index b7b8fce..3b36e8b 100644 --- a/client/index.mjs +++ b/client/index.mjs @@ -34,7 +34,7 @@ alt.onServer('vehicle:setInto', (newVehicle) => { alt.setTimeout(() => { native.setPedIntoVehicle(localPlayer, newVehicle.scriptID, -1) - }, 300) + }, 400) }) alt.onServer('admin:setStat', () => { diff --git a/client/ui.mjs b/client/ui.mjs index b66caca..c59b6d8 100644 --- a/client/ui.mjs +++ b/client/ui.mjs @@ -830,6 +830,7 @@ listCommandsMenu.AddItem(new UIMenuItem('Сменить скин', `/skin [0 - 7 listCommandsMenu.AddItem(new UIMenuItem('Появиться на спауне', `/spawn`)) listCommandsMenu.AddItem(new UIMenuItem('Узнать текущий онлайн', `/online`)) listCommandsMenu.AddItem(new UIMenuItem('Узнать Social Club ID', `/scid`)) +listCommandsMenu.AddItem(new UIMenuItem('Выйти из комнаты ожидания', `/exit`)) const adminMenu = new Menu("Админ Панель", "Выполняйте админ-функции", menuPos) const kickPlayerMenu = new Menu("Кикнуть игрока", "Сервер кикнет любого игрока", menuPos) diff --git a/server/index.mjs b/server/index.mjs index b038d23..1c2b5af 100644 --- a/server/index.mjs +++ b/server/index.mjs @@ -41,6 +41,7 @@ import './modules/commands/player/skin.mjs' import './modules/commands/player/scid.mjs' import './modules/commands/player/copchase.mjs' import './modules/commands/player/mydimension.mjs' +import './modules/commands/player/exit.mjs' /* Default text labels diff --git a/server/modules/commands/player/copchase.mjs b/server/modules/commands/player/copchase.mjs index 342dcd9..3dc073d 100644 --- a/server/modules/commands/player/copchase.mjs +++ b/server/modules/commands/player/copchase.mjs @@ -5,7 +5,11 @@ import { copchase } from '../../copchase.mjs' import config from '../../../config.mjs' registerCmd('copchase', player => { - if (copchase.isPlayerInWaitingRoom(player)) return false + if (copchase.isPlayerInWaitingRoom(player)) { + send(player, '{EE9A00}[COPCHASE]: {FF0000}Вы уже в комнате ожидания!') + send(player, '{EE9A00}[COPCHASE]: {FF0000}/exit чтобы выйти') + return false + } if (copchase.isPlayerInGame(player)) return false player.dimension = copchase.waitingRoomDimension @@ -15,7 +19,6 @@ registerCmd('copchase', player => { alt.emitClient(player, 'player:setInvincible') if (copchase.isStarted && copchase.players.length > 0) { - // copchase.addPlayerToWaitingRoom(player) return alt.emitClient(player, 'player:showMidsizedMessage', '~b~Игра уже начата', 'Ожидание игроков...') } diff --git a/server/modules/commands/player/exit.mjs b/server/modules/commands/player/exit.mjs new file mode 100644 index 0000000..e358cdc --- /dev/null +++ b/server/modules/commands/player/exit.mjs @@ -0,0 +1,18 @@ +import { registerCmd, send } from 'chat' +import { copchase } from '../../copchase.mjs' + +import config from '../../../config.mjs' + +registerCmd('exit', player => { + if (copchase.isPlayerInWaitingRoom(player)) { + const exitPlayerIndex = copchase.waitingPlayers.findIndex(_player => _player.name === player.name) + copchase.waitingPlayers.splice(exitPlayerIndex, 1) + + player.pos = config.spawn + player.dimension = 0 + + return + } + + send(player, `{EE9A00}[COPCHASE]: {FF0000}Вы должны находиться в комнате ожидания!`) +}) \ No newline at end of file diff --git a/server/modules/commands/player/skin.mjs b/server/modules/commands/player/skin.mjs index 4a43563..062c6dc 100644 --- a/server/modules/commands/player/skin.mjs +++ b/server/modules/commands/player/skin.mjs @@ -1,8 +1,12 @@ import { registerCmd, send } from 'chat' +import { copchase } from '../../copchase.mjs' import skins from '../../../skins.json' registerCmd('skin', (player, args) => { + if (copchase.isPlayerInWaitingRoom(player)) return false + if (copchase.isPlayerInGame(player)) return false + if (!args || !args[0] || isNaN(args[0])) { return send(player, `{EE9A00}[SERVER]: {FFF}/skin [0 - 700]`) } diff --git a/server/modules/commands/player/spawn.mjs b/server/modules/commands/player/spawn.mjs index fc62445..63a7a20 100644 --- a/server/modules/commands/player/spawn.mjs +++ b/server/modules/commands/player/spawn.mjs @@ -1,8 +1,12 @@ import { registerCmd } from 'chat' +import { copchase } from '../../copchase.mjs' import config from '../../../config.mjs' registerCmd('spawn', player => { + if (copchase.isPlayerInWaitingRoom(player)) return false + if (copchase.isPlayerInGame(player)) return false + player.pos = config.spawn player.dimension = 0 }) \ No newline at end of file diff --git a/server/modules/copchase.mjs b/server/modules/copchase.mjs index 0475650..ba89d10 100644 --- a/server/modules/copchase.mjs +++ b/server/modules/copchase.mjs @@ -79,7 +79,6 @@ class Copchase { this.isStarted = false this.suspect = null this.players = [] - // this.waitingPlayers = [] this.blips = {} setTimeout(() => { @@ -99,7 +98,6 @@ class Copchase { isPlayerInWaitingRoom(player) { if(this.waitingPlayers.find(_player => _player.name === player.name) !== undefined) { - send(player, '{EE9A00}[COPCHASE]: {FF0000}Вы уже в комнате ожидания!') return true } else { return false @@ -127,6 +125,12 @@ class Copchase { this.waitingPlayers.forEach(_player => send(_player, message)) } + midsizedMessageToWaitingPlayers(message, description, delay) { + this.waitingPlayers.forEach(_player => { + alt.emitClient(_player, 'player:showMidsizedMessage', message, description, delay) + }) + } + notifyPolicePlayers(message) { this.players.forEach(_player => _player.name !== this.suspect.name ? alt.emitClient(_player, 'player:notify', message) : false) } @@ -209,11 +213,14 @@ class Copchase { const interval = setInterval(() => { timeToStart = timeToStart - 1 + if (this.waitingPlayers.length < this.minPlayers) { + this.midsizedMessageToWaitingPlayers('~r~Недостаточно игроков для старта!', '', 3000) + + clearInterval(interval) + return + } + if (timeToStart <= 0) { - // if (this.waitingPlayers.length >= 2) { - // broadcast(`Недостаточно игроков для старта!`) - // return - // } this.isStarted = true @@ -251,10 +258,7 @@ class Copchase { clearInterval(interval) return true } - - this.waitingPlayers.forEach(_player => { - alt.emitClient(_player, 'player:showMidsizedMessage', `${timeToStart}`, '', 1000) - }) + this.midsizedMessageToWaitingPlayers(timeToStart, '', 1000) // this.messageToWaitingPlayers(`[COPCHASE]: Игра начнется через: ${timeToStart}`) }, 1000) } diff --git a/server/modules/events/playerDeath.mjs b/server/modules/events/playerDeath.mjs index 2da34eb..9f01dba 100644 --- a/server/modules/events/playerDeath.mjs +++ b/server/modules/events/playerDeath.mjs @@ -17,6 +17,7 @@ alt.on('playerDeath', (player) => { alt.setTimeout(() => { player.spawn(config.spawn.x, config.spawn.y,config.spawn.z) + player.dimension = 0 player.removeAllWeapons() alt.emitClient(player, 'player:setInvincible') }, 5000)