Jump to content

onPlayerJoin/Quit


Absence2

Recommended Posts

Well, then I have a problem :P It goes 'nil' and floods the debug with it , window wont show and so on, works well without 'Relative' but that wont work well for the resolution settings though :/

local sText = '' 
local uTimer   
  
function fDraw( quitReason ) 
    sText = sText..string.format( 'Server: %s has %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 
            dxDrawRelativeText( sText,254.0,0.0,585.0,25.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
            dxDrawRelativeRectangle( 258.0,0.0,328.0,21.0,tocolor( 0,0,0,150 ),false ) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerJoin', root, fDraw ) 

Link to comment
  
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 dxDrawText(  
        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: #FFFFFF%s has %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 
            dxDrawRelativeText( sText,388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
            dxDrawRelativeRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerJoin', root, fDraw ) 
  

Updated.

Well, then I have a problem It goes 'nil' and floods the debug with it , window wont show and so on, works well without 'Relative' but that wont work well for the resolution settings though :/

Because you not have this functions in code :/

Learn lua please!

viewtopic.php?f=91&t=40809

Edited by Guest
Link to comment
  
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 dxDrawText(  
        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: #FFFFFF%s has %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 
            dxDrawRelativeText( sText,388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
            dxDrawRelativeRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerJoin', root, fDraw ) 
  

Updated.

Well, then I have a problem It goes 'nil' and floods the debug with it , window wont show and so on, works well without 'Relative' but that wont work well for the resolution settings though :/

Because you not have this functions in code :/

Learn lua please!

viewtopic.php?f=91&t=40809

I asked if I should of implanted it or not, and I was given a "no" :roll: and I'll learn Lua, no doubt about that :D, thanks for your help, all of you.

Link to comment

I tested it still but don't work.

Client Side :

  
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 dxDrawText( 
        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: #FFFFFF%s has %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 
            dxDrawRelativeText( sText,388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
            dxDrawRelativeRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerJoin', root, fDraw ) 
  

Link to comment
I tested it still but don't work.

Client Side :

local sText = '' 
local uTimer 
  
addEventHandler ( 'onClientPlayerJoin', root, 
    function() 
        sText = getPlayerName( source ) 
        if isTimer( uTimer ) then 
            killTimer( uTimer ) 
        end 
        uTimer = setTimer( 
            function( ) 
                sText = '' 
            end, 
        5000, 
        1 ) 
    end 
)   
  
addEventHandler( 'onClientRender', root, 
    function( ) 
local screenWidth, screenHeight = guiGetScreenSize() 
local nSw,nSh = guiGetScreenSize( ) 
local rootElement = getRootElement() 
local x,y = guiGetScreenSize() 
        if sText ~= '' then 
            dxDrawText( '#FFFFFFServer: #FFFFFF'.. sText .. ' has joined the server ',nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.55,"bankgothic","left","top",false,false,false) 
            dxDrawRectangle ( x/3.4, y/1.6, x/2.13, y/4.2, tocolor ( 0, 0, 0, 150 ) ) 
        end 
    end 
) 

This one worked for me,

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 dxDrawText( 
        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( 'Server: %s has %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,150 ),false ) 
            dxDrawRelativeText( sText,254.0,0.0,757.0,20.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerJoin', root, fDraw ) 
   

Link to comment
No problem. :)

but i think you need lengthen rectangle.

Thanks for the tip, I'm working on the positions, makes it a lot easier having guieditor for it :lol:

Was on this, but it was huge:

            dxDrawRelativeRectangle( 421.0,1.0,793.0,52.0,tocolor( 0,0,0,150 ),false ) 

This should do well:

        dxDrawRectangle(323.0,0.0,426.0,64.0,tocolor(0,0,0,150),false) 

centers it very well together with the text, thank you so much man, I really appreciate it. I'm tired of outputchatbox login/logouts... they're spam-ish. :D

Link to comment

I Tested It know but dont work when i join the server nothing dose show for me

Client Side :

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 dxDrawText( 
        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( 'Server: %s has %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,150 ),false ) 
            dxDrawRelativeText( sText,254.0,0.0,757.0,20.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerJoin', root, fDraw ) 
  

Link to comment

Client

addEvent( 'onClientPlayerLogin', true ) 
  
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 dxDrawText(  
        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: #FFFFFF%s has %s the server %s \n', 
    getPlayerName( source ), eventName == 'onClientPlayerQuit' and 'left' or eventName == 'onClientPlayerLogin' 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,150 ),false ) 
            dxDrawRelativeText( sText,254.0,0.0,757.0,20.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerLogin', root, fDraw ) 
  

Server

addEventHandler( 'onPlayerLogin', root, 
    function( ) 
        triggerClientEvent( root, 'onClientPlayerLogin', source ) 
    end 
)    

Link to comment
Thank you Kenix for help

No problem. :)

its will bad, cause if 2 players connect in 1-3 second, background will drawning '1', text '2' "\n"

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.

Link to comment
Thank you Kenix for help

No problem. :)

its will bad, cause if 2 players connect in 1-3 second, background will drawning '1', text '2' "\n"

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 :S

Link to comment

Lol, it's draw rectangle.

Client

local sText = '' 
local uTimer 
  
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 
  
addEvent( 'onClientPlayerLogin', true ) 
  
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: #FFFFFF%s has %s the server %s \n', 
    getPlayerName( source ), eventName == 'onClientPlayerQuit' and 'left' or eventName == 'onClientPlayerLogin' 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,150 ),false ) 
            dxDrawRelativeText( sText,254.0,0.0,757.0,20.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        end 
    end 
) 
  
addEventHandler ( 'onClientPlayerQuit', root, fDraw ) 
addEventHandler ( 'onClientPlayerLogin', root, fDraw ) 
  
  

sckatchof, Full code with color codes.

Edited by Guest
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...