Advertisement
Evers

Server.lua

Dec 14th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. RconLog({ msgType = 'serverStart', hostname = 'lovely', maxplayers = 63 })
  2.  
  3. RegisterServerEvent('rlPlayerActivated')
  4.  
  5. local names = {}
  6.  
  7. AddEventHandler('rlPlayerActivated', function()
  8. RconLog({ msgType = 'playerActivated', netID = source, name = GetPlayerName(source), guid = GetPlayerIdentifiers(source)[1], ip = GetPlayerEP(source) })
  9.  
  10. names[source] = { name = GetPlayerName(source), id = source }
  11.  
  12. TriggerClientEvent('rlUpdateNames', GetHostId())
  13. end)
  14.  
  15. RegisterServerEvent('rlUpdateNamesResult')
  16.  
  17. AddEventHandler('rlUpdateNamesResult', function(res)
  18. if source ~= tonumber(GetHostId()) then
  19. print('bad guy')
  20. return
  21. end
  22.  
  23. for id, data in pairs(res) do
  24. if data then
  25. if data.name then
  26. if not names[id] then
  27. names[id] = data
  28. end
  29.  
  30. if names[id].name ~= data.name or names[id].id ~= data.id then
  31. names[id] = data
  32.  
  33. RconLog({ msgType = 'playerRenamed', netID = id, name = data.name })
  34. end
  35. end
  36. else
  37. names[id] = nil
  38. end
  39. end
  40. end)
  41.  
  42. AddEventHandler('playerDropped', function()
  43. RconLog({ msgType = 'playerDropped', netID = source, name = GetPlayerName(source) })
  44.  
  45. names[source] = nil
  46. end)
  47.  
  48. AddEventHandler('chatMessage', function(netID, name, message)
  49. RconLog({ msgType = 'chatMessage', netID = netID, name = name, message = message, guid = GetPlayerIdentifiers(netID)[1] })
  50. end)
  51.  
  52. AddEventHandler('rconCommand', function(commandName, args)
  53. if commandName == 'status' then
  54. for netid, data in pairs(names) do
  55. local guid = GetPlayerIdentifiers(netid)
  56.  
  57. if guid and guid[1] and data then
  58. local ping = GetPlayerPing(netid)
  59.  
  60. RconPrint(netid .. ' ' .. guid[1] .. ' ' .. data.name .. ' ' .. GetPlayerEP(netid) .. ' ' .. ping .. "\n")
  61. end
  62. end
  63.  
  64. CancelEvent()
  65. elseif commandName:lower() == 'clientkick' then
  66. local playerId = table.remove(args, 1)
  67. local msg = table.concat(args, ' ')
  68.  
  69. DropPlayer(playerId, msg)
  70.  
  71. CancelEvent()
  72. elseif commandName:lower() == 'tempbanclient' then
  73. local playerId = table.remove(args, 1)
  74. local msg = table.concat(args, ' ')
  75.  
  76. TempBanPlayer(playerId, msg)
  77.  
  78. CancelEvent()
  79. end
  80. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement