FreeGells Posted February 5, 2013 Share Posted February 5, 2013 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 Link to comment
Lloyd Logan Posted February 5, 2013 Share Posted February 5, 2013 You will need; bindKey Click on it for examples! Link to comment
Castillo Posted February 5, 2013 Share Posted February 5, 2013 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. Link to comment
Lloyd Logan Posted February 5, 2013 Share Posted February 5, 2013 C'mon Castillo! What ever happened to "let him try and see how he gets on?" =D Link to comment
FreeGells Posted February 5, 2013 Author Share Posted February 5, 2013 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 ) Link to comment
Castillo Posted February 5, 2013 Share Posted February 5, 2013 Use the example from: https://wiki.multitheftauto.com/wiki/GuiCreateGridList Also, "getAllElementData" is a server side only function, you can't use it on a client side script. Link to comment
FreeGells Posted February 5, 2013 Author Share Posted February 5, 2013 and i can't put the elements in the grid to edit them? ): Link to comment
Castillo Posted February 5, 2013 Share Posted February 5, 2013 No, the only way would be requesting the data from client and get it at server, then send it to the client. Link to comment
FreeGells Posted February 5, 2013 Author Share Posted February 5, 2013 ok, thanks for the help castillo, you have skype? Link to comment
Castillo Posted February 5, 2013 Share Posted February 5, 2013 You're welcome. I do, but I don't give it to everyone, you can send me a PM explaining why you want it. Link to comment
FreeGells Posted February 5, 2013 Author Share Posted February 5, 2013 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 ) Link to comment
Castillo Posted February 5, 2013 Share Posted February 5, 2013 Post the whole script. Link to comment
FreeGells Posted February 5, 2013 Author Share Posted February 5, 2013 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 ) Link to comment
Castillo Posted February 5, 2013 Share Posted February 5, 2013 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 ) Link to comment
FreeGells Posted February 6, 2013 Author Share Posted February 6, 2013 61: Bad argument @ 'bindKey' Link to comment
TAPL Posted February 6, 2013 Share Posted February 6, 2013 bindKey ( "F3", should be: bindKey ( "F3", "down", Link to comment
FreeGells Posted February 6, 2013 Author Share Posted February 6, 2013 The error continue... .lua:61: Bad argument @ 'bindKey' @EDIT FIXED! Thanks for all. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now