Jump to content

thisdp

Scripting Moderators
  • Posts

    535
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by thisdp

  1. I found out why your code went wrong. The table "cars" is not split into BMW and VAZ while the grid list is. Here is the correct code: DGS = exports.dgs addEventHandler("onClientResourceStart", resourceRoot, function() createBlip(2827.34, 1290.94, 10.76, 55, 2, 255, 0, 0, 255, 0, 250) carMarker = createMarker(2827.34, 1290.94, 9.6, "cylinder", 2.0, 0, 0, 255, 155) end ) carGUI = {} function markerTrigger(hitPlayer) if source == carMarker then showCursor(true) carGUI.win = DGS:dgsDxCreateWindow(0.75, 0.35, 0.25, 0.5, "Автомагазин", true) carGUI.window = DGS:dgsDxCreateTabPanel(0, 0, 1, 1, true, carGUI.win) carGUI.tab1 = DGS:dgsDxCreateTab("BMW", carGUI.window) carGUI.grid1 = DGS:dgsDxCreateGridList(0, 0, 1, 1, true, carGUI.tab1) carGUI.grid1Name = DGS:dgsDxGridListAddColumn(carGUI.grid1, "Название", 0.3) carGUI.grid1Price = DGS:dgsDxGridListAddColumn(carGUI.grid1, "Цена", 0.1) DGS:dgsDxGUISetProperty(carGUI.grid1,"Mark","BMW") carGUI.tab2 = DGS:dgsDxCreateTab("VAZ", carGUI.window) carGUI.grid2 = DGS:dgsDxCreateGridList(0, 0, 1, 1, true, carGUI.tab2) carGUI.grid2Name = DGS:dgsDxGridListAddColumn(carGUI.grid2, "Название", 0.3) carGUI.grid2Price = DGS:dgsDxGridListAddColumn(carGUI.grid2, "Цена", 0.1) DGS:dgsDxGUISetProperty(carGUI.grid2,"Mark","VAZ") setCameraMatrix(2814.61, 1316.01, 10.75) --setElementDimension(localPlayer, 100) for i=1,1 do addCarsToGrids("a",100,"BMW",411) end for i=1,2 do addCarsToGrids("a",100,"VAZ",422) end end end addEventHandler("onClientMarkerHit", getRootElement(), markerTrigger) cars = {} function addCarsToGrids(name, price, mark, model) cars[mark] = cars[mark] or {} cars[mark].name = { price = tonumber(price), model = tonumber(model), name = name } if mark == "BMW" then local row = DGS:dgsDxGridListAddRow(carGUI.grid1) DGS:dgsDxGridListSetItemText(carGUI.grid1, row, carGUI.grid1Name, name) DGS:dgsDxGridListSetItemText(carGUI.grid1, row, carGUI.grid1Price, price) elseif mark == "VAZ" then local row = DGS:dgsDxGridListAddRow(carGUI.grid2) DGS:dgsDxGridListSetItemText(carGUI.grid2, row, carGUI.grid2Name, name) DGS:dgsDxGridListSetItemText(carGUI.grid2, row, carGUI.grid2Price, price) end end addEvent("getCar", true) addEventHandler("getCar", getRootElement(), addCarsToGrids) function clickTrigger(button, state) if button == "left" and state == "up" then local mark = DGS:dgsDxGUIGetProperty(source,"Mark") if mark then iprint(source) print(mark) if source == carGUI.grid1 then local selected = DGS:dgsDxGridListGetSelectedItem(carGUI.grid1) if selected ~= -1 then if carGUI.buyButton == nil then carGUI.buyButton = DGS:dgsDxCreateButton(0.3, 0.7, 0.3, 0.15, "Купить", true) end local name = DGS:dgsDxGridListGetItemText(carGUI.grid1, selected, carGUI.grid1Name) if isElement(car) and getElementType(car) == "vehicle" then destroyElement(car, false) end car = createVehicle(cars[mark].name.model, 2802.79, 1309.43, 10.89) --setElementDimension(car, 100) outputChatBox(cars[mark].name.name) outputChatBox(cars[mark].name.model) end elseif source == carGUI.grid2 then local selected = DGS:dgsDxGridListGetSelectedItem(carGUI.grid2) if selected ~= -1 then if carGUI.buyButton == nil then carGUI.buyButton = DGS:dgsDxCreateButton(0.3, 0.7, 0.3, 0.15, "Купить", true) end local name = DGS:dgsDxGridListGetItemText(carGUI.grid2, selected, carGUI.grid2Name) if isElement(car) and getElementType(car) == "vehicle" then destroyElement(car, false) end car = createVehicle(cars[mark].name.model, 2802.79, 1309.43, 10.89) outputChatBox(cars[mark].name.name) outputChatBox(cars[mark].name.model) end end end end end addEventHandler("onClientDgsDxMouseClick", getRootElement(), clickTrigger) function windowClosed() if source == carGUI.win then showCursor(false) setCameraTarget(localPlayer, localPlayer) setElementDimension(localPlayer, 0) destroyElement(carGUI.buyButton) end end addEventHandler("onClientDgsDxWindowClose", getRootElement(), windowClosed)
  2. Show Me the code. And I have fixed the tab switch just now.
  3. Thank you ! I solved this problem with the help of you ! And thank you all the same.
  4. How can i focus gui-edit with a function?
  5. I use guiEdit as input, is there any method to focus guiEdit?
  6. Make it as a child of a gui element, since child elements is always on the top of its parent.
  7. I am a afraid not. I will be appreciate it very much if some one can help me to make a dgs in-game editor. Scroll Bars are available for memo. Version -> 2.91 update your dgs with "updatedgs" See Update Log: http://angel.mtaip.cn:233/dgsUpdate
  8. Plz update to the latest version with the command "updatedgs".
  9. Current version is based on element system. This means everything created by dgs returns an element. As is known to us all, lua can't provide oop functions to elements. And this project is already on github. https://github.com/thisdp/dgs I thinks that i have already fixed it. And thanks for your supports.
  10. You are welcome and thank you for your help and support.
  11. Hey bro. I fulfilled what I have promised, and you? dgs-dxmemo is released for testing without scrollbar which will be added soon. See update log: http://angel.mtaip.cn:233/dgsUpdate/
  12. You can use a dx lib instead of MTA's gui. So that you don't need to worry about it.
  13. OK.I won't add it as a type of dgs. Instead I will provide an alternative interface.
  14. Just refer to CLEO. If you want to create a vehicle, you need to check whether the model is available first, and then load model into memory. After loading model, you could create a vehicle. But in MTA you don't need to load model when you create an object , a vehicle or a ped etc. Because this step is done when you call "create*" function such as createObject . Anyway, if you want to load external dff, txd, col, you can't skip this step. So we have engineLoad* functions which can be cleared by destroyElement to load external model into memory.
  15. By the way, mta doesn't support video and gif image without CEF. dgs-dximage can render dx-created CEF. So you just load a video and gif image into CEF and use dgsDxGUISetProperty. eg: dgsDxGUISetProperty(image,"image",CEFbrowser).
  16. destroyElement can recover most of usage of RAM and Video Momery.
  17. DGS Dx Memo is almost finished. There are still some bugs to be fixed. If there is nothing unexpected, 2.88 will be released at next weekend.
  18. Since the problem comes from dx scrollbar, DGS(a dx lib) can help him to solve the problem and give him a reference.
  19. Refer to dgs. https://forum.multitheftauto.com/topic/95964-releasethisdps
  20. Maybe fetchRemote and loadstring are your choice.
  21. local scw,sch = guiGetScreenSize() local cursorX,cursorY = getCursorPosition() local absX,absY = cursorX*scw,cursorY*sch
×
×
  • Create New...