Doj /me

ya his wont work yours does tho

here’s the chat toggle just copy and replace the chat resource in /fxserver/resources/system/chat/ and then either restart chat or restart your server then join in and do /togglechat

will it mess with anything els i have my chat to where its transparent will it interfere with that

nope that is in the html folder so to not mess that up just copy the chat client and chat server lua files to your chat folder

see the sv_chat.lua and cl_chat.lua replace the those with the sv_chat and cl_chat from the folder you just downloaded :wink:

oh ok let me try that

nope its not working Capture3

well it will work if other players are talking in chat but you can still type and it will show no one has figured out how to completely hide it even showing a command that i know of no one has found that out yet

no like when other people type in chat it shows it, it doesnt doing anything or hide anything at all

so what about this one this will replace cl_chat.lua so back it up before

local chatInputActive = false
local chatInputActivating = false
local chatVisibilityToggle = false
local chatCleared = false

RegisterNetEvent('chatMessage')
RegisterNetEvent('chat:addTemplate')
RegisterNetEvent('chat:addMessage')
RegisterNetEvent('chat:addSuggestion')
RegisterNetEvent('chat:removeSuggestion')
RegisterNetEvent('chat:clear')
RegisterNetEvent('chat:textchat')

-- internal events
RegisterNetEvent('__cfx_internal:serverPrint')

RegisterNetEvent('_chat:messageEntered')

--deprecated, use chat:addMessage
AddEventHandler('chatMessage', function(author, color, text)
  local args = { text }
  if author ~= "" then
    table.insert(args, 1, author)
  end
  SendNUIMessage({
    type = 'ON_MESSAGE',
    message = {
      color = color,
      multiline = true,
      args = args
    }
  })
end)

AddEventHandler('__cfx_internal:serverPrint', function(msg)
  print(msg)

  SendNUIMessage({
    type = 'ON_MESSAGE',
    message = {
      color = { 0, 0, 0 },
      multiline = true,
      args = { msg }
    }
  })
end)

AddEventHandler('chat:addMessage', function(message)
  SendNUIMessage({
    type = 'ON_MESSAGE',
    message = message
  })
end)

AddEventHandler('chat:addSuggestion', function(name, help, params)
  SendNUIMessage({
    type = 'ON_SUGGESTION_ADD',
    suggestion = {
      name = name,
      help = help,
      params = params or nil
    }
  })
end)

AddEventHandler('chat:removeSuggestion', function(name)
  SendNUIMessage({
    type = 'ON_SUGGESTION_REMOVE',
    name = name
  })
end)

AddEventHandler('chat:addTemplate', function(id, html)
  SendNUIMessage({
    type = 'ON_TEMPLATE_ADD',
    template = {
      id = id,
      html = html
    }
  })
end)

AddEventHandler('chat:clear', function(name)
  SendNUIMessage({
    type = 'ON_CLEAR'
  })
end)

local state = (clear == true) and "^1Cleared" or "^2Failed to clear"

  SendNUIMessage({
    type = 'ON_CLEAR',
    Clear = chatCleared
  })

  SendNUIMessage({
  type = 'ON_CLEAR',
  message = {
    color = {255,255,255},
    multiline = true,
    args = {"Server has " ..state "the chat"}
    }
  })
end)

RegisterCommand("clear",function()
  TriggerEvent('chat:clear')
end)

AddEventHandler('chat:textchat',function(newState)
  if(newState == true or newState == false)then
    chatVisibilityToggle = not newState
  else
    chatVisibilityToggle = not chatVisibilityToggle
  end

  local state = (chatVisibilityToggle == true) and "^1disabled" or "^2enabled"

  SendNUIMessage({
    type = 'ON_TOGGLE_CHAT',
    toggle = chatVisibilityToggle
  })

  SendNUIMessage({
  type = 'ON_MESSAGE',
  message = {
    color = {255,255,255},
    multiline = true,
    args = {"Textchat has been "..state}
    }
  })
end)

