kevincouto6 Posted December 14, 2018 Share Posted December 14, 2018 É possivel evitar de fazer tudo isso, talvez uma tabela ou algo do tipo, tenho que criar mais ou menos 20 "guiCreateMemo", exite uma maneira mais facil de fazer, se tiver poderia me ensinar ? GUIEditor = { button = {}, window = {}, memo = {} } addEventHandler("onClientResourceStart", resourceRoot, function() infoMission = guiCreateWindow(939, 156, 196, 329, "Mission Description", false) guiSetVisible (infoMission, false) guiWindowSetSizable(infoMission, false) memo = guiCreateMemo(9, 32, 175, 196, "You must kill 50 zombies in area 51\n\n \n Reward\nMoney: R$ 5,000.00 \nEXP : 3555 ", false, infoMission) exitBuInfo = guiCreateButton(10, 280, 174, 40, "EXIT", false, infoMission) copyButton = guiCreateButton(9, 233, 175, 37, "COPY", false, infoMission) end ) addEventHandler("onClientResourceStart", resourceRoot, function() infoMission2 = guiCreateWindow(939, 156, 196, 329, "Mission Description", false) guiSetVisible (infoMission2, false) guiWindowSetSizable(infoMission, false) memo2 = guiCreateMemo(9, 32, 175, 196, "123456", false, infoMission2) exitBuInfo2 = guiCreateButton(10, 280, 174, 40, "EXIT", false, infoMission2) copyButton2 = guiCreateButton(9, 233, 175, 37, "COPY", false, infoMission2) end ) addEventHandler("onClientResourceStart", resourceRoot, function() infoMission3 = guiCreateWindow(939, 156, 196, 329, "Mission Description", false) guiSetVisible (infoMission3, false) guiWindowSetSizable(infoMission3, false) memo3 = guiCreateMemo(9, 32, 175, 196, "KEVIN", false, infoMission3) exitBuInfo3 = guiCreateButton(10, 280, 174, 40, "EXIT", false, infoMission3) copyButton3 = guiCreateButton(9, 233, 175, 37, "COPY", false, infoMission3) end ) addEventHandler ("onClientGUIClick", getRootElement(), function (button, state, absoluteX, absoluteY) local me = not guiGetVisible (infoMission) if (source == exitBuInfo) then guiSetVisible (infoMission, me) end end) addEventHandler ("onClientGUIClick", getRootElement(), function (button, state, absoluteX, absoluteY) local me = not guiGetVisible (infoMission2) if (source == exitBuInfo2) then guiSetVisible (infoMission2, me) end end) addEventHandler ("onClientGUIClick", getRootElement(), function (button, state, absoluteX, absoluteY) local me = not guiGetVisible (infoMission3) if (source == exitBuInfo3) then guiSetVisible (infoMission3, me) end end) Link to comment
kevincouto6 Posted December 14, 2018 Author Share Posted December 14, 2018 Desculpe, postar 2 veses, não consegui editar aqui esta a parte onde os torna visível addEventHandler ("onClientGUIClick", getRootElement(), function (button, state, absoluteX, absoluteY) outputDebugString("onClientGUIClick called.") local me = not guiGetVisible (WinMission) if (source == info) then outputDebugString("guiGridListGetSelectedItem(ListMissions): "..guiGridListGetSelectedItem(ListMissions)) if (guiGridListGetSelectedItem(ListMissions) == 0) then outputDebugString("1 was selected") guiSetVisible (infoMission, true) guiSetVisible (infoMission2, me) guiSetVisible (infoMission3, me) elseif (guiGridListGetSelectedItem(ListMissions) == 1) then outputDebugString("2 was selected") guiSetVisible (infoMission2, true) guiSetVisible (infoMission, me) guiSetVisible (infoMission3, me) elseif (guiGridListGetSelectedItem(ListMissions) == 2) then outputDebugString("3 was selected") guiSetVisible (infoMission3, true) guiSetVisible (infoMission2, me) guiSetVisible (infoMission, me) elseif (guiGridListGetSelectedItem(ListMissions) == 3) then outputDebugString("4 was selected") end end end ) Link to comment
[M]ister Posted December 14, 2018 Share Posted December 14, 2018 Você precisa aprender tabelas e loops. local janelas = { { titulo = "Mission Description", memo = "You must kill 50 zombies in area 51\n\n \n Reward\nMoney: R$ 5,000.00 \nEXP : 3555 " }, { titulo = "Mission Description", memo = "123456" }, { titulo = "Mission Description", memo = "KEVIN" } } local elementos = { window = {}, btns = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() for i,janela in ipairs(janelas) do wnd = guiCreateWindow(939, 156, 196, 329, janela.titulo, false) elementos.window[wnd] = i-1 guiSetVisible (wnd, false) guiWindowSetSizable(wnd, false) guiCreateMemo(9, 32, 175, 196, janela.memo, false, wnd) btnExit = guiCreateButton(10, 280, 174, 40, "EXIT", false, wnd) btnCopy = guiCreateButton(9, 233, 175, 37, "COPY", false, wnd) elementos.btns[btnExit] = {wnd,"exit"} elementos.btns[btnCopy] = {wnd,"copy"} end end ) addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY) if (elementos.btns[source]) then if (elementos.btns[source][2] == "exit") then guiSetVisible (elementos.btns[source][1], false) end end end) addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY) if (source == info) then for wnd, id in pairs(elementos.window) do if (id == guiGridListGetSelectedItem(ListMissions)) then guiSetVisible (wnd, true) else guiSetVisible (wnd, false) end end end end) 1 Link to comment
kevincouto6 Posted December 14, 2018 Author Share Posted December 14, 2018 (edited) 1 hour ago, MaligNos said: conhece algum tutorial que possa me ajudar a compreender tablas e loops? e obrigado pela ajuda Edited December 14, 2018 by kevincouto6 Link to comment
[M]ister Posted December 15, 2018 Share Posted December 15, 2018 1 hour ago, kevincouto6 said: conhece algum tutorial que possa me ajudar a compreender tablas e loops? e obrigado pela ajuda Eu coloquei dois links de tutoriais no meu comentário acima. E também existem vários outros espalhados por ai, basta saber pesquisar (Google é um grande amigo de qualquer programador). Link to comment
miiguelz Posted December 15, 2018 Share Posted December 15, 2018 https://www.youtube.com/watch?v=W_NgkjPyIck&index=16&list=PLqYboeh3Jru55Yq4J08zsBoOwwwjUtZNA Este tutorial, explica bem detalhado sobre a questão de tabelas e loops. da uma analisada. Link to comment
kevincouto6 Posted February 2, 2019 Author Share Posted February 2, 2019 (edited) addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY) if (elementos.btns[source]) then if (elementos.btns[source][2] == "copy") then setClipboard(guiGetText(wordsCopy)) end end end) OBS: o script é o memo que esta acima, por isso não postei todo novamente, lado CLIENT ! desculpe reviver este topic, porem estou com uma dificuldade, tipo setClipBoard estou tentando faze-lo no botão COPY, porem só copia o ultimo { titulo = "Mission Description", memo = "KEVIN" } Tipo so COPIA o "KEVIN" , como fasso pra ele copiar da guiMemo que tiver aberta, tipo aperto info e abre conforme a lista, porem quando copio copia apenas o do ultimo da lista, sabe me dizer como resolver ? eu renomei o guiCreateMemo, para wordsCopy mas não sei como add um verificação ou algo do tipo para copiar o memo que foi selecionado da lista addEventHandler("onClientResourceStart", resourceRoot, function() for i,janela in ipairs(janelas) do wnd = guiCreateWindow(598, 161, 202, 329, janela.titulo, false) elementos.window[wnd] = i-1 guiSetVisible (wnd, false) guiWindowSetSizable(wnd, false) wordsCopy = guiCreateMemo(9, 32, 175, 196, janela.memo, false, wnd) btnExit = guiCreateButton(10, 280, 174, 40, "EXIT", false, wnd) btnCopy = guiCreateButton(9, 233, 175, 37, "COPY", false, wnd) elementos.btns[btnExit] = {wnd,"exit"} elementos.btns[btnCopy] = {wnd,"copy"} end end ) espero que consigam me entender, desde ja obrigado, e desculpem por reviver esse topic, achei melhor aki do que criar outro Edited February 2, 2019 by kevincouto6 Link to comment
[M]ister Posted February 2, 2019 Share Posted February 2, 2019 wordsCopy = guiCreateMemo(9, 32, 175, 196, janela.memo, false, wnd) btnExit = guiCreateButton(10, 280, 174, 40, "EXIT", false, wnd) btnCopy = guiCreateButton(9, 233, 175, 37, "COPY", false, wnd) elementos.btns[btnExit] = {wnd,"exit"} elementos.btns[btnCopy] = {wnd,"copy",wordsCopy} --- addEventHandler ("onClientGUIClick", resourceRoot, function (button, state, absoluteX, absoluteY) if (elementos.btns[source]) then if (elementos.btns[source][2] == "copy") then local title = guiGetText(elementos.btns[source][1]) local memo = guiGetText(elementos.btns[source][3]) -- Exemplo copiando os dois setClipboard ( title.." : "..memo ) end end end) Link to comment
kevincouto6 Posted February 2, 2019 Author Share Posted February 2, 2019 3 hours ago, MaligNos said: Muitoo Obrigadoo 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