try this:
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI)
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, left, top, clip, wordbreak, postGUI )
end
end
local message = {join="",quit="",nick="",login=""}
local x,y = guiGetScreenSize()
local scaleX = x/1920
local scaleY = y/1080
function renderPlayerJoined ( )
dxDrawColorText("#ffffff".. message.join, 1140*scaleX, 20,574.0,20.0,tocolor(200,0,0,255),1,"default-bold","left","top",false,false,false)
dxDrawImage (1110*scaleX, 20,16,16,"icon/join.png",0,-120)
end
function renderPlayerLeft ( )
dxDrawColorText("#ffffff".. message.quit, 1140*scaleX, 40,573.0,32.0,tocolor(0,0,255,170),1,"default-bold","left","top",false,false,false)
dxDrawImage (1110*scaleX, 40,16,16,"icon/quit.png",0,-120)
end
function renderPlayerNick ( )
dxDrawColorText("#ffffff".. message.nick, 1140*scaleX, 60,574.0,20.0,tocolor(200,0,0,255),1,"default-bold","left","top",false,false,false)
dxDrawImage (1110*scaleX, 60,16,16,"icon/nick.png",0,-120)
end
function renderPlayerLogin ( )
dxDrawColorText("#ffffff".. message.login, 1140*scaleX, 80,574.0,20.0,tocolor(200,0,0,255),1,"default-bold","left","top",false,false,false)
dxDrawImage (1110*scaleX, 80,16,16,"icon/login.png",0,-120)
end
addEvent( "onJoin", true )
addEventHandler( "onJoin", root,function( player, ulke )
message.join = "#ffffff"..getPlayerName (player) .. " #ffffffhas joined the game from #00ff00 ".. tostring ( ulke )
addEventHandler ( "onClientRender", root, renderPlayerJoined )
setTimer(removeEventHandler,6000,1,"onClientRender", root, renderPlayerJoined )
end)
addEventHandler('onClientPlayerQuit', root,function(reason)
message.quit = "#ffffff" ..getPlayerName(source) .. " #ffffffhas left game. [#ffffff" .. reason .. "#ffffff]"
addEventHandler ( "onClientRender", root, renderPlayerLeft )
setTimer(removeEventHandler,6000,1,"onClientRender", root, renderPlayerLeft )
end)
addEventHandler ( "onClientPlayerChangeNick", root,function ( oldNick, newNick )
message.nick = "#ffffff" ..oldNick.. " #ffffffis now known as #ffffff" ..newNick
addEventHandler ( "onClientRender", root, renderPlayerNick )
setTimer(removeEventHandler,6000,1,"onClientRender", root, renderPlayerNick )
end)
addEvent( "onPlayerLogin", true )
addEvent( "onPlayerLogout", true )
addEventHandler( "onPlayerLogin", root, function( player )
message.login = "#ffffff"..getPlayerName (player) .. " #ffffffhas successfully logged in!"
addEventHandler ( "onClientRender", root, renderPlayerLogin )
setTimer(removeEventHandler,6000,1,"onClientRender", root, renderPlayerLogin )
end)
addEventHandler( "onPlayerLogout", root, function( player )
message.login = "#ffffff"..getPlayerName (player) .. " #ffffffhas successfully logged out!"
addEventHandler ( "onClientRender", root, renderPlayerLogin )
setTimer(removeEventHandler,6000,1,"onClientRender", root, renderPlayerLogin )
end)
And where is "onJoin" triggered?