MrLoKi Posted November 6, 2021 Share Posted November 6, 2021 Hello friends ! I want to create a spy mode for my server admin using onClientChatMessage That the admin can spy on the whole chat player ! Please help me..... Link to comment
The_GTA Posted November 6, 2021 Share Posted November 6, 2021 Hello MrLoki, I have found this topic inside of our forums that seems to ask a similar question. Does it help you in any way? If not, could you explain what the solutions provided in said topic are missing based on your imagination? Link to comment
MrLoKi Posted November 6, 2021 Author Share Posted November 6, 2021 (edited) 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 Edited November 6, 2021 by MrLoKi Link to comment
The_GTA Posted November 6, 2021 Share Posted November 6, 2021 (edited) 13 hours ago, MrLoKi said: I wanted a code similar to this I still cannot understand what kind of code you are looking for. The above script has some errors [EDIT]. Could you please help us understand what is missing from the script? which "admin" should receive those messages? should all admins receive it or specific admins (issuer of command, admin group, etc) what players should be spied on? I recommend you to detect admins based on the player account. When a player has logged into an internal MTA server account, then that account can be given rights inside of the ACL.xml file. Inside of that file you can create a special permission called "spychat" as well as limit the accessibility to MTA commands (for example /spy). You could loop through all logged in players using a for-loop on getElementsByType("player") and create a list of only the players that meet the "spychat" permission/right. Edited November 7, 2021 by The_GTA Link to comment
MrLoKi Posted November 7, 2021 Author Share Posted November 7, 2021 (edited) I want the server admin to be able to spy on the player with this command Edited November 7, 2021 by MrLoKi Link to comment
The_GTA Posted November 7, 2021 Share Posted November 7, 2021 13 hours ago, MrLoKi said: setElementData(ppl, "spy", thePlayer) Have you tried fixing the variable "thePlayer" to "player"? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now