[Release] Emojis for chat | FiveMojis 1.0

thanks
20 characters

You should use hashes instead of copied web emojis

2 Likes

Great work.
but
is there a way to make this work with rolesFX? since i assume that is whats causing this problem!
image
image
(118 chars)

@Jakob2 Yes, you can merge the resources.
It can be done in other ways, but :peach: there you go:


Emoji + RoleFX ( or other chat resources (?) )

I don’t test it, let me know if it works

1. Copy emoji.lua in rolefx resource folder

  • Do not forget to add the file in __resource.lua as a server_script

2. Copy Emojit function in sv_chat.lua (or however is named)

function Emojit(text)
function Emojit(text)
    for i = 1, #emoji do
      for k = 1, #emoji[i][1] do
        text = string.gsub(text, emoji[i][1][k], emoji[i][2])
      end
    end
    return text
end

3. Add message = Emojit(message) before CancelEvent() in sv_chat.lua

  • Where message is the last param from your chatMessage event
Example
--                                                     |
--                                                     v
AddEventHandler('chatMessage', function(Source, Name, Msg)
    args = stringsplit(Msg, " ")
    Msg = Emojit(Msg) -- <-------------------------- HERE
    CancelEvent()
1 Like

:hash: Can you show me an example ?

Nice resource. For what it’s worth, I used a similar method to this to append squad tags to player names and it broke the DiscordBot resource (due to CancelEvent()). Haven’t tested this particular resource with DiscordBot, but I ended up needing to make my own server events to handle the Discord WebHooks. Just an FYI for other users :slight_smile:

So this is what i did and its not showing my prefix and also not the emoji
image

--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.

function Emojit(text)
    for i = 1, #emoji do
      for k = 1, #emoji[i][1] do
        text = string.gsub(text, emoji[i][1][k], emoji[i][2])
      end
    end
    return text
end

local Director = {"steam:","ip:127.0.0.1",}
local Admin = {"steam:11000013228a95a", }
local Test = {"steam:","ip:",}
local Moderator = {"steam:110000108902d31", "steam:11000010e5465c9", "steam:11000010b3b480d", "steam:1100001083b9da9", "steam:1100001172acba7", }
local Owner = {"steam:11000011549e13f","steam:110000107d2ab57",}
local CommunityManager = {"steam:1100001075dcb0c",}
local HeadMod = {"",}
local preadmin = {"steam:","steam:","steam:",}
local premod = {"steam:1100001150a49e5", "steam:110000109ac4abe", "steam:11000010a9e7ee3", "steam:11000011c9d6f57", "steam:110000113c5aba4", "steam:110000108a89cd2", "steam:11000011292783a", }
local superadmin = {"steam:11000010d321783",}
local donmod = {"steam:","ip:",}
local superadmin = {"steam:11000010d321783","ip:",}
local bronzedonator = {"steam:","steam:11000010801d208", "steam:11000011212efe7", "steam:110000115f9732b", "steam:110000131e7e790", "steam:11000011bf0bf39", "steam:110000119028107", "steam:1100001189092e7", "steam:11000010c5fb7e7", "steam:110000109a601de", "steam:110000116957349", "steam:110000101e6d37f", "steam:11000011503fea3", "steam:110000105da6418", "steam:110000118121a0f", "steam:11000011ac4fd74", }
local silverdonator = {"steam:110000104ac3bb4","steam:110000109b7d6a4", "steam:11000011292783a", "steam:110000133c8d56f", }
local golddonator = {"steam:",}
local platinumdonator = {"steam:110000108a89cd2","steam:110000114daab2d","steam:1100001160600c9", "steam:11000011bf25c50", "steam:11000011c9d6f57", "steam:11000011ac0b459", "steam:11000010785a648", "steam:110000112c56562", }
local supremedonator = {"steam:",}
local leadadmin  = {"steam:1100001151f9d75"}


AddEventHandler('chatMessage', function(Source, Name, Msg)
    args = stringsplit(Msg, " ")
    message = Emojit(message)
    CancelEvent()
    if string.find(args[1], "/") then
        local cmd = args[1]
        table.remove(args, 1)
    else     
        local player = GetPlayerIdentifiers(Source)[1]         
        if has_value(Admin, player) then
            TriggerClientEvent('chatMessage', -1, "Admin | " .. Name, { 255, 0, 0 }, Msg)
	    elseif has_value(Moderator, player) then
            TriggerClientEvent('chatMessage', -1, "Moderator | " .. Name, { 0, 255, 247 }, Msg)
		elseif has_value(Owner, player) then
            TriggerClientEvent('chatMessage', -1, "Community Owner | " .. Name, { 0, 255, 50 }, Msg)
		elseif has_value(CommunityManager, player) then
            TriggerClientEvent('chatMessage', -1, "Community Manager | " .. Name, { 0, 150, 255 }, Msg)
		elseif has_value(premod, player) then
            TriggerClientEvent('chatMessage', -1, "Trial-Staff | " .. Name, { 255, 144, 0 }, Msg)
		elseif has_value(leadadmin, player) then
            TriggerClientEvent('chatMessage', -1, "Lead Admin | " .. Name, { 0, 150, 255 }, Msg)
		elseif has_value(superadmin, player) then
            TriggerClientEvent('chatMessage', -1, "Senior Admin | " .. Name, { 255, 0, 0 }, Msg)
		elseif has_value(bronzedonator, player) then
            TriggerClientEvent('chatMessage', -1, "Bronze Donator | " .. Name, { 160, 100, 40 }, Msg)
		elseif has_value(silverdonator, player) then
            TriggerClientEvent('chatMessage', -1, "Silver Donator | " .. Name, { 75, 75, 75 }, Msg)
		elseif has_value(golddonator, player) then
            TriggerClientEvent('chatMessage', -1, "Gold Donator | " .. Name, { 255, 180, 0 }, Msg)
		elseif has_value(platinumdonator, player) then
            TriggerClientEvent('chatMessage', -1, "Platinum Donator | " .. Name, { 0, 150, 150 }, Msg)
		elseif has_value(supremedonator, player) then
            TriggerClientEvent('chatMessage', -1, "Supreme Donator | " .. Name, { 255, 3, 62 }, Msg)
        else
            TriggerClientEvent('chatMessage', -1, "User | " .. Name, { 235, 214, 51 }, Msg)
        end
            
    end
end)

function has_value (tab, val)
    for index, value in ipairs(tab) do
        if value == val then
            return true
        end
    end

    return false
end

function Emojit(text)
    for i = 1, #emoji do
      for k = 1, #emoji[i][1] do
        text = string.gsub(text, emoji[i][1][k], emoji[i][2])
      end
    end
    return text
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

Did i do something wrong?

Replace message = Emojit(message) with Msg = Emojit(Msg)
Because your “message” parameter is named “Msg”

                                                       |
                                                       v
AddEventHandler('chatMessage', function(Source, Name, Msg)

This. Copy-pasting emojis can lead to a whole variety of issues.

Okay so i did what you said but now i get this:
image
here is my code again

--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.
--- DO NOT REMOVE ME FROM THE CONFIG, ITS THERE TO GIVE ME CREDIT WHEN I JOIN SERVERS.

function Emojit(text)
    for i = 1, #emoji do
      for k = 1, #emoji[i][1] do
        text = string.gsub(text, emoji[i][1][k], emoji[i][2])
      end
    end
    return text
end

local Director = {"steam:","ip:127.0.0.1",}
local Admin = {"steam:11000013228a95a", }
local Test = {"steam:","ip:",}
local Moderator = {"steam:110000108902d31", "steam:11000010e5465c9", "steam:11000010b3b480d", "steam:1100001083b9da9", "steam:1100001172acba7", }
local Owner = {"steam:11000011549e13f","steam:110000107d2ab57",}
local CommunityManager = {"steam:1100001075dcb0c",}
local HeadMod = {"",}
local preadmin = {"steam:","steam:","steam:",}
local premod = {"steam:1100001150a49e5", "steam:110000109ac4abe", "steam:11000010a9e7ee3", "steam:11000011c9d6f57", "steam:110000113c5aba4", "steam:110000108a89cd2", "steam:11000011292783a", }
local superadmin = {"steam:11000010d321783",}
local donmod = {"steam:","ip:",}
local superadmin = {"steam:11000010d321783","ip:",}
local bronzedonator = {"steam:","steam:11000010801d208", "steam:11000011212efe7", "steam:110000115f9732b", "steam:110000131e7e790", "steam:11000011bf0bf39", "steam:110000119028107", "steam:1100001189092e7", "steam:11000010c5fb7e7", "steam:110000109a601de", "steam:110000116957349", "steam:110000101e6d37f", "steam:11000011503fea3", "steam:110000105da6418", "steam:110000118121a0f", "steam:11000011ac4fd74", }
local silverdonator = {"steam:110000104ac3bb4","steam:110000109b7d6a4", "steam:11000011292783a", "steam:110000133c8d56f", }
local golddonator = {"steam:",}
local platinumdonator = {"steam:110000108a89cd2","steam:110000114daab2d","steam:1100001160600c9", "steam:11000011bf25c50", "steam:11000011c9d6f57", "steam:11000011ac0b459", "steam:11000010785a648", "steam:110000112c56562", }
local supremedonator = {"steam:",}
local leadadmin  = {"steam:1100001151f9d75"}


AddEventHandler('chatMessage', function(Source, Name, Msg)
    args = stringsplit(Msg, " ")
    message = Emojit(Msg)
    CancelEvent()
    if string.find(args[1], "/") then
        local cmd = args[1]
        table.remove(args, 1)
    else     
        local player = GetPlayerIdentifiers(Source)[1]         
        if has_value(Admin, player) then
            TriggerClientEvent('chatMessage', -1, "Admin | " .. Name, { 255, 0, 0 }, Msg)
	    elseif has_value(Moderator, player) then
            TriggerClientEvent('chatMessage', -1, "Moderator | " .. Name, { 0, 255, 247 }, Msg)
		elseif has_value(Owner, player) then
            TriggerClientEvent('chatMessage', -1, "Community Owner | " .. Name, { 0, 255, 50 }, Msg)
		elseif has_value(CommunityManager, player) then
            TriggerClientEvent('chatMessage', -1, "Community Manager | " .. Name, { 0, 150, 255 }, Msg)
		elseif has_value(premod, player) then
            TriggerClientEvent('chatMessage', -1, "Trial-Staff | " .. Name, { 255, 144, 0 }, Msg)
		elseif has_value(leadadmin, player) then
            TriggerClientEvent('chatMessage', -1, "Lead Admin | " .. Name, { 0, 150, 255 }, Msg)
		elseif has_value(superadmin, player) then
            TriggerClientEvent('chatMessage', -1, "Senior Admin | " .. Name, { 255, 0, 0 }, Msg)
		elseif has_value(bronzedonator, player) then
            TriggerClientEvent('chatMessage', -1, "Bronze Donator | " .. Name, { 160, 100, 40 }, Msg)
		elseif has_value(silverdonator, player) then
            TriggerClientEvent('chatMessage', -1, "Silver Donator | " .. Name, { 75, 75, 75 }, Msg)
		elseif has_value(golddonator, player) then
            TriggerClientEvent('chatMessage', -1, "Gold Donator | " .. Name, { 255, 180, 0 }, Msg)
		elseif has_value(platinumdonator, player) then
            TriggerClientEvent('chatMessage', -1, "Platinum Donator | " .. Name, { 0, 150, 150 }, Msg)
		elseif has_value(supremedonator, player) then
            TriggerClientEvent('chatMessage', -1, "Supreme Donator | " .. Name, { 255, 3, 62 }, Msg)
        else
            TriggerClientEvent('chatMessage', -1, "User | " .. Name, { 235, 214, 51 }, Msg)
        end
            
    end
end)

function has_value (tab, val)
    for index, value in ipairs(tab) do
        if value == val then
            return true
        end
    end

    return false
end

function Emojit(text)
    for i = 1, #emoji do
      for k = 1, #emoji[i][1] do
        text = string.gsub(text, emoji[i][1][k], emoji[i][2])
      end
    end
    return text
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

can you help me, how to to add ServerID in RoleFX

There is a download. Idk what you are saying but read the whole post before posting something stupid.

Hello, I know I am not the author but I want to help. In case you didn’t figured it our yet.

Try this:

AddEventHandler(‘chatMessage’, function(Source, Name, message)
args = stringsplit(message, " " )
message = Emojit(message)
CancelEvent()

Let me know if it worked.

why did you remove the creator it says in the top of the config that is not allowed

The only problem right now is. I’m getting double messages.

1 with my steam name
2 with my RP name

The one with my steam name shows the emoji the one with my RP name not.

I’d be really interested to know if there is a way to make this work in a way that is similar to Discord, in which you can add custom emoji :thinking:

Is the emoji resource separate from RolesFX? You need to integrate emojis into RolesFX so you don’t send 2 messages at once

Isn’t the chat HTML based, or am I stupid? I would think if it was, it could be possible

how does one do that?

Is it possible to make like custom emojis like “:pepeHype:”?
I mean, you can add your own emoji to your Discord Server, and can you use it somehow in FiveM Chat too?
like, I don’t know… upload image with that emoji to the in-game chat?