mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
add playernames resource
This commit is contained in:
36
resources/[gameplay]/playernames/playernames_sv.lua
Normal file
36
resources/[gameplay]/playernames/playernames_sv.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
local curTemplate
|
||||
local curTags = {}
|
||||
|
||||
local function detectUpdates()
|
||||
SetTimeout(500, detectUpdates)
|
||||
|
||||
local template = GetConvar('playerNames_template', '[{{id}}] {{name}}')
|
||||
|
||||
if curTemplate ~= template then
|
||||
setNameTemplate(-1, template)
|
||||
|
||||
curTemplate = template
|
||||
end
|
||||
|
||||
template = GetConvar('playerNames_svTemplate', '[{{id}}] {{name}}')
|
||||
|
||||
for _, v in ipairs(GetPlayers()) do
|
||||
local newTag = formatPlayerNameTag(v, template)
|
||||
|
||||
if newTag ~= curTags[v] then
|
||||
setName(v, newTag)
|
||||
|
||||
curTags[v] = newTag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
RegisterNetEvent('playernames:init')
|
||||
AddEventHandler('playernames:init', function()
|
||||
reconfigure(source)
|
||||
end)
|
||||
|
||||
SetTimeout(500, detectUpdates)
|
||||
detectUpdates()
|
||||
Reference in New Issue
Block a user