- 黄金
- 0.00G
JavaScript:
window.addEventListener('message', function () {
if (event.data.type === 'Show') {
let server = document.querySelector('.server')
let servername = document.querySelector('.server-name')
let serverversion = document.querySelector('.server-version')
let ServerNumber = document.querySelector('.server-number')
let ServerTime = document.querySelector('.server-time')
ServerNumber.innerHTML = `- ${event.data.GetPlayerNumber}/500`
ServerTime.innerHTML = `- ${event.data.GetServeTime}`
server.style.display = 'block'
servername.style.display = 'block'
serverversion.style.display = 'block'
ServerNumber.style.display = 'block'
ServerTime.style.display = 'block'
}
})
Lua:
--客户端部分
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
QBCore.Functions.TriggerCallback('GetServerDetail', function(data)
SendNuiMessage(data)
print('client')
end)
end)
--服务器端部分
local QBCore = exports['qb-core']:GetCoreObject()
QBCore.Functions.CreateCallback('GetServerDetail', function(source, cb)
print('serve1')
local data = {
type = 'Show',
GetPlayerNumber = GetNumPlayerIndices(),
GetServeTime = '[' .. os.date('%X') .. '] '
}
cb(data)
print('server2')
end)
最后编辑: