Jump to content

Recommended Posts

Подскажите пожалуйста, как сделать, чтобы при написании в чат, старые строки "уезжали" вверх.

if isChatVisible ( ) then 
    showChat ( false ) 
end 
         
local chatStatus            = true 
local EnterMessGUI 
local sW, sH = guiGetScreenSize ( ) 
local chatHistory           = {  
     
}    
         
addEventHandler ( "onClientRender", getRootElement(), 
    function (  ) 
        if not chatStatus then return end 
          
        if EnterMessGUI then 
            dxDrawRectangle ( sW/2-sW/2+8, sH/2+320, 771, 24, tocolor ( 42, 42, 42, 200 ) ) 
            dxDrawText ( guiGetText ( EnterMessGUI ), sW/2-sW/2+15, sH/2+323, 771, 24, tocolor ( 255,255,255,255 ), 1, "Segoe Ui" ) 
        end 
        -- 
        sY = 0 
        --  
         for i = 1, #chatHistory do      
            dxDrawText ( chatHistory [ i ] [ 2 ].. ": ", sW/2-sW/2 + 30, sH/2 + sY, 150, 30, tocolor ( 224,224,224,255), 1.05, "default-bold" ) -- вывод ника 
            wn = dxGetTextWidth ( chatHistory [ i ] [ 2 ]..": ", 1.05, "default-bold" ) 
            dxDrawText ( chatHistory [ i ] [ 1 ], sW/2-sW/2 + 30 + wn, sH/2+sY, 150, 30, tocolor ( 224,224,224,255), 1.05, "default-bold" ) -- вывод сообщения 
                         
            sY = sY + 20 
                 
         
        end          
        -- 
        -- 
        -- 
    end 
) 
  
local EnterMess  = false 
bindKey ( "t", "down",  
    function (  ) 
        if not EnterMess and chatStatus then 
            EnterMessGUI = guiCreateEdit ( sW/2-sW/2+8, sH/2+320, 771, 24, "", false) 
            guiSetAlpha ( EnterMessGUI, 0.00 ) 
            guiEditSetMaxLength ( EnterMessGUI, 100 )   
            EnterMess = true 
            showCursor ( true ) 
            guiBringToFront ( EnterMessGUI ) 
            setTimer (  
                function ( ) 
                    guiSetText ( EnterMessGUI, "" ) 
                end, 50, 1 ) 
        end 
    end 
) 
  
addEventHandler ( "onClientKey", root,  
    function ( key, press ) 
        if not press then return end 
        if EnterMess then  
            if key == "enter" then  
                -- 
                showCursor ( false ) 
                EnterMess    = false 
                text = guiGetText ( EnterMessGUI ) 
                destroyElement ( EnterMessGUI ) 
                EnterMessGUI = nil 
                if text == "" or text == " " then return end 
                table.insert ( chatHistory, { text, "Mr" } ) 
                -- 
        end 
    end 
) 

Link to comment

Подскажите пожалуйста, как сделать, чтобы при написании в чат, старые строки "уезжали" вверх.

if isChatVisible ( ) then 
    showChat ( false ) 
end 
         
local chatStatus            = true 
local EnterMessGUI 
local sW, sH = guiGetScreenSize ( ) 
local chatHistory           = {  
     
}    
         
addEventHandler ( "onClientRender", getRootElement(), 
    function (  ) 
        if not chatStatus then return end 
          
        if EnterMessGUI then 
            dxDrawRectangle ( sW/2-sW/2+8, sH/2+320, 771, 24, tocolor ( 42, 42, 42, 200 ) ) 
            dxDrawText ( guiGetText ( EnterMessGUI ), sW/2-sW/2+15, sH/2+323, 771, 24, tocolor ( 255,255,255,255 ), 1, "Segoe Ui" ) 
        end 
        -- 
        sY = 0 
        --  
         for i = 1, #chatHistory do      
            dxDrawText ( chatHistory [ i ] [ 2 ].. ": ", sW/2-sW/2 + 30, sH/2 + sY, 150, 30, tocolor ( 224,224,224,255), 1.05, "default-bold" ) -- вывод ника 
            wn = dxGetTextWidth ( chatHistory [ i ] [ 2 ]..": ", 1.05, "default-bold" ) 
            dxDrawText ( chatHistory [ i ] [ 1 ], sW/2-sW/2 + 30 + wn, sH/2+sY, 150, 30, tocolor ( 224,224,224,255), 1.05, "default-bold" ) -- вывод сообщения 
                         
            sY = sY + 20 
                 
         
        end          
        -- 
        -- 
        -- 
    end 
) 
  
local EnterMess  = false 
bindKey ( "t", "down",  
    function (  ) 
        if not EnterMess and chatStatus then 
            EnterMessGUI = guiCreateEdit ( sW/2-sW/2+8, sH/2+320, 771, 24, "", false) 
            guiSetAlpha ( EnterMessGUI, 0.00 ) 
            guiEditSetMaxLength ( EnterMessGUI, 100 )   
            EnterMess = true 
            showCursor ( true ) 
            guiBringToFront ( EnterMessGUI ) 
            setTimer (  
                function ( ) 
                    guiSetText ( EnterMessGUI, "" ) 
                end, 50, 1 ) 
        end 
    end 
) 
  
addEventHandler ( "onClientKey", root,  
    function ( key, press ) 
        if not press then return end 
        if EnterMess then  
            if key == "enter" then  
                -- 
                showCursor ( false ) 
                EnterMess    = false 
                text = guiGetText ( EnterMessGUI ) 
                destroyElement ( EnterMessGUI ) 
                EnterMessGUI = nil 
                if text == "" or text == " " then return end 
                table.insert ( chatHistory, { text, "Mr" } ) 
                -- 
        end 
    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...