Server side:
addCommandHandler("spy",
function (player, command, target)
if target then
local ppl = getPlayerFromName(target)
if ppl then
setElementData(ppl, "spy", thePlayer)
outputChatBox("Enabled on: "..getPlayerName(ppl).."", player, 255, 255, 255)
end
else
outputChatBox("USAGE: /"..command.." <Player-Name>", player, 255, 255, 255)
end
end)
addEvent("spy:ShowChat", true)
addEventHandler("spy:ShowChat", root,
function (root, message)
local spy = getElementData(root, "spy")
if spy then
outputChatBox("[SPY-Mode] "..getPlayerName(root)..": "..message, spy, 255, 255, 255)
end
end)
Client side:
local lastMessage = nil
addEventHandler("onClientChatMessage", getRootElement(),
function (message)
if not getElementData(getLocalPlayer(), "spy") then
return false
end
if message == "" or message == " " then
if lastMessage == message then
return
end
end
lastMessage = message
triggerServerEvent("spy:ShowChat", getLocalPlayer(), getLocalPlayer(), message)
end)
I use this code but chats are not sent to the admin !
I wanted a code similar to this