0.0.1
This commit is contained in:
15
resources/[cfx-default]/[system]/rconlog/fxmanifest.lua
Normal file
15
resources/[cfx-default]/[system]/rconlog/fxmanifest.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
-- This resource is part of the default Cfx.re asset pack (cfx-server-data)
|
||||
-- Altering or recreating for local use only is strongly discouraged.
|
||||
|
||||
version '1.0.0'
|
||||
author 'Cfx.re <root@cfx.re>'
|
||||
description 'Handles old-style server player management commands.'
|
||||
repository 'https://github.com/citizenfx/cfx-server-data'
|
||||
|
||||
client_script 'rconlog_client.lua'
|
||||
server_script 'rconlog_server.lua'
|
||||
|
||||
fx_version 'adamant'
|
||||
games { 'gta5', 'rdr3' }
|
||||
|
||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||
25
resources/[cfx-default]/[system]/rconlog/rconlog_client.lua
Normal file
25
resources/[cfx-default]/[system]/rconlog/rconlog_client.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
RegisterNetEvent('rlUpdateNames')
|
||||
|
||||
AddEventHandler('rlUpdateNames', function()
|
||||
local names = {}
|
||||
|
||||
for i = 0, 31 do
|
||||
if NetworkIsPlayerActive(i) then
|
||||
names[GetPlayerServerId(i)] = { id = i, name = GetPlayerName(i) }
|
||||
end
|
||||
end
|
||||
|
||||
TriggerServerEvent('rlUpdateNamesResult', names)
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
|
||||
if NetworkIsSessionStarted() then
|
||||
TriggerServerEvent('rlPlayerActivated')
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
84
resources/[cfx-default]/[system]/rconlog/rconlog_server.lua
Normal file
84
resources/[cfx-default]/[system]/rconlog/rconlog_server.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
RconLog({ msgType = 'serverStart', hostname = 'lovely', maxplayers = 32 })
|
||||
|
||||
RegisterServerEvent('rlPlayerActivated')
|
||||
|
||||
local names = {}
|
||||
|
||||
AddEventHandler('rlPlayerActivated', function()
|
||||
RconLog({ msgType = 'playerActivated', netID = source, name = GetPlayerName(source), guid = GetPlayerIdentifiers(source)[1], ip = GetPlayerEP(source) })
|
||||
|
||||
names[source] = { name = GetPlayerName(source), id = source }
|
||||
|
||||
if GetHostId() then
|
||||
TriggerClientEvent('rlUpdateNames', GetHostId())
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('rlUpdateNamesResult')
|
||||
|
||||
AddEventHandler('rlUpdateNamesResult', function(res)
|
||||
if source ~= tonumber(GetHostId()) then
|
||||
print('bad guy')
|
||||
return
|
||||
end
|
||||
|
||||
for id, data in pairs(res) do
|
||||
if data then
|
||||
if data.name then
|
||||
if not names[id] then
|
||||
names[id] = data
|
||||
end
|
||||
|
||||
if names[id].name ~= data.name or names[id].id ~= data.id then
|
||||
names[id] = data
|
||||
|
||||
RconLog({ msgType = 'playerRenamed', netID = id, name = data.name })
|
||||
end
|
||||
end
|
||||
else
|
||||
names[id] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
RconLog({ msgType = 'playerDropped', netID = source, name = GetPlayerName(source) })
|
||||
|
||||
names[source] = nil
|
||||
end)
|
||||
|
||||
AddEventHandler('chatMessage', function(netID, name, message)
|
||||
RconLog({ msgType = 'chatMessage', netID = netID, name = name, message = message, guid = GetPlayerIdentifiers(netID)[1] })
|
||||
end)
|
||||
|
||||
-- NOTE: DO NOT USE THIS METHOD FOR HANDLING COMMANDS
|
||||
-- This resource has not been updated to use newer methods such as RegisterCommand.
|
||||
AddEventHandler('rconCommand', function(commandName, args)
|
||||
if commandName == 'status' then
|
||||
for netid, data in pairs(names) do
|
||||
local guid = GetPlayerIdentifiers(netid)
|
||||
|
||||
if guid and guid[1] and data then
|
||||
local ping = GetPlayerPing(netid)
|
||||
|
||||
RconPrint(netid .. ' ' .. guid[1] .. ' ' .. data.name .. ' ' .. GetPlayerEP(netid) .. ' ' .. ping .. "\n")
|
||||
end
|
||||
end
|
||||
|
||||
CancelEvent()
|
||||
elseif commandName:lower() == 'clientkick' then
|
||||
local playerId = table.remove(args, 1)
|
||||
local msg = table.concat(args, ' ')
|
||||
|
||||
DropPlayer(playerId, msg)
|
||||
|
||||
CancelEvent()
|
||||
elseif commandName:lower() == 'tempbanclient' then
|
||||
local playerId = table.remove(args, 1)
|
||||
local msg = table.concat(args, ' ')
|
||||
|
||||
TempBanPlayer(playerId, msg)
|
||||
|
||||
CancelEvent()
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user