hi i am a new scripter and i ran into a problem, i made a script to replace strings with emojis.
my problem is the following on the client the script is
local root = getRootElement()
local rroot = getResourceRootElement()
local sx,sy = guiGetScreenSize()
local chatbox = getChatboxLayout()
local y = chatbox["chat_scale"][2]
local lineas = chatbox["chat_lines"]
local font = "default"
if chatbox["chat_font"] == 1 then
font = "clear"
elseif chatbox["chat_font"] == 2 then
font = "default-bold"
elseif chatbox["chat_font"] == 3 then
font = "arial"
end
addEventHandler("SpecialEmojis", root,function(txt)
for k,v in ipairs(getElementsByType("gui-staticimage",rroot)) do
local gx,gy = guiGetPosition(v,true)
if string.len(txt) > 100 then
guiSetPosition(v, gx,gy-0.025,true)
else
guiSetPosition(v, gx,gy-0.025,true)
end
if gy <= 0.01 then
destroyElement(v)
end
end
txt = string.gsub(txt,"#[%x][%x][%x][%x][%x][%x]","")
local len = 0
if string.len(txt) > 48 then
return
end
if string.find(txt,"ضض") then
local text = string.gsub(txt,"ضض","")
local len = dxGetTextWidth(text,chatbox["chat_scale"][1],font)
local lfin = convertirRelativo(len)
outputDebugString("LEN="..tostring(len).." LFIN="..tostring(lfin))
local img = guiCreateStaticImage(0.01875+lfin,0.02+(0.025*(lineas-1)),0.02,0.025,"dai/3tb.png",true)
end
end)
function convertirRelativo(x)
local rx = x/sx
return rx
end
and on server side its
function dai ( )
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then
triggerClientEvent ( "SpecialEmojis", source )
end
end
the main thing i want my script to do is to check if the player is in admin group and then when he types "ضض" in chat it replaces with an emoji which is 3tb.png
thanks...