Jump to content

GUI Help


FreeGells

Recommended Posts

Posted

Hello friends, i create this GUI with QTToLua , and i don't know how put this on game, how i open this GUI on press key F2 ? Please help! thank you

GUI:

function build_Dialog() 
     
    local gui = {} 
    gui._placeHolders = {} 
     
    local screenWidth, screenHeight = guiGetScreenSize() 
    local windowWidth, windowHeight = 633, 608 
    local left = screenWidth/2 - windowWidth/2 
    local top = screenHeight/2 - windowHeight/2 
    gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "SEALS Clan [ADMIN PANEL]", false) 
    guiWindowSetSizable(gui["_root"], false) 
     
    gui._placeHolders["online"] = {left = 10, top = 65, width = 211, height = 531, parent = gui["_root"]} 
     
    gui._placeHolders["variaveis"] = {left = 400, top = 65, width = 221, height = 531, parent = gui["_root"]} 
     
    gui["label"] = guiCreateLabel(10, 25, 201, 41, "Players Online:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label"], "left", false) 
    guiLabelSetVerticalAlign(gui["label"], "center") 
     
    gui["label_2"] = guiCreateLabel(400, 25, 201, 41, "Variaveis:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_2"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_2"], "center") 
     
    gui["setr"] = guiCreateEdit(250, 95, 121, 21, "", false, gui["_root"]) 
    guiEditSetMaxLength(gui["setr"], 32767) 
     
    gui["label_3"] = guiCreateLabel(250, 75, 71, 16, "Setar para:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_3"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_3"], "center") 
     
    gui["srt_botao"] = guiCreateButton(270, 125, 75, 23, "Setar", false, gui["_root"]) 
    if on_srt_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["srt_botao"], on_srt_botao_clicked, false) 
    end 
     
    gui["fecha_botao"] = guiCreateButton(270, 575, 75, 23, "Fechar", false, gui["_root"]) 
    if on_fecha_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["fecha_botao"], on_fecha_botao_clicked, false) 
    end 
     
    return gui, windowWidth, windowHeight 
end 

Posted

You will need;

bindKey 

Click on it for examples!

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted
function build_Dialog() 
    gui = {} 
    gui._placeHolders = {} 
    
    local screenWidth, screenHeight = guiGetScreenSize() 
    local windowWidth, windowHeight = 633, 608 
    local left = screenWidth/2 - windowWidth/2 
    local top = screenHeight/2 - windowHeight/2 
    gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "SEALS Clan [ADMIN PANEL]", false) 
    guiWindowSetSizable(gui["_root"], false) 
    guiSetVisible(gui["_root"], false) 
    
    gui._placeHolders["online"] = {left = 10, top = 65, width = 211, height = 531, parent = gui["_root"]} 
    
    gui._placeHolders["variaveis"] = {left = 400, top = 65, width = 221, height = 531, parent = gui["_root"]} 
    
    gui["label"] = guiCreateLabel(10, 25, 201, 41, "Players Online:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label"], "left", false) 
    guiLabelSetVerticalAlign(gui["label"], "center") 
    
    gui["label_2"] = guiCreateLabel(400, 25, 201, 41, "Variaveis:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_2"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_2"], "center") 
    
    gui["setr"] = guiCreateEdit(250, 95, 121, 21, "", false, gui["_root"]) 
    guiEditSetMaxLength(gui["setr"], 32767) 
    
    gui["label_3"] = guiCreateLabel(250, 75, 71, 16, "Setar para:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_3"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_3"], "center") 
    
    gui["srt_botao"] = guiCreateButton(270, 125, 75, 23, "Setar", false, gui["_root"]) 
    if on_srt_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["srt_botao"], on_srt_botao_clicked, false) 
    end 
    
    gui["fecha_botao"] = guiCreateButton(270, 575, 75, 23, "Fechar", false, gui["_root"]) 
    if on_fecha_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["fecha_botao"], on_fecha_botao_clicked, false) 
    end 
    
    return gui, windowWidth, windowHeight 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, build_Dialog ) 
  
bindKey ( "F2", 
    function ( ) 
        guiSetVisible ( gui["_root"], not guiGetVisible ( gui["_root"] ) ) 
        showCursor ( guiGetVisible ( gui["_root"] ) ) 
    end 
) 

Now you must create a resource and a .lua file, then you put this code on it and create a meta.xml for it.

https://wiki.multitheftauto.com/wiki/Meta.xml

NOTE: THIS IS A CLIENT SIDE SCRIPT.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

C'mon Castillo! What ever happened to "let him try and see how he gets on?" =D

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

Castillo, and to put the elements in the grind list ?

in the end of script have outputChatBox, i need put this in a grid "listWidget_2"...

Code updated:

function build_Dialog() 
     
    local gui = {} 
    gui._placeHolders = {} 
     
    local screenWidth, screenHeight = guiGetScreenSize() 
    local windowWidth, windowHeight = 633, 608 
    local left = screenWidth/2 - windowWidth/2 
    local top = screenHeight/2 - windowHeight/2 
    gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "SEALS Clan [ADMIN PANEL]", false) 
    guiWindowSetSizable(gui["_root"], false) 
     
    gui["label"] = guiCreateLabel(10, 25, 201, 41, "Players Online:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label"], "left", false) 
    guiLabelSetVerticalAlign(gui["label"], "center") 
     
    gui["label_2"] = guiCreateLabel(400, 25, 201, 41, "Variaveis:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_2"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_2"], "center") 
     
    gui["setr"] = guiCreateEdit(250, 95, 121, 21, "", false, gui["_root"]) 
    guiEditSetMaxLength(gui["setr"], 32767) 
     
    gui["label_3"] = guiCreateLabel(250, 75, 71, 16, "Setar para:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_3"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_3"], "center") 
     
    gui["srt_botao"] = guiCreateButton(270, 125, 75, 23, "Setar", false, gui["_root"]) 
    if on_srt_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["srt_botao"], on_srt_botao_clicked, false) 
    end 
     
    gui["fecha_botao"] = guiCreateButton(270, 575, 75, 23, "Fechar", false, gui["_root"]) 
    if on_fecha_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["fecha_botao"], on_fecha_botao_clicked, false) 
    end 
     
    gui["listWidget"] = guiCreateGridList(10, 65, 211, 531, false, gui["_root"]) 
    guiGridListSetSortingEnabled(gui["listWidget"], false) 
    gui["listWidget_col"] = guiGridListAddColumn(gui["listWidget"], "", 0.85) 
    local listWidget_row = nil 
     
    gui["listWidget_2"] = guiCreateGridList(400, 65, 221, 531, false, gui["_root"]) 
    guiGridListSetSortingEnabled(gui["listWidget_2"], false) 
    gui["listWidget_2_col"] = guiGridListAddColumn(gui["listWidget_2"], "", 0.85) 
    local listWidget_2_row = nil 
     
    return gui, windowWidth, windowHeight 
end 
  
function on_srt_botao_clicked(button, state, absoluteX, absoluteY) 
    if (button ~= "left") or (state ~= "up") then 
  
        return 
    end 
     
end 
  
function on_fecha_botao_clicked(button, state, absoluteX, absoluteY) 
    if (button ~= "left") or (state ~= "up") then 
  
        return 
    end 
     
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, build_Dialog ) 
  
bindKey ( "F2", 
    function ( ) 
        guiSetVisible ( gui["_root"], not guiGetVisible ( gui["_root"] ) ) 
        showCursor ( guiGetVisible ( gui["_root"] ) ) 
        local data = getAllElementData(thePlayer) 
        for k, v in pairs(data) do 
            outputChatBox(tostring(k) .. ": " .. tostring(v), thePlayer) // here the function to add at the grid 
        end 
    end 
) 

Posted

No, the only way would be requesting the data from client and get it at server, then send it to the client.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

I do, but I don't give it to everyone, you can send me a PM explaining why you want it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Ok.. one more help, on i enter in the server, the GUI is visible, the F3 button don't work, and the online players don't appears in the grid... ):

  
function joinHandler() 
    guiSetVisible ( gui["_root"], false ) 
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, build_Dialog ) 
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 
  
bindKey ( "F3", 
    function ( ) 
        guiSetVisible ( gui["_root"], not guiGetVisible ( gui["_root"] ) ) 
        showCursor ( guiGetVisible ( gui["_root"] ) ) 
        local column = guiGridListAddColumn( gui["listWidget"], "Online:", 0.85 ) 
        for id, playeritem in ipairs(getElementsByType("player")) do  
            local row = guiGridListAddRow ( gui["listWidget"] ) 
            guiGridListSetItemText ( gui["listWidget"], row, column, getPlayerName ( playeritem ), false, false ) 
        end 
    end 
) 

Posted

Post the whole script.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Oh, sorry..

function build_Dialog() 
     
    local gui = {} 
    gui._placeHolders = {} 
     
    local screenWidth, screenHeight = guiGetScreenSize() 
    local windowWidth, windowHeight = 633, 608 
    local left = screenWidth/2 - windowWidth/2 
    local top = screenHeight/2 - windowHeight/2 
    gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "SEALS Clan [ADMIN PANEL]", false) 
    guiWindowSetSizable(gui["_root"], false) 
     
    gui["label"] = guiCreateLabel(10, 25, 201, 41, "Players Online:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label"], "left", false) 
    guiLabelSetVerticalAlign(gui["label"], "center") 
     
    gui["label_2"] = guiCreateLabel(400, 25, 201, 41, "Variaveis:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_2"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_2"], "center") 
     
    gui["setr"] = guiCreateEdit(250, 95, 121, 21, "", false, gui["_root"]) 
    guiEditSetMaxLength(gui["setr"], 32767) 
     
    gui["label_3"] = guiCreateLabel(250, 75, 71, 16, "Setar para:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_3"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_3"], "center") 
     
    gui["srt_botao"] = guiCreateButton(270, 125, 75, 23, "Setar", false, gui["_root"]) 
    if on_srt_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["srt_botao"], on_srt_botao_clicked, false) 
    end 
     
    gui["fecha_botao"] = guiCreateButton(270, 575, 75, 23, "Fechar", false, gui["_root"]) 
    if on_fecha_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["fecha_botao"], on_fecha_botao_clicked, false) 
    end 
     
    gui["listWidget"] = guiCreateGridList(10, 65, 211, 531, false, gui["_root"]) 
    guiGridListSetSortingEnabled(gui["listWidget"], false) 
    gui["listWidget_col"] = guiGridListAddColumn(gui["listWidget"], "", 0.85) 
    local listWidget_row = nil 
     
    gui["listWidget_2"] = guiCreateGridList(400, 65, 221, 531, false, gui["_root"]) 
    guiGridListSetSortingEnabled(gui["listWidget_2"], false) 
    gui["listWidget_2_col"] = guiGridListAddColumn(gui["listWidget_2"], "", 0.85) 
    local listWidget_2_row = nil 
     
    return gui, windowWidth, windowHeight 
end 
  
function on_srt_botao_clicked(button, state, absoluteX, absoluteY) 
    if (button ~= "left") or (state ~= "up") then 
  
        return 
    end 
     
end 
  
function on_fecha_botao_clicked(button, state, absoluteX, absoluteY) 
    if (button ~= "left") or (state ~= "up") then 
            guiSetVisible ( gui["_root"], false ) 
        return 
    end 
     
end 
  
function joinHandler() 
    guiSetVisible ( gui["_root"], false ) 
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, build_Dialog ) 
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 
  
bindKey ( "F3", 
    function ( ) 
        guiSetVisible ( gui["_root"], not guiGetVisible ( gui["_root"] ) ) 
        showCursor ( guiGetVisible ( gui["_root"] ) ) 
        for id, playeritem in ipairs(getElementsByType("player")) do  
            local row = guiGridListAddRow ( gui["listWidget"] ) 
            guiGridListSetItemText ( gui["listWidget"], row, gui["listWidget_col"], getPlayerName ( playeritem ), false, false ) 
        end 
    end 
) 

Posted
function build_Dialog() 
    gui = {} 
    gui._placeHolders = {} 
    
    local screenWidth, screenHeight = guiGetScreenSize() 
    local windowWidth, windowHeight = 633, 608 
    local left = screenWidth/2 - windowWidth/2 
    local top = screenHeight/2 - windowHeight/2 
    gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "SEALS Clan [ADMIN PANEL]", false) 
    guiWindowSetSizable(gui["_root"], false) 
    guiSetVisible ( gui["_root"], false ) 
    
    gui["label"] = guiCreateLabel(10, 25, 201, 41, "Players Online:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label"], "left", false) 
    guiLabelSetVerticalAlign(gui["label"], "center") 
    
    gui["label_2"] = guiCreateLabel(400, 25, 201, 41, "Variaveis:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_2"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_2"], "center") 
    
    gui["setr"] = guiCreateEdit(250, 95, 121, 21, "", false, gui["_root"]) 
    guiEditSetMaxLength(gui["setr"], 32767) 
    
    gui["label_3"] = guiCreateLabel(250, 75, 71, 16, "Setar para:", false, gui["_root"]) 
    guiLabelSetHorizontalAlign(gui["label_3"], "left", false) 
    guiLabelSetVerticalAlign(gui["label_3"], "center") 
    
    gui["srt_botao"] = guiCreateButton(270, 125, 75, 23, "Setar", false, gui["_root"]) 
    if on_srt_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["srt_botao"], on_srt_botao_clicked, false) 
    end 
    
    gui["fecha_botao"] = guiCreateButton(270, 575, 75, 23, "Fechar", false, gui["_root"]) 
    if on_fecha_botao_clicked then 
        addEventHandler("onClientGUIClick", gui["fecha_botao"], on_fecha_botao_clicked, false) 
    end 
    
    gui["listWidget"] = guiCreateGridList(10, 65, 211, 531, false, gui["_root"]) 
    guiGridListSetSortingEnabled(gui["listWidget"], false) 
    gui["listWidget_col"] = guiGridListAddColumn(gui["listWidget"], "", 0.85) 
    
    gui["listWidget_2"] = guiCreateGridList(400, 65, 221, 531, false, gui["_root"]) 
    guiGridListSetSortingEnabled(gui["listWidget_2"], false) 
    gui["listWidget_2_col"] = guiGridListAddColumn(gui["listWidget_2"], "", 0.85) 
    
    return gui, windowWidth, windowHeight 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, build_Dialog ) 
  
function on_srt_botao_clicked ( button, state, absoluteX, absoluteY ) 
    if ( button ~= "left" ) or ( state ~= "up" ) then 
    end 
end 
  
function on_fecha_botao_clicked ( button, state, absoluteX, absoluteY ) 
    if ( button ~= "left" ) or ( state ~= "up" ) then 
        guiSetVisible ( gui["_root"], false ) 
    end 
end 
  
bindKey ( "F3", 
    function ( ) 
        guiSetVisible ( gui["_root"], not guiGetVisible ( gui["_root"] ) ) 
        showCursor ( guiGetVisible ( gui["_root"] ) ) 
        if ( guiGetVisible ( gui["_root"] ) ) then 
            for id, playeritem in ipairs(getElementsByType("player")) do 
                local row = guiGridListAddRow ( gui["listWidget"] ) 
                guiGridListSetItemText ( gui["listWidget"], row, gui["listWidget_col"], getPlayerName ( playeritem ), false, false ) 
            end 
        end 
    end 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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...