mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-01-08 06:02:57 +08:00
Compare commits
3 Commits
2bde7889b4
...
dd38bd0192
Author | SHA1 | Date | |
---|---|---|---|
|
dd38bd0192 | ||
|
2998a23ced | ||
|
296226b734 |
@ -46,9 +46,9 @@ function updatePlayerNames()
|
|||||||
local localCoords = GetEntityCoords(PlayerPedId())
|
local localCoords = GetEntityCoords(PlayerPedId())
|
||||||
|
|
||||||
-- for each valid player index
|
-- for each valid player index
|
||||||
for i = 0, 255 do
|
for _, i in ipairs(GetActivePlayers()) do
|
||||||
-- if the player exists
|
-- if the player exists
|
||||||
if NetworkIsPlayerActive(i) and i ~= PlayerId() then
|
if i ~= PlayerId() then
|
||||||
-- get their ped
|
-- get their ped
|
||||||
local ped = GetPlayerPed(i)
|
local ped = GetPlayerPed(i)
|
||||||
local pedCoords = GetEntityCoords(ped)
|
local pedCoords = GetEntityCoords(ped)
|
||||||
@ -188,4 +188,4 @@ SetTimeout(0, function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- run this function every frame
|
-- run this function every frame
|
||||||
SetTimeout(0, updatePlayerNames)
|
SetTimeout(0, updatePlayerNames)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
local curTemplate
|
local curTemplate
|
||||||
local curTags = {}
|
local curTags = {}
|
||||||
|
|
||||||
|
local activePlayers = {}
|
||||||
|
|
||||||
local function detectUpdates()
|
local function detectUpdates()
|
||||||
SetTimeout(500, detectUpdates)
|
SetTimeout(500, detectUpdates)
|
||||||
|
|
||||||
@ -14,23 +16,31 @@ local function detectUpdates()
|
|||||||
|
|
||||||
template = GetConvar('playerNames_svTemplate', '[{{id}}] {{name}}')
|
template = GetConvar('playerNames_svTemplate', '[{{id}}] {{name}}')
|
||||||
|
|
||||||
for _, v in ipairs(GetPlayers()) do
|
for v, _ in pairs(activePlayers) do
|
||||||
local newTag = formatPlayerNameTag(v, template)
|
local newTag = formatPlayerNameTag(v, template)
|
||||||
|
|
||||||
if newTag ~= curTags[v] then
|
if newTag ~= curTags[v] then
|
||||||
setName(v, newTag)
|
setName(v, newTag)
|
||||||
|
|
||||||
curTags[v] = newTag
|
curTags[v] = newTag
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i, tag in pairs(curTags) do
|
||||||
|
if not activePlayers[i] then
|
||||||
|
curTags[i] = nil -- in case curTags doesnt get cleared when the player left, clear it now.
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
AddEventHandler('playerDropped', function()
|
||||||
|
curTags[source] = nil
|
||||||
|
activePlayers[source] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('playernames:init')
|
RegisterNetEvent('playernames:init')
|
||||||
AddEventHandler('playernames:init', function()
|
AddEventHandler('playernames:init', function()
|
||||||
reconfigure(source)
|
reconfigure(source)
|
||||||
|
activePlayers[source] = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
SetTimeout(500, detectUpdates)
|
detectUpdates()
|
||||||
detectUpdates()
|
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
client_script 'spawnmanager.lua'
|
client_script 'spawnmanager.lua'
|
||||||
|
|
||||||
export 'getRandomSpawnPoint'
|
|
||||||
export 'spawnPlayer'
|
|
||||||
export 'addSpawnPoint'
|
|
||||||
export 'removeSpawnPoint'
|
|
||||||
export 'loadSpawns'
|
|
||||||
export 'setAutoSpawn'
|
|
||||||
export 'setAutoSpawnCallback'
|
|
||||||
export 'forceRespawn'
|
|
||||||
|
|
||||||
fx_version 'adamant'
|
fx_version 'adamant'
|
||||||
games { 'rdr3', 'gta5' }
|
games { 'rdr3', 'gta5' }
|
||||||
|
|
||||||
|
@ -369,3 +369,11 @@ function forceRespawn()
|
|||||||
spawnLock = false
|
spawnLock = false
|
||||||
respawnForced = true
|
respawnForced = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
exports('spawnPlayer', spawnPlayer)
|
||||||
|
exports('addSpawnPoint', addSpawnPoint)
|
||||||
|
exports('removeSpawnPoint', removeSpawnPoint)
|
||||||
|
exports('loadSpawns', loadSpawns)
|
||||||
|
exports('setAutoSpawn', setAutoSpawn)
|
||||||
|
exports('setAutoSpawnCallback', setAutoSpawnCallback)
|
||||||
|
exports('forceRespawn', forceRespawn)
|
||||||
|
Loading…
Reference in New Issue
Block a user