Jump to content

Recommended Posts

  • Scripting Moderators
17 hours ago, said:

Good work, but i've two points,

- Upload this project on github

- Support OOP

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

21 hours ago, Master_MTA said:

soo good and so easy to use but u have small mistake in grid list the scrollbar not working

line 443 at client.lua

any way i fixed it 

download link:https://up.top4top.net/downloadf-67100qlm1-zip.html

I thinks that i have already fixed it.

 

And thanks for your supports.

Edited by thisdp
Link to comment
  • Scripting Moderators
3 hours ago, Master_MTA said:

np pro 

and also u have small mistake with window close btn when u use it with marker do u wanna me fix it or u will fix it?

Are u using github version?

Link to comment
  • Scripting Moderators
9 hours ago, arciCZ said:

Is there ingame editor for that ?

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

 

Link to comment

Hello,

How do you make the grid stacked on top each other?

Spoiler

PmExU5C.jpg

I try to make it, but it's really pain because it's not like bootstrap/html xD
I have been make it, but its hard to implement it into my another scripts

So, i just wonder how is your code or at least give me a logic how to make it.

I'm sorry if it's OOT, and i hope you understand my english. 9_9

  • Like 1
Link to comment
  • Scripting Moderators
2 hours ago, anchor said:

Hello,

How do you make the grid stacked on top each other?

  Hide contents

PmExU5C.jpg

I try to make it, but it's really pain because it's not like bootstrap/html xD
I have been make it, but its hard to implement it into my another scripts

So, i just wonder how is your code or at least give me a logic how to make it.

I'm sorry if it's OOT, and i hope you understand my english. 9_9

Make it as a child of a gui element, since child elements is always on the top of its parent.

Edited by thisdp
Link to comment
  • Scripting Moderators
21 hours ago, Taka said:

Can not write to the edit in the second tab, if the first tab has a edit in the same place

I use guiEdit as input, is there any method to focus guiEdit?

Link to comment
  • Scripting Moderators
6 minutes ago, Taka said:

Another problem with tab panel. If i create tab panel with 2 tabs and inside them gridlist then if I click on an row in gridlist in tab 1, DGS considers that I clicked on the row in the second tab.

Show Me the code. And I have fixed the tab switch just now.

Link to comment
1 minute ago, thisdp said:

Show Me the code. And I have fixed the tab switch just now.

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)
		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)
		setCameraMatrix(2814.61, 1316.01, 10.75)
		--setElementDimension(localPlayer, 100)
		triggerServerEvent("onClientOpenCarShop", localPlayer)
	end
end
addEventHandler("onClientMarkerHit", getRootElement(), markerTrigger)

cars = {}

function addCarsToGrids(name, price, mark, model)
	cars.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)
	outputChatBox(source)
	if button == "left" and state == "up" then
		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 getElementType(car) == "vehicle" then
					blowVehicle(car, false)
				end
				car = createVehicle(cars.name.model, 2802.79, 1309.43, 10.89)
				--setElementDimension(car, 100)
				outputChatBox(cars.name.name)
				outputChatBox(cars.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 getElementType(car) == "vehicle" then
					blowVehicle(car, false)
				end
				car = createVehicle(cars.name.model, 2802.79, 1309.43, 10.89)
				outputChatBox(cars.name.name)
				outputChatBox(cars.name.model)
			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)

 

Link to comment
  • Scripting Moderators
13 minutes ago, Taka said:

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)
		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)
		setCameraMatrix(2814.61, 1316.01, 10.75)
		--setElementDimension(localPlayer, 100)
		triggerServerEvent("onClientOpenCarShop", localPlayer)
	end
end
addEventHandler("onClientMarkerHit", getRootElement(), markerTrigger)

cars = {}

function addCarsToGrids(name, price, mark, model)
	cars.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)
	outputChatBox(source)
	if button == "left" and state == "up" then
		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 getElementType(car) == "vehicle" then
					blowVehicle(car, false)
				end
				car = createVehicle(cars.name.model, 2802.79, 1309.43, 10.89)
				--setElementDimension(car, 100)
				outputChatBox(cars.name.name)
				outputChatBox(cars.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 getElementType(car) == "vehicle" then
					blowVehicle(car, false)
				end
				car = createVehicle(cars.name.model, 2802.79, 1309.43, 10.89)
				outputChatBox(cars.name.name)
				outputChatBox(cars.name.model)
			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)

 

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)

 

  • Thanks 1
Link to comment
  • Scripting Moderators
On 2017/11/8 at 23:59, Taka said:

Can not write to the edit in the second tab, if the first tab has a edit in the same place

Update dgs, and you can switch the edit with "tab".

  • Like 1
  • Thanks 1
Link to comment

dgsDxGUIBringToFront dont work with dgsDxCreateEdit.
If I try to do:

dgsDxGUIBringToFront (EditBox, 'left')
dgsDxEditSetCaretPosition (EditBox, 1)


The cursor simply flashes and I can not start writing without clicking the mouse on the dgsDxCreateEdit.

Edited by Lowner
Link to comment
  • Scripting Moderators
11 hours ago, Lowner said:

dgsDxGUIBringToFront dont work with dgsDxCreateEdit.
If I try to do:


dgsDxGUIBringToFront (EditBox, 'left')
dgsDxEditSetCaretPosition (EditBox, 1)


The cursor simply flashes and I can not start writing without clicking the mouse on the dgsDxCreateEdit.

