No problem.
What you mean?
If someone connect, then draw first name . if next connect, draw next name.
Like this
Someone connect:
Server: Kenix has join the server.
Again someone connect.( if last drawing then +1 row .If not draw new.( 1 row ) ).
So draw it:
Server: Kenix has join the server.
Server: Qwety~ has join the server.
And in 5 sec hide.
its draw only text , not
dxDrawRectangle
local sText = ''
local uTimer
function dxDrawRelativeText( text,posX,posY,right,bottom,color,scale,mixed_font,alignX,alignY,clip,wordBreak,postGUI )
local resolutionX = 1280
local resolutionY = 1024
local sWidth,sHeight = guiGetScreenSize( )
return dxDrawColorText(
tostring( text ),
( posX/resolutionX )*sWidth,
( posY/resolutionY )*sHeight,
( right/resolutionX )*sWidth,
( bottom/resolutionY)*sHeight,
color,( sWidth/resolutionX )*scale,
mixed_font,
alignX,
alignY,
clip,
wordBreak,
postGUI
)
end
function dxDrawRelativeRectangle( posX, posY, width, height,color,postGUI )
local resolutionX = 1280
local resolutionY = 1024
local sWidth,sHeight = guiGetScreenSize( )
return dxDrawRectangle(
( posX/resolutionX )*sWidth,
( posY/resolutionY )*sHeight,
( width/resolutionX )*sWidth,
( height/resolutionY )*sHeight,
color,
postGUI
)
end
function fDraw( quitReason )
sText = sText..string.format( '#ffffffServer: %s #ffffffhas %s the server %s \n',
getPlayerName( source ), eventName == 'onClientPlayerQuit' and 'left' or eventName == 'onClientPlayerJoin' and 'join',
eventName == 'onClientPlayerQuit' and '[' .. quitReason .. ']' or '' )
if isTimer( uTimer ) then
killTimer( uTimer )
end
uTimer = setTimer(
function( )
sText = ''
end,
5000,
1 )
end
addEventHandler( 'onClientRender', root,
function( )
if sText ~= '' then
dxDrawRelativeRectangle( 245.0,0.0,365.0,23.0,tocolor( 0,0,0,210 ),false )
dxDrawRelativeText( sText,254.0,0.0,757.0,20.0,tocolor(255,255,255,255),1.0,"default-bold","left","top",false,false,false)
end
end
)
addEventHandler ( 'onClientPlayerQuit', root, fDraw )
addEventHandler ( 'onClientPlayerJoin', root, fDraw )
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY)
if alignX then
if alignX == "center" then
local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
ax = ax + (bx-ax)/2 - w/2
elseif alignX == "right" then
local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
ax = bx - w
end
end
if alignY then
if alignY == "center" then
local h = dxGetFontHeight(scale, font)
ay = ay + (by-ay)/2 - h/2
elseif alignY == "bottom" then
local h = dxGetFontHeight(scale, font)
ay = by - h
end
end
local pat = "(.-)#(%x%x%x%x%x%x)"
local s, e, cap, col = str:find(pat, 1)
local last = 1
while s do
if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end
if s ~= 1 or cap ~= "" then
local w = dxGetTextWidth(cap, scale, font)
dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
ax = ax + w
color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255)
end
last = e + 1
s, e, cap, col = str:find(pat, last)
end
if last <= #str then
cap = str:sub(last)
local w = dxGetTextWidth(cap, scale, font)
dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
end
end
for dxdrawcolortext, \n not work