RegisterCommand("textchat",function()
  TriggerEvent('chat:textchat')
end)

RegisterNUICallback('chatResult', function(data, cb)
  chatInputActive = false
  SetNuiFocus(false)

  if not data.canceled then
    local id = PlayerId()

    --deprecated
    local r, g, b = 0, 0x99, 255

    if data.message:sub(1, 1) == '/' then
      ExecuteCommand(data.message:sub(2))
    else
      TriggerServerEvent('_chat:messageEntered', GetPlayerName(id), { r, g, b }, data.message)
    end
  end

  cb('ok')
end)

RegisterNUICallback('loaded', function(data, cb)
  TriggerServerEvent('chat:init');

  cb('ok')
end)

Citizen.CreateThread(function()
  SetTextChatEnabled(false)
  SetNuiFocus(false)

  while true do
    Wait(0)

    if not chatInputActive then
      if IsControlPressed(0, 245) --[[ INPUT_MP_TEXT_CHAT_ALL ]] then
        chatInputActive = true
        chatInputActivating = true

        SendNUIMessage({
          type = 'ON_OPEN'
        })
      end
    end

    if chatInputActivating then
      if not IsControlPressed(0, 245) then
        SetNuiFocus(true)

        chatInputActivating = false
      end
    end
  end
end)

i was also editing stuff like chatclear it has /clear i was just adding a chat message to say that the chat was successfully cleared but thats my code

so what do i do to toggle it?

Can you post the code for your me script? I cant seem to get it to work.

AddEventHandler('chatMessage', function(source, name, msg)
	sm = stringsplit(msg, " ");
	if sm[1] == "/me" then
		CancelEvent()
		TriggerClientEvent('chatMessage', -1, "^3>^1:^0 " .. name .. '^0' .. string.sub(msg,4))
	end
end)

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

The code above is in the server.lua file located in the server folder.
The code below is in the __resource.lua file located in the mescript folder.

server_script 'server.lua'

and all that happens when I do /me test is it registars the command but doesnt output anything into chat.

TriggerEvent('es:addCommand', 'do', function(source, args, user)
    table.remove(args, 1)
    TriggerClientEvent('chatMessage', -1, "", {255, 0, 0}, "^6  " .. GetPlayerName(source) .."  ".."^3<  " .. table.concat(args, " ")) -- you may change the "^3< <-- that to whatever you want and the ^3 is gold color!
end)


TriggerEvent('es:addCommand', 'me', function(source, args, user)
    table.remove(args, 1)
    TriggerClientEvent('chatMessage', -1, "", {255, 0, 0}, "^6  " .. GetPlayerName(source) .."  ".."^3>  " .. table.concat(args, " ")) -- again you can change the > to whatever you want!
end)

-- Stringsplit for FX --
function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

__resource.lua:

resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"

description 'MGCRP Me Command'

server_scripts {
	"server.lua"
}

or the files if your lazy :wink:
__resource.lua (136 Bytes)
server.lua (947 Bytes)

So I got it to my liking but in order for the message to actually be sent you have to do “/me test hello” Only Hello shows up not test. How can I make it only “/me hello” instead of having to have a word in the middle?

RegisterCommand("me", function(source, args, rawCommand)
    TriggerClientEvent('chatMessage', -1, "" .. GetPlayerName(source) .. '^3>^1:^0' .. string.sub(rawCommand,  4))
end)

there that should do it as it works on my server :wink:

edit: thanks for the edit @Havoc didn’t know there could be no stringsplit :wink:

Where do i find where to put the server.lua scripts? Where is the Lua file? :blush:
And is it just to copypaste the scripts in ? In both Server.lua and Resource? /Thanks

Make a folder, call it “mecommand”, place the server.lua and __resource into the folder, head over to your server.cfg and start that bad boy: start mecommand - Save, refresh and start the resource.

Yo when I put this is the script and replace the /me already in the server it comes up like 3-6 times
https://gyazo.com/2679f39731fe097ff3b723f9647040ba

I made this script and it is based of DOJ