Jump to content

JoinQuit NUEVO!


Recommended Posts

Hola bueno hacemos este post aver si me ayudan mejor quisiera hacer un script donde , cuando uno se connecta aparesca esto

* ejemplo has joined the game " que diga "ejemplo se a unido " y cuando se va diga "ejemplo abandono el server" que en vez de que aparesca en el chat que aparesca a la derecha de la pantalla

Link to comment

pero creo que no entendes por que yo ise uno pero no anda

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 messageJoin = "" 
local messageQuit = "" 
  
function renderPlayerJoined ( ) 
    dxDrawColorText("* ".. messageJoin,504.0,4.0,574.0,20.0,tocolor(200,0,0,255),0.7,"sans","left","top",false,false,false) 
end 
  
function renderPlayerLeft ( ) 
    dxDrawColorText("* ".. messageQuit,503.0,16.0,573.0,32.0,tocolor(0,0,255,170),0.7,"sans","left","top",false,false,false) 
end 
  
addEventHandler('onClientPlayerJoin', root, 
    function() 
        messageJoin = getPlayerName(source) .. " #ffffffa entrado al servidor." 
        addEventHandler ( "onClientRender", root, renderPlayerJoined ) 
        setTimer ( 
            function ( ) 
                removeEventHandler ( "onClientRender", root, renderPlayerJoined ) 
            end 
            ,6000,1 
        ) 
    end 
) 
  
addEventHandler('onClientPlayerChangeNick', root, 
    function(oldNick, newNick) 
        outputChatBox('* ' .. oldNick .. ' #ffffffis now known as ' .. newNick, 255, 100, 100) 
    end 
) 
  
addEventHandler('onClientPlayerQuit', root, 
    function(reason) 
        messageQuit  = getPlayerName(source) .. " #ffffffa salido del server [" .. reason .. "]" 
        addEventHandler ( "onClientRender", root, renderPlayerLeft ) 
        setTimer ( 
            function ( ) 
                removeEventHandler ( "onClientRender", root, renderPlayerLeft ) 
            end 
            ,6000,1 
        ) 
    end 
) 
  

Link to comment

-- Client Side

local toDraw = "" 
local screenWidth, screenHeight = guiGetScreenSize ( ) 
  
addEventHandler('onClientPlayerJoin', root, 
    function ( ) 
        toDraw = getPlayerName ( source ):gsub ( "#%x%x%x%x%x%x", "" ) .." Se ha unido al servidor." 
    end 
) 
  
addEventHandler('onClientPlayerQuit', root, 
    function ( ) 
        toDraw = getPlayerName ( source ):gsub ( "#%x%x%x%x%x%x", "" ) .." Se fue del servidor." 
    end 
) 
     
function drawText ( ) 
    dxDrawText ( toDraw, 35, screenHeight - 260, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 0.5, "pricedown" ) 
end 
addEventHandler ( "onClientRender", root, drawText ) 
  

Si quieres cambiar la posicion y el color de la letra se cambia aca :

  dxDrawText ( toDraw, 35, screenHeight - 260, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 0.5, "pricedown" ) 
  

Ya habia un tema sobre esto deberias mirar antes de postear un nuevo tema sobre lo mismo.

Link to comment
  • Recently Browsing   0 members

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