saluta Posted July 5, 2021 Share Posted July 5, 2021 (edited) Помоги пожалуйста Reveal hidden contents --full code m4a1_img = guiCreateStaticImage( W/2-100/1.4, 30+365, 100, 50, "img/46.png", false, arkaplan ) m4a1_btngzl = guiCreateStaticImage( W/2-94.5/2, 30+422, 102, 21, "img/panel2.png", false, arkaplan ) m4a1_L = guiCreateLabel( W/2-94.5/2, 30+422, 100, 20, "Парашют - 18000$", false, arkaplan ) guiSetProperty( m4a1_btngzl, "ImageColours", "tl:FFCFCFCF tr:FFCFCFCF bl:FFCFCFCF br:FFCFCFCF" ) guiSetAlpha( m4a1_btngzl, 0 ) guiLabelSetHorizontalAlign( m4a1_L, "center" ) guiSetFont( m4a1_L, font ) guiSetEnabled( m4a1_btngzl, false ) Фото Edited July 5, 2021 by saluta Link photo fixed Link to comment
Erlkonig Posted July 5, 2021 Share Posted July 5, 2021 Пришлите пожалуйста весь код. I guess it should be moved into russian section. Link to comment
saluta Posted July 6, 2021 Author Share Posted July 6, 2021 (edited) On 05/07/2021 at 21:50, Erlkonig said: Пришлите пожалуйста весь код. Думаю, его нужно переместить в русский раздел. Expand Reveal hidden contents addEventHandler( "onClientGUIDoubleClick", root, function() if isInArray (pointData,guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 )) then rebuildGridList (isInArray (pointData,guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 ))) end if guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 )=="..." then rebuildGridList (0) end end) help pls Edited July 6, 2021 by saluta Code fixed Link to comment
saluta Posted July 6, 2021 Author Share Posted July 6, 2021 Heeelp please urgent need Link to comment
Scripting Moderators Sarrum Posted July 6, 2021 Scripting Moderators Share Posted July 6, 2021 Если речь про код, который выше, переменная grid нигде не определена. Но если нужен элемент, по которому дважды щёлкнули, тогда используйте source, которая и будет этим элементом. Link to comment
saluta Posted July 6, 2021 Author Share Posted July 6, 2021 On 06/07/2021 at 17:44, Sarrum said: Если речь про код, выше, переменная сетка нигде не определена. Но если нужно элемент, по которому дважды щёлкнул, тогда используйте источник , которая и будет этот элемент. Expand как использовать то, пример кода хотябы есть? Link to comment
Scripting Moderators Sarrum Posted July 6, 2021 Scripting Moderators Share Posted July 6, 2021 Достаточно просто заменить grid в этом участке кода на source. Link to comment
saluta Posted July 7, 2021 Author Share Posted July 7, 2021 On 06/07/2021 at 19:10, Sarrum said: Достаточно просто заменить grid в этом участке кода на source. Expand гдк именно заменить, напишите это на моем коде пожалуйста. Link to comment
Scripting Moderators Sarrum Posted July 7, 2021 Scripting Moderators Share Posted July 7, 2021 addEventHandler( "onClientGUIDoubleClick", root, function() if isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )) then rebuildGridList (isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 ))) end if guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )=="..." then rebuildGridList (0) end end) Link to comment
saluta Posted July 7, 2021 Author Share Posted July 7, 2021 On 07/07/2021 at 08:51, Sarrum said: addEventHandler( "onClientGUIDoubleClick", root, function() if isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )) then rebuildGridList (isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 ))) end if guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )=="..." then rebuildGridList (0) end end) Expand некоторые ошибки пропали но остались и те же ошибки Warning: gps\client.lua:157:Bad argument @'guiGridListGetSelectedItem' [Expected gui-element at argument 1] и Warning: gps\client.lua:157:Bad argument @'guiGridListGetItemText' [Expected gui-element at argument 1] On 07/07/2021 at 08:51, Sarrum said: addEventHandler( "onClientGUIDoubleClick", root, function() if isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )) then rebuildGridList (isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 ))) end if guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )=="..." then rebuildGridList (0) end end) Expand это вот эта строка 157 -- Reveal hidden contents if guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )=="..." then Link to comment
Scripting Moderators Sarrum Posted July 7, 2021 Scripting Moderators Share Posted July 7, 2021 Сложно ответить без остального кода. Возможно событие onClientGUIDoubleClick срабатывает на клики по другим GUI элементам, либо же в rebuildGridList с гридлистом что-то происходит. Link to comment
saluta Posted July 7, 2021 Author Share Posted July 7, 2021 On 07/07/2021 at 12:50, Sarrum said: Сложно ответить без остального кода. Возможно событие onClientGUIDoubleClick срабатывает на клики по другим элементам GUI, либо же в rebuildGridList с гридлистом что-то происходит. Expand так иесть это событие срабатывает на клики по другим элементам GUI в том же числе в админ панеле. Что делать Link to comment
saluta Posted July 7, 2021 Author Share Posted July 7, 2021 On 07/07/2021 at 12:50, Sarrum said: Сложно ответить без остального кода. Возможно событие onClientGUIDoubleClick срабатывает на клики по другим элементам GUI, либо же в rebuildGridList с гридлистом что-то происходит. Expand FUll code: Reveal hidden contents local function isInTable (array,element) if array and element then for i = 1, #array do for l = 1, #array[i] do if array[i][l] == element then return i, l end end end else return false end end local function isInArray (array,element) if array and element then for i = 1, #array do if array[i]==element then return i end end else return false end end local function isInTable (array,element) if array and element then for i = 1, #array do for l = 1, #array[i] do if array[i][l] == element then return i, l end end end else return false end end local function setGuiVisible (state) guiSetVisible ( okno , state) showCursor(state) end local function workWithBlip (x,y,z) if x and y and z then if #blips>0 then for i = 1, #blips do local lx,ly,lz = getElementPosition(blips[i]) if lx == tonumber(x) and ly == tonumber(y) and lz == tonumber(z) then destroyElement(blips[i]) table.remove (blips, i) break else if i == #blips then blips[#blips+1] = createBlip ( x, y, z , 41, 1 ) lx,ly,lz = nil end end end else blips[#blips+1] = createBlip ( x, y, z , 41, 1 ) lx,ly,lz = nil end else return false end end function rebuildGridList (typeOfGrid) local row = nil if isElement(grid) then destroyElement(grid) end grid = guiCreateGridList ( 10,30,390,250, false, okno ) if typeOfGrid then if typeOfGrid >= 1 then column = guiGridListAddColumn ( grid, pointData[typeOfGrid], 0.9 ) row = guiGridListAddRow ( grid ) guiGridListSetItemText ( grid, row, column, "...", false, false ) for i = 1, #dataArray do if tonumber(dataArray[i][5]) == typeOfGrid then local row = guiGridListAddRow ( grid ) guiGridListSetItemText ( grid, row, column, dataArray[i][1], false, false ) row = nil end end else column = guiGridListAddColumn ( grid, "Название", 0.9 ) for i = 1, #pointData do row = guiGridListAddRow ( grid ) guiGridListSetItemText ( grid, row, column, pointData[i], false, false ) row = nil end end else return false end end --bind gui bindKey ( "F4", "down", function () setGuiVisible(not guiGetVisible(okno)) rebuildGridList (-1) end) --gui click addEventHandler ( "onClientGUIClick", root, function () if source == Button_Start then if isInTable (dataArray,guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 )) then local a, b = isInTable (dataArray,guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 )) workWithBlip(dataArray[a][2],dataArray[a][3],dataArray[a][4]) end end if source == Button_Exit then setGuiVisible(false) end end) addEventHandler( "onClientGUIDoubleClick", root, function() if isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )) then rebuildGridList (isInArray (pointData,guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 ))) end if guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 )=="..." then rebuildGridList (0) end end) Link to comment
Scripting Moderators Sarrum Posted July 7, 2021 Scripting Moderators Share Posted July 7, 2021 addEventHandler( "onClientGUIDoubleClick", guiRoot, function() if source == grid then local row = guiGridListGetSelectedItem ( grid ) local itemText = guiGridListGetItemText ( grid, row, 1 ) local i = isInArray (pointData,itemText) if i then rebuildGridList (i) end if itemText=="..." then rebuildGridList (0) end end end) 1) Разумней использовать guiRoot, если GUI элементы в одном ресурсе. guiRoot - корневой элемент всех GUI элементов текущего ресурса. 2) Добавил проверку, что элемент, по которому кликнули это действительно нужный гридлист. 3) Перед rebuildGridList() нужно сохранить значение guiGridListGetItemText в переменную, ибо после "ребилда" там будет уже совершенно другой текст, так как список поменяется. Либо же перед if itemText=="..." then можно заново получать row и itemText. 1 Link to comment
saluta Posted July 8, 2021 Author Share Posted July 8, 2021 On 07/07/2021 at 20:29, Sarrum said: addEventHandler( "onClientGUIDoubleClick", guiRoot, function() if source == grid then local row = guiGridListGetSelectedItem ( grid ) local itemText = guiGridListGetItemText ( grid, row, 1 ) local i = isInArray (pointData,itemText) if i then rebuildGridList (i) end if itemText=="..." then rebuildGridList (0) end end end) 1) Разумней использовать guiRoot, если GUI элементы в одном ресурсе. guiRoot - корневой элемент всех GUI элементов текущего ресурса. 2) Добавил проверку, что элемент, по которому кликнули это действительно нужный гридлист. 3) Перед rebuildGridList() нужно сохранить значение guiGridListGetItemText в переменную, ибо после "ребилда" там будет уже совершенно другой текст, так как список поменяется. Либо же перед if itemText=="..." then можно заново получать row и itemText. Expand спасибО, низкий поклон Link to comment
saluta Posted July 10, 2021 Author Share Posted July 10, 2021 On 07/07/2021 at 20:29, Sarrum said: addEventHandler( "onClientGUIDoubleClick", guiRoot, function() if source == grid then local row = guiGridListGetSelectedItem ( grid ) local itemText = guiGridListGetItemText ( grid, row, 1 ) local i = isInArray (pointData,itemText) if i ) end if itemText=="..." then rebuildGridList (0) end end 1) Разумней использовать guiRoot, если GUI элементы в одном ресурсе. guiRoot - корневой элемент всех GUI элементов текущего ресурса. 2) Добавил проверку, что элемент, по которому кликнули это действительно нужный гридлист. 3) Перед rebuildGridList() нужно сохранить значение guiGridListGetItemText в переменную, ибо после "ребилда" там будет уже совершенно другой текст, так как список поменяется. Либо же перед if itemText=="..." then можно заново получать row и Expand а нет ошибься ошибки пропали но теперь маркер не пропадает когда я жму кнопку отметить или снять метку с карты Link to comment
Scripting Moderators Sarrum Posted July 10, 2021 Scripting Moderators Share Posted July 10, 2021 On 10/07/2021 at 18:12, saluta said: а нет ошибься ошибки пропали но теперь маркер не пропадает когда я жму кнопку отметить или снять метку с карты Expand Но метка пропадает? Возможно нужно выполнить совет в 3 пункте тогда (про row и itemText), либо же пересмотреть логику в своём коде. 1 Link to comment
saluta Posted July 11, 2021 Author Share Posted July 11, 2021 On 10/07/2021 at 19:42, Sarrum said: Но метка пропадает? Возможно нужно выполнить совет в 3 тогда (про row и itemText ), либо же пересмотреть логику в своём коде. Expand нет метка не пропадает, она ставится ее видно а вот как нажимаешь снова она же по сути должна снятся метка но она не снимается. Link to comment
saluta Posted July 11, 2021 Author Share Posted July 11, 2021 А не надо уже спасибо, уже сам исправил, спасибо огромное за то что просто помогли исправить предыдущие ошибки) 1 Link to comment
Scripting Moderators Sarrum Posted July 11, 2021 Scripting Moderators Share Posted July 11, 2021 Без проблем. 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