This commit is contained in:
Sergey Yarkov 2020-08-08 20:29:20 +03:00
parent 31c66cbc2b
commit bcc504901c
7 changed files with 111 additions and 94 deletions

View File

@ -4,49 +4,10 @@ import * as NativeUI from './includes/nativeui/nativeui.min.js'
import './ui.mjs' import './ui.mjs'
const blips = {} import './modules/blips.mjs'
alt.setMsPerGameMinute(30000) alt.setMsPerGameMinute(30000)
alt.everyTick(() => {
alt.Player.all.forEach(_player => {
if (blips[_player.id]) {
blips[_player.id].pos = _player.pos
}
})
})
alt.onServer('player:createBlip', player => {
// blips[player.id] = new alt.PointBlip(player.pos.x, player.pos.y, player.pos.z)
// blips[player.id].name = player.name
// blips[player.id].color = 0
alt.emitServer('player:createBlipPlayers', blips)
})
alt.onServer('player:createBlipPlayers', (suspectPlayer) => {
alt.Player.all.forEach(_player => {
if (suspectPlayer.name === _player.name) {
blips[_player.id] = new alt.PointBlip(_player.pos.x, _player.pos.y, _player.pos.z)
blips[_player.id].name = _player.name
blips[_player.id].color = 1
} else {
blips[_player.id] = new alt.PointBlip(_player.pos.x, _player.pos.y, _player.pos.z)
blips[_player.id].name = _player.name
blips[_player.id].color = 38
}
})
})
alt.onServer('player:deleteBlipPlayers', () => {
alt.Player.all.forEach(_player => {
if (blips[_player.id]) {
blips[_player.id].destroy()
blips[_player.id] = null
}
})
})
alt.onServer('player:death', () => { alt.onServer('player:death', () => {
native.animpostfxPlay('DeathFailNeutralIn', 5000, false) native.animpostfxPlay('DeathFailNeutralIn', 5000, false)
NativeUI.BigMessage.ShowWastedMessage('Мертв', 'Вы умерли', NativeUI.HudColor.HUD_COLOUR_RED, 5000) NativeUI.BigMessage.ShowWastedMessage('Мертв', 'Вы умерли', NativeUI.HudColor.HUD_COLOUR_RED, 5000)

37
client/modules/blips.mjs Normal file
View File

@ -0,0 +1,37 @@
import * as alt from 'alt'
const blips = {}
alt.everyTick(() => {
alt.Player.all.forEach(_player => {
if (blips[_player.id]) {
blips[_player.id].pos = _player.pos
}
})
})
alt.onServer('player:createBlipPlayers', ({ players, color }) => {
players.forEach(_player => {
if (_player.name !== alt.Player.local.name) {
blips[_player.id] = new alt.PointBlip(_player.pos.x, _player.pos.y, _player.pos.z)
blips[_player.id].name = _player.name
blips[_player.id].color = color
}
})
})
alt.onServer('player:deleteBlipPlayers', () => {
alt.Player.all.forEach(_player => {
if (blips[_player.id]) {
blips[_player.id].destroy()
blips[_player.id] = null
}
})
})
alt.onServer('player:deleteBlipPlayer', player => {
if (blips[player.id]) {
blips[player.id].destroy()
blips[player.id] = null
}
})

View File

@ -13,7 +13,8 @@ export default {
}, },
admins: [ admins: [
{ socialId: '370262977' }, { socialId: '370262977' },
{ socialId: '401448051' } { socialId: '401448051' },
{ socialId: '367807894' }
], ],
defaultModel: 'mp_m_freemode_01' defaultModel: 'mp_m_freemode_01'
} }

View File

@ -17,23 +17,35 @@ class Copchase {
this.isTimeToStartStarted = false this.isTimeToStartStarted = false
this.suspectCars = [ this.suspectCars = [
'asea', 'asea',
'bison', 'tornado',
'bobcatxl', 'futo',
'burrito', 'taxi',
'picador',
'phoenix',
'ruiner',
'sabregt',
'rancherxl',
'regina',
'stanier',
'washington',
'emperor', 'emperor',
'emperor2', 'blista',
'ardent',
'ingot',
'journey',
'clique',
'vamos',
'tulip', 'tulip',
'stafford', 'vamos',
'cheburek', 'chino',
'streiter', 'moonbeam',
'nebula', 'elegy2',
'hellion', 'dubsta',
'gauntlet4' 'dominator',
'rebla',
'sanchez',
'superd',
'dilettante',
'huntley',
'monroe',
'windsor',
'novak',
'gauntlet3'
] ]
this.policeCars = [ this.policeCars = [
'police2', 'police2',
@ -68,8 +80,8 @@ class Copchase {
], ],
police: [ police: [
{ x: 442.308, y: -1025.066, z: 28.231 }, { x: 442.308, y: -1025.066, z: 28.231 },
{ x: 348.865, y: -1966.507, z:24.133 }, { x: 348.865, y: -1966.507, z: 24.133 },
{ x: 2678.454, y: 3459.637, z: 55.340 } { x: 2681.454, y: 3457.637, z: 55.228 }
] ]
} }
} }
@ -139,30 +151,41 @@ class Copchase {
} }
spawnPlayers() { spawnPlayers() {
let posX = 0
let suspectRandomNumber = Math.floor(Math.random() * this.positions.suspect.length) let suspectRandomNumber = Math.floor(Math.random() * this.positions.suspect.length)
let suspectPosition = this.positions.suspect[suspectRandomNumber] let suspectPosition = this.positions.suspect[suspectRandomNumber]
this.players.forEach(_player => { return new Promise((resolve, reject) => {
if (_player.name === this.suspect.name) { this.players.forEach(_player => {
_player.pos = suspectPosition if (_player.name === this.suspect.name) {
_player.dimension = this.dimension _player.pos = suspectPosition
_player.model = skins[Math.floor(Math.random() * (430 - 1 - 422) + 422)] setTimeout(() => _player.health = 200, 300)
alt.emitClient(_player, 'player:delInvincible') _player.dimension = this.dimension
alt.emitClient(_player, 'player:showMidsizedMessage', '~r~Вы саспект!', 'Уйдите от полицейских.', 5000) _player.model = skins[Math.floor(Math.random() * (430 - 1 - 422) + 422)]
alt.emitClient(_player, 'player:createBlip', _player) alt.emitClient(_player, 'player:delInvincible')
alt.Player.all.forEach(_player => alt.emitClient(_player, 'player:createBlipPlayers', this.suspect)) alt.emitClient(_player, 'player:showMidsizedMessage', '~r~Вы саспект!', 'Уйдите от полицейских.', 5000)
} else { this.players.forEach(_player => _player.name === this.suspect.name
_player.pos = { ? alt.emitClient(_player, 'player:createBlipPlayers', { players: this.players, color: 38 })
x: this.positions.police[suspectRandomNumber].x + 2, : alt.emitClient(_player, 'player:createBlipPlayers', { players: this.players, color: 1 })
y: this.positions.police[suspectRandomNumber].y, )
z: this.positions.police[suspectRandomNumber].z } else {
posX = posX + 3
_player.pos = {
x: this.positions.police[suspectRandomNumber].x + posX,
y: this.positions.police[suspectRandomNumber].y,
z: this.positions.police[suspectRandomNumber].z
}
setTimeout(() => _player.armour = 100, 300)
setTimeout(() => _player.health = 200, 300)
_player.dimension = this.dimension
_player.model = 's_m_y_cop_01'
_player.giveWeapon('0x3656C8C1', 100, true)
alt.emitClient(_player, 'player:delInvincible')
alt.emitClient(_player, 'player:showMidsizedMessage', `~w~Саспект: ~r~${this.suspect.name}`, 'Нейтрализуйте саспекта.', 5000)
} }
_player.dimension = this.dimension })
_player.model = 's_m_y_cop_01'
_player.giveWeapon('0x3656C8C1', 100, true) resolve()
alt.emitClient(_player, 'player:delInvincible')
alt.emitClient(_player, 'player:showMidsizedMessage', `~w~Саспект: ~r~${this.suspect.name}`, 'Нейтрализуйте саспекта.', 5000)
}
}) })
} }
@ -206,6 +229,7 @@ class Copchase {
if (this.waitingPlayers.length < this.minPlayers) { if (this.waitingPlayers.length < this.minPlayers) {
this.midsizedMessageToWaitingPlayers('~r~Недостаточно игроков для старта!', '', 3000) this.midsizedMessageToWaitingPlayers('~r~Недостаточно игроков для старта!', '', 3000)
this.isTimeToStartStarted = false
clearInterval(interval) clearInterval(interval)
return return
@ -222,9 +246,8 @@ class Copchase {
this.notifyPolicePlayers(`~w~ Остановите саспекта!`) this.notifyPolicePlayers(`~w~ Остановите саспекта!`)
this.notifySuspectPlayer(`~w~ Уйдите от полицейских!`) this.notifySuspectPlayer(`~w~ Уйдите от полицейских!`)
this.spawnPlayers() this.spawnPlayers().then(() => this.spawnCars())
this.spawnCars()
let timeRemaining = this.timeRemaining let timeRemaining = this.timeRemaining
this.timeRemainingInterval = setInterval(() => { this.timeRemainingInterval = setInterval(() => {
timeRemaining = timeRemaining - 1 timeRemaining = timeRemaining - 1
@ -294,7 +317,7 @@ const copchase = new Copchase({
maxPlayers: 11, maxPlayers: 11,
minPlayers: 2, minPlayers: 2,
timeRemaining: 10, timeRemaining: 10,
timeToStart: 5 timeToStart: 4
}) })
export { export {

View File

@ -14,16 +14,6 @@ alt.on('playerConnect', (player) => {
player.spawn(config.spawn.x, config.spawn.y,config.spawn.z) player.spawn(config.spawn.x, config.spawn.y,config.spawn.z)
player.dimension = 0 player.dimension = 0
//alt.emitClient(player, 'player:createBlip', player)
//alt.Player.all.forEach(_player => alt.emitClient(_player, 'player:createBlipPlayers'))
alt.emitClient(player, 'player:setInvincible') alt.emitClient(player, 'player:setInvincible')
alt.emitClient(player, 'player:notify', '~g~Добро пожаловать на сервер!') alt.emitClient(player, 'player:notify', '~g~Добро пожаловать на сервер!')
}) })
// setInterval(() => {
// alt.Player.all.forEach(_player => {
// if (blips[_player.id]) {
// blips[_player.id].pos = _player.pos
// }
// })
// }, 1000)

View File

@ -5,8 +5,11 @@ import config from '../../config.mjs'
alt.on('playerDeath', (player) => { alt.on('playerDeath', (player) => {
alt.emitClient(player, 'player:death') alt.emitClient(player, 'player:death')
alt.Player.all.forEach(_player => alt.emitClient(_player, 'player:notify', `Игрок <C>${player.name}</C> погиб`)) alt.Player.all.forEach(_player => {
alt.emitClient(_player, 'player:notify', `Игрок <C>${player.name}</C> погиб`)
alt.emitClient(_player, 'player:deleteBlipPlayer', player)
})
if (copchase.isStarted) { if (copchase.isStarted) {
if (player.name === copchase.suspect.name) copchase.stopGame({ winner: 'police' }) if (player.name === copchase.suspect.name) copchase.stopGame({ winner: 'police' })

View File

@ -22,4 +22,6 @@ alt.on('playerDisconnect', (player) => {
if (policemanIndex !== -1) copchase.players.splice(policemanIndex, 1) if (policemanIndex !== -1) copchase.players.splice(policemanIndex, 1)
if (copchase.players.length <= 1 && copchase.suspect !== null) copchase.stopGame({ winner: 'suspect' }) if (copchase.players.length <= 1 && copchase.suspect !== null) copchase.stopGame({ winner: 'suspect' })
} }
alt.Player.all.forEach(_player => alt.emitClient(_player, 'player:deleteBlipPlayer', player))
}) })