I will confirm it at this weekend.If it really exists I will fix it. And thanks for your report.

Edited by thisdp
Link to comment
On 11/10/2017 at 23:06, DABL said:

@thisdp , can you make like this ?

demo.gif

function dxDrawCircle( posX, posY, radius, width, angleAmount, startAngle, stopAngle, color, postGUI )
	if ( type( posX ) ~= "number" ) or ( type( posY ) ~= "number" ) then
		return false
	end
	
	local function clamp( val, lower, upper )
		if ( lower > upper ) then lower, upper = upper, lower end
		return math.max( lower, math.min( upper, val ) )
	end
	
	radius = type( radius ) == "number" and radius or 50
	width = type( width ) == "number" and width or 5
	angleAmount = type( angleAmount ) == "number" and angleAmount or 1
	startAngle = clamp( type( startAngle ) == "number" and startAngle or 0, 0, 360 )
	stopAngle = clamp( type( stopAngle ) == "number" and stopAngle or 360, 0, 360 )
	color = color or tocolor( 255, 255, 255, 200 )
	postGUI = type( postGUI ) == "boolean" and postGUI or false
	
	if ( stopAngle < startAngle ) then
		local tempAngle = stopAngle
		stopAngle = startAngle
		startAngle = tempAngle
	end
	
	for i = startAngle, stopAngle, angleAmount do
		local startX = math.cos( math.rad( i ) ) * ( radius - width )
		local startY = math.sin( math.rad( i ) ) * ( radius - width )
		local endX = math.cos( math.rad( i ) ) * ( radius + width )
		local endY = math.sin( math.rad( i ) ) * ( radius + width )
	
		dxDrawLine( startX + posX, startY + posY, endX + posX, endY + posY, color, width, postGUI )
	end
	
	return true
end
local screenWidth, screenHeight = guiGetScreenSize( )
local screenW, screenH = guiGetScreenSize( )
local count = 0

addEventHandler( "onClientRender", root,
	function( )
		if ( count < 360 ) then
			count = count + 5
		end
		dxDrawText( math.ceil(100*(count/360)).."%", (screenW - 184) / 2, (screenH - 62) / 2, ((screenW - 184) / 2) + 184, ( (screenH - 62) / 2) + 62, tocolor(0, 0, 0, 200), 1.00, "sans", "center", "center", false, false, false, false, false)
		dxDrawCircle( screenWidth / 2, screenHeight / 2 , 68, 4, nil, nil, 360, tocolor ( 1, 186, 172, 200 ) )
		dxDrawCircle( screenWidth / 2, screenHeight / 2, 60, 4, 1, 0, count, tocolor ( 104, 253, 240, 150 ) )
	end
)

 

  • Thanks 1
Link to comment
  • Scripting Moderators
5 hours ago, iMr.WiFi..! said:

function dxDrawCircle( posX, posY, radius, width, angleAmount, startAngle, stopAngle, color, postGUI )
	if ( type( posX ) ~= "number" ) or ( type( posY ) ~= "number" ) then
		return false
	end
	
	local function clamp( val, lower, upper )
		if ( lower > upper ) then lower, upper = upper, lower end
		return math.max( lower, math.min( upper, val ) )
	end
	
	radius = type( radius ) == "number" and radius or 50
	width = type( width ) == "number" and width or 5
	angleAmount = type( angleAmount ) == "number" and angleAmount or 1
	startAngle = clamp( type( startAngle ) == "number" and startAngle or 0, 0, 360 )
	stopAngle = clamp( type( stopAngle ) == "number" and stopAngle or 360, 0, 360 )
	color = color or tocolor( 255, 255, 255, 200 )
	postGUI = type( postGUI ) == "boolean" and postGUI or false
	
	if ( stopAngle < startAngle ) then
		local tempAngle = stopAngle
		stopAngle = startAngle
		startAngle = tempAngle
	end
	
	for i = startAngle, stopAngle, angleAmount do
		local startX = math.cos( math.rad( i ) ) * ( radius - width )
		local startY = math.sin( math.rad( i ) ) * ( radius - width )
		local endX = math.cos( math.rad( i ) ) * ( radius + width )
		local endY = math.sin( math.rad( i ) ) * ( radius + width )
	
		dxDrawLine( startX + posX, startY + posY, endX + posX, endY + posY, color, width, postGUI )
	end
	
	return true
end
local screenWidth, screenHeight = guiGetScreenSize( )
local screenW, screenH = guiGetScreenSize( )
local count = 0

addEventHandler( "onClientRender", root,
	function( )
		if ( count < 360 ) then
			count = count + 5
		end
		dxDrawText( math.ceil(100*(count/360)).."%", (screenW - 184) / 2, (screenH - 62) / 2, ((screenW - 184) / 2) + 184, ( (screenH - 62) / 2) + 62, tocolor(0, 0, 0, 200), 1.00, "sans", "center", "center", false, false, false, false, false)
		dxDrawCircle( screenWidth / 2, screenHeight / 2 , 68, 4, nil, nil, 360, tocolor ( 1, 186, 172, 200 ) )
		dxDrawCircle( screenWidth / 2, screenHeight / 2, 60, 4, 1, 0, count, tocolor ( 104, 253, 240, 150 ) )
	end
)

 

This has low performance. We will use shader instead.

Edited by thisdp
Link to comment

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