mirror of
https://github.com/sergeyyarkov/altv-copchase-mod.git
synced 2026-10-11 10:19:42 +03:00
stable
This commit is contained in:
parent
31c66cbc2b
commit
bcc504901c
@ -4,49 +4,10 @@ import * as NativeUI from './includes/nativeui/nativeui.min.js'
|
||||
|
||||
import './ui.mjs'
|
||||
|
||||
const blips = {}
|
||||
import './modules/blips.mjs'
|
||||
|
||||
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', () => {
|
||||
native.animpostfxPlay('DeathFailNeutralIn', 5000, false)
|
||||
NativeUI.BigMessage.ShowWastedMessage('Мертв', 'Вы умерли', NativeUI.HudColor.HUD_COLOUR_RED, 5000)
|
||||
|
||||
37
client/modules/blips.mjs
Normal file
37
client/modules/blips.mjs
Normal 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
|
||||
}
|
||||
})
|
||||
@ -13,7 +13,8 @@ export default {
|
||||
},
|
||||
admins: [
|
||||
{ socialId: '370262977' },
|
||||
{ socialId: '401448051' }
|
||||
{ socialId: '401448051' },
|
||||
{ socialId: '367807894' }
|
||||
],
|
||||
defaultModel: 'mp_m_freemode_01'
|
||||
}
|
||||
@ -17,23 +17,35 @@ class Copchase {
|
||||
this.isTimeToStartStarted = false
|
||||
this.suspectCars = [
|
||||
'asea',
|
||||
'bison',
|
||||
'bobcatxl',
|
||||
'burrito',
|
||||
'tornado',
|
||||
'futo',
|
||||
'taxi',
|
||||
'picador',
|
||||
'phoenix',
|
||||
'ruiner',
|
||||
'sabregt',
|
||||
'rancherxl',
|
||||
'regina',
|
||||
'stanier',
|
||||
'washington',
|
||||
'emperor',
|
||||
'emperor2',
|
||||
'ardent',
|
||||
'ingot',
|
||||
'journey',
|
||||
'clique',
|
||||
'vamos',
|
||||
'blista',
|
||||
'tulip',
|
||||
'stafford',
|
||||
'cheburek',
|
||||
'streiter',
|
||||
'nebula',
|
||||
'hellion',
|
||||
'gauntlet4'
|
||||
'vamos',
|
||||
'chino',
|
||||
'moonbeam',
|
||||
'elegy2',
|
||||
'dubsta',
|
||||
'dominator',
|
||||
'rebla',
|
||||
'sanchez',
|
||||
'superd',
|
||||
'dilettante',
|
||||
'huntley',
|
||||
'monroe',
|
||||
'windsor',
|
||||
'novak',
|
||||
'gauntlet3'
|
||||
]
|
||||
this.policeCars = [
|
||||
'police2',
|
||||
@ -69,7 +81,7 @@ class Copchase {
|
||||
police: [
|
||||
{ x: 442.308, y: -1025.066, z: 28.231 },
|
||||
{ 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,24 +151,32 @@ class Copchase {
|
||||
}
|
||||
|
||||
spawnPlayers() {
|
||||
let posX = 0
|
||||
let suspectRandomNumber = Math.floor(Math.random() * this.positions.suspect.length)
|
||||
let suspectPosition = this.positions.suspect[suspectRandomNumber]
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.players.forEach(_player => {
|
||||
if (_player.name === this.suspect.name) {
|
||||
_player.pos = suspectPosition
|
||||
setTimeout(() => _player.health = 200, 300)
|
||||
_player.dimension = this.dimension
|
||||
_player.model = skins[Math.floor(Math.random() * (430 - 1 - 422) + 422)]
|
||||
alt.emitClient(_player, 'player:delInvincible')
|
||||
alt.emitClient(_player, 'player:showMidsizedMessage', '~r~Вы саспект!', 'Уйдите от полицейских.', 5000)
|
||||
alt.emitClient(_player, 'player:createBlip', _player)
|
||||
alt.Player.all.forEach(_player => alt.emitClient(_player, 'player:createBlipPlayers', this.suspect))
|
||||
this.players.forEach(_player => _player.name === this.suspect.name
|
||||
? alt.emitClient(_player, 'player:createBlipPlayers', { players: this.players, color: 38 })
|
||||
: alt.emitClient(_player, 'player:createBlipPlayers', { players: this.players, color: 1 })
|
||||
)
|
||||
} else {
|
||||
posX = posX + 3
|
||||
_player.pos = {
|
||||
x: this.positions.police[suspectRandomNumber].x + 2,
|
||||
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)
|
||||
@ -164,6 +184,9 @@ class Copchase {
|
||||
alt.emitClient(_player, 'player:showMidsizedMessage', `~w~Саспект: ~r~${this.suspect.name}`, 'Нейтрализуйте саспекта.', 5000)
|
||||
}
|
||||
})
|
||||
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
spawnCars() {
|
||||
@ -206,6 +229,7 @@ class Copchase {
|
||||
|
||||
if (this.waitingPlayers.length < this.minPlayers) {
|
||||
this.midsizedMessageToWaitingPlayers('~r~Недостаточно игроков для старта!', '', 3000)
|
||||
this.isTimeToStartStarted = false
|
||||
|
||||
clearInterval(interval)
|
||||
return
|
||||
@ -222,8 +246,7 @@ class Copchase {
|
||||
this.notifyPolicePlayers(`~w~ Остановите саспекта!`)
|
||||
this.notifySuspectPlayer(`~w~ Уйдите от полицейских!`)
|
||||
|
||||
this.spawnPlayers()
|
||||
this.spawnCars()
|
||||
this.spawnPlayers().then(() => this.spawnCars())
|
||||
|
||||
let timeRemaining = this.timeRemaining
|
||||
this.timeRemainingInterval = setInterval(() => {
|
||||
@ -294,7 +317,7 @@ const copchase = new Copchase({
|
||||
maxPlayers: 11,
|
||||
minPlayers: 2,
|
||||
timeRemaining: 10,
|
||||
timeToStart: 5
|
||||
timeToStart: 4
|
||||
})
|
||||
|
||||
export {
|
||||
|
||||
@ -14,16 +14,6 @@ alt.on('playerConnect', (player) => {
|
||||
player.spawn(config.spawn.x, config.spawn.y,config.spawn.z)
|
||||
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:notify', '~g~Добро пожаловать на сервер!')
|
||||
})
|
||||
|
||||
// setInterval(() => {
|
||||
// alt.Player.all.forEach(_player => {
|
||||
// if (blips[_player.id]) {
|
||||
// blips[_player.id].pos = _player.pos
|
||||
// }
|
||||
// })
|
||||
// }, 1000)
|
||||
|
||||
@ -5,7 +5,10 @@ import config from '../../config.mjs'
|
||||
|
||||
alt.on('playerDeath', (player) => {
|
||||
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 (player.name === copchase.suspect.name) copchase.stopGame({ winner: 'police' })
|
||||
|
||||
@ -22,4 +22,6 @@ alt.on('playerDisconnect', (player) => {
|
||||
if (policemanIndex !== -1) copchase.players.splice(policemanIndex, 1)
|
||||
if (copchase.players.length <= 1 && copchase.suspect !== null) copchase.stopGame({ winner: 'suspect' })
|
||||
}
|
||||
|
||||
alt.Player.all.forEach(_player => alt.emitClient(_player, 'player:deleteBlipPlayer', player))
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user