Jump to content

مشكلة بسيطة


w7sH

Recommended Posts

السلام عليكم
اليوم عندي مشكلة في كود بسيط حق الفيسات

المشكلة:

اذا حط فيس فالشات يعني يكتب " ض1

الفيس يكون نازل تحت ثم يرتفع فوق

يعني مو موزون مع الشات

هذا الكود وأتمنى المساعدة

 

local root = getRootElement()
local rroot = getResourceRootElement()





--addEvent("Mensaje",true)
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("onClientChatMessage",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,"ض1") then
		local text = string.gsub(txt,"ض1","")
		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,"imagenes/q1.png",true)
	elseif string.find(txt,"ض2") then
		local text = string.gsub(txt,"ض2","")
		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,"imagenes/q2.png",true)
	elseif string.find(txt,"ض3") then
		local text = string.gsub(txt,"ض3","")
		local len = dxGetTextWidth(text,chatbox["chat_scale"][1],font)
		local lfin = convertirRelativo(len)
		local img = guiCreateStaticImage(0.01875+lfin,0.02+(0.025*(lineas-1)),0.02,0.025,"imagenes/q3.png",true)
	elseif string.find(txt,"ض4") then
		local text = string.gsub(txt,"ض4","")
		local len = dxGetTextWidth(text,chatbox["chat_scale"][1],font)
		local lfin = convertirRelativo(len)
		local img = guiCreateStaticImage(0.01875+lfin,0.02+(0.025*(lineas-1)),0.02,0.025,"imagenes/q4.png",true)
	elseif string.find(txt,"ض5") then
		local text = string.gsub(txt,"ض5","")
		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,"imagenes/q5.png",true)
	end
end)

function convertirRelativo(x)
	local rx = x/sx
	
	return rx
end

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...