I want to convert "<span style="color: blue;"></span>" to "~b~"

Hi, so I’m using mythic_notify and I want to use these “~b~” color codes instead of this

<span style="color: blue;"></span>

So I wonder if someone has made a “script” or something like that to convert that css code to this “~b~” kind of color code?

I have heard of that before in the Swedish Fivem Communtiy that someone has done it!

Thanks!

you can use string.gsub
for instance

s = string.gsub("Lua is cute", "cute", "great")
print(s)         --> "Lua is great"

Hey, I think you missunderstood a bit

So if you don’t already know you can use color codes in esx notifications, such as ~b~ = blue and ~r~ = green.

Like this

ESX.Notification("~r~Hello")

And I’m using Mythic Notifications instead of the ESX.Notification, But in Mythic Notification you can’t use these color codes ~r~, and i have to use that css code down under.

<span style="color: blue;"></span>

So it looks like this (I have made the ESX.Notification function in es_extended to be mythic notification instead)

ESX.ShowNotification("<span style=color:red>No</span> Player Nearby")

So my question actually is if you or someone else knows how to convert this type of color code ~r~, so I don’t have to use the css code
To this

<span style=color:red>Ingen</span>

Hope you understand!

i understand now.
so you input "~b~ Hello" and you want the output to be

<span style="color:blue">Hello</span>

i am sure you can use a few lua string libraries to help you.
http://lua-users.org/wiki/StringLibraryTutorial
you can use a patterened gsub to find what it being input between ~
and make a switch statement (http://lua-users.org/wiki/SwitchStatement) and output your desired output
for example
if “b” is found between ~
then output = “blue”

<span style="color:"..output>hello</span>

Hi, I have a question about how I can put a background to a word or text … I tried everything but it didn’t work, does anyone have any idea how I can do it? I leave an example here of a text with background and another without background
https://gyazo.com/81487525bea04cbcbd9103fa6ad236fa

1 Like

if I understand correctly, insert a div behind the text element. then set the div color accordingly

I am using a self-message script on my server but the message comes out of no text background how can I put a background and color? This is the

https://gyazo.com/43e4af86e534f62ddfb246d05d3ee3fd
can you help me with this? please

‘Value your life and don’t forget to feed yourself.’,

1 Like

well first of all you have non escaped characters so that won’t work.
i assume you want a random quote from the list shown. you can use a lua script to randomly pick one from the list and display it inside a nui. or have the script send a new quote every 5-10 seconds.