Jump to content

Recommended Posts

  • Scripting Moderators
6 hours ago, JeViCo said:

Hello! Could you add something like css border-radius property? It'll be awesome having rounded buttons, window, gridlist corners

This requires shader

Link to comment
  • 4 weeks later...

@thisdp Hello again) Could you help me?

function scr(new, old)
	if source == dgsGridListGetScrollBar(gridlist)[1] then
		dgsGridListSetScrollPosition(gridlist,old)
	end
end
addEventHandler("onDgsScrollBarScrollPositionChange",root,scr)

i tried to make something like cancelEvent() but dgs resource gives an error: "C stack overflow"

  • Like 1
Link to comment

Hello. I have several problems on my server with this interface. I've updated the resource already with the command (/updatedgs) or re-uploading the downloaded files from GitHub.

 

When I'm clicking a button which has an handler ("onDgsMouseClick"), executes the function twice. Has anyone this problem like me? I'd like to resolve it.

 

exports.DGS:dgsCreateButton(301, 111, 481, 40, "Register", false, login[4], tocolor(255, 255, 255,255), false, false, false, false, false,  tocolor(240, 181, 0,255),  tocolor(0, 0, 0,255),  tocolor(240, 181, 0,255))

 

Thanks!

Regards,

@edge

Edited by edge
Link to comment
  • Scripting Moderators
function scr(new, old)
	if source == dgsGridListGetScrollBar(gridlist)[1] then
		local vertical = dgsGridListGetScrollPosition(gridlist)
		if vertical ~= old then
			dgsGridListSetScrollPosition(gridlist,old)
		end
	end
end
addEventHandler("onDgsScrollBarScrollPositionChange",root,scr)

 

9 hours ago, edge said:

Hello. I have several problems on my server with this interface. I've updated the resource already with the command (/updatedgs) or re-uploading the downloaded files from GitHub.

 

When I'm clicking a button which has an handler ("onDgsMouseClick"), executes the function twice. Has anyone this problem like me? I'd like to resolve it.

 


exports.DGS:dgsCreateButton(301, 111, 481, 40, "Register", false, login[4], tocolor(255, 255, 255,255), false, false, false, false, false,  tocolor(240, 181, 0,255),  tocolor(0, 0, 0,255),  tocolor(240, 181, 0,255))

 

Thanks!

Regards,

@edge

https://wiki.multitheftauto.com/wiki/OnDgsMouseClick

read the bold text in "state" carefully

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

Also this code


f = addEventHandler("OnDgsGridListSelect",getRootElement(),chooseStickGrid)
print(f)

always returns false and of course chooseStickGrid function doesn't work. I tried to put gridlist variable instead of getRootElement() but got same result

:arcade:

and FINALLY gridlist sort "#"..number items like this and i can't understand how to fix it

RMazp7n9T6SuRTwvr3MCVQ.png

Event Name: On*** -> on***

use custom sort function

  • Thanks 1
Link to comment
21 minutes ago, thisdp said:

Event Name: On*** -> on***

oops, my fault

22 minutes ago, thisdp said:

use custom sort function

i have some difficulties with it. 

I guess i'm totally wrong here

local sortfnc = [[
	local arg = {...}
	local a = arg[1]
	local b = arg[2]
	local column = dgsElementData[self].sortColumn
	local texta,textb = a[column][1],b[column][1]
	local texta,textb = tonumber(string.gsub(texta,"%#","")),tonumber(string.gsub(textb,"%#",""))
	return texta < textb
]]

 

Link to comment
  • Scripting Moderators
23 minutes ago, JeViCo said:

oops, my fault

i have some difficulties with it. 

I guess i'm totally wrong here


local sortfnc = [[
	local arg = {...}
	local a = arg[1]
	local b = arg[2]
	local column = dgsElementData[self].sortColumn
	local texta,textb = a[column][1],b[column][1]
	local texta,textb = tonumber(string.gsub(texta,"%#","")),tonumber(string.gsub(textb,"%#",""))
	return texta < textb
]]

 

here is an example

	local sortfnc = [[
	local arg = {...}
	local a = arg[1]
	local b = arg[2]
	local column = dgsElementData[self].sortColumn
	local texta,textb = a[column][1],b[column][1]
	local texta,textb = tonumber(texta:sub(2)),tonumber(textb:sub(2))
	print(texta,textb)
	return texta < textb
	]]
	gridlist = dgsCreateGridList(300,50,600,600,false)
	dgsGridListAddColumn(gridlist,"test1",0.2)
	for i=1,50 do
		local row = dgsGridListAddRow(gridlist)
		dgsGridListSetItemText(gridlist,row,1,"#"..tostring(i))
	end
	dgsGridListSetSortEnabled(gridlist,false) --disable click sorting
	dgsGridListSetSortFunction(gridlist,sortfnc)
	dgsGridListSetSortColumn(gridlist,1)

 

5 hours ago, JeViCo said:

same

zcTHvol0RMuihj5i24a5xA.png

 

I have just released DGS 3.393

You can use dgsScrollBarSetLocked to lock the position

dgsScrollBarSetLocked(scrollbar,state)

Edited by thisdp
  • Thanks 1
Link to comment
23 minutes ago, thisdp said:

here is an example


	local sortfnc = [[
	local arg = {...}
	local a = arg[1]
	local b = arg[2]
	local column = dgsElementData[self].sortColumn
	local texta,textb = a[column][1],b[column][1]
	local texta,textb = tonumber(texta:sub(2)),tonumber(textb:sub(2))
	print(texta,textb)
	return texta < textb
	]]
	gridlist = dgsCreateGridList(300,50,600,600,false)
	dgsGridListAddColumn(gridlist,"test1",0.2)
	for i=1,50 do
		local row = dgsGridListAddRow(gridlist)
		dgsGridListSetItemText(gridlist,row,1,"#"..tostring(i))
	end
	dgsGridListSetSortEnabled(gridlist,false) --disable click sorting
	dgsGridListSetSortFunction(gridlist,sortfnc)
	dgsGridListSetSortColumn(gridlist,1)

 

click sorting confused me. Thank you

  • Like 1
Link to comment

Could you help me a little bit? (maybe not). Something wrong with my code - 3d menu always facing the wrong way

local x, y, z = getElementPosition ( localPlayer ) 
local _,_,r = getElementRotation ( localPlayer ) 
x = x - math.sin ( math.rad ( r ) ) * 2
y = y + math.cos ( math.rad ( r ) ) * 2

d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000)
w_main = dgsCreateWindow(0, 0, 0.32, 0.58, "test window", true)

6-MbOeUPTa_CXgiJpFWZ0g.png

BoqnTdadRSCFVea8-bzqrw.png

Link to comment
  • Scripting Moderators
4 hours ago, JeViCo said:

Could you help me a little bit? (maybe not). Something wrong with my code - 3d menu always facing the wrong way


local x, y, z = getElementPosition ( localPlayer ) 
local _,_,r = getElementRotation ( localPlayer ) 
x = x - math.sin ( math.rad ( r ) ) * 2
y = y + math.cos ( math.rad ( r ) ) * 2

d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000)
w_main = dgsCreateWindow(0, 0, 0.32, 0.58, "test window", true)

6-MbOeUPTa_CXgiJpFWZ0g.png

BoqnTdadRSCFVea8-bzqrw.png

I just wonder how can you draw a window on 3d interface.

set face to nil,nil,nil can give you an always facing to the camera state

Edited by thisdp
  • Thanks 1
Link to comment
7 hours ago, thisdp said:

I just wonder how can you draw a window on 3d interface.

i cut that from my code. I forgot to add dgsSetParent

7 hours ago, thisdp said:

set face to nil,nil,nil can give you an always facing to the camera state

i tried to add coordinates from getCameraMatrix and getElementPosition - same. I'll try with nil,nil,nil

  • Like 1
Link to comment
  • Scripting Moderators
9 hours ago, JeViCo said:

i cut that from my code. I forgot to add dgsSetParent

i tried to add coordinates from getCameraMatrix and getElementPosition - same. I'll try with nil,nil,nil

face to of dgs 3d interface is offset relative to the position of 3d interface

such as face to 1,0,0

the absolute position is x+1,y,z

Link to comment
44 minutes ago, thisdp said:

face to of dgs 3d interface is offset relative to the position of 3d interface

such as face to 1,0,0

the absolute position is x+1,y,z

i didn't know about that, thanks!

p.s. i've just tested those offsets and they don't work for me (at all)

addCommandHandler("ttt",function(cmd,amount)
	local x, y, z = getElementPosition ( localPlayer ) 
	local _,_,r = getElementRotation ( localPlayer ) 
	x = x - math.sin ( math.rad ( r ) ) * 2
	y = y + math.cos ( math.rad ( r ) ) * 2

	d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000,tonumber(amount),r)
	w_main = dgsCreateWindow(0, 0, 100, 100, "test window", false)
	dgsSetParent(w_main,d3)
end)

i thought i can rotate those menus using offsets and player rotation but all of them

adFwaLa7TMC3tjYMhmcNng.png

Could you add something like camera position settings then? 1. Menu always facing towards the player (dynamic world position) 2. Menu always facing towards the single point (static world position)

Edited by JeViCo
Link to comment
  • Scripting Moderators
9 hours ago, JeViCo said:

i didn't know about that, thanks!

p.s. i've just tested those offsets and they don't work for me (at all)


addCommandHandler("ttt",function(cmd,amount)
	local x, y, z = getElementPosition ( localPlayer ) 
	local _,_,r = getElementRotation ( localPlayer ) 
	x = x - math.sin ( math.rad ( r ) ) * 2
	y = y + math.cos ( math.rad ( r ) ) * 2

	d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000,tonumber(amount),r)
	w_main = dgsCreateWindow(0, 0, 100, 100, "test window", false)
	dgsSetParent(w_main,d3)
end)

i thought i can rotate those menus using offsets and player rotation but all of them

adFwaLa7TMC3tjYMhmcNng.png

Could you add something like camera position settings then? 1. Menu always facing towards the player (dynamic world position) 2. Menu always facing towards the single point (static world position)

so I told you,  set "Face To" to nil,nil,nil

https://wiki.multitheftauto.com/wiki/DgsCreate3DInterface

If you want to face to a point, use pointPosition-3dInterfacePosition

Edited by thisdp
Link to comment
12 hours ago, thisdp said:

so I told you,  set "Face To" to nil,nil,nil

addCommandHandler("ttt",function()
	local x, y, z = getElementPosition ( localPlayer ) 
	local _,_,r = getElementRotation ( localPlayer ) 
	x = x - math.sin ( math.rad ( r ) ) * 2
	y = y + math.cos ( math.rad ( r ) ) * 2

	d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000,nil,nil,nil)
	w_main = dgsCreateWindow(0, 0, 100, 100, "test window", false)
	dgsSetParent(w_main,d3)
end)

](*,)

Link to comment
1 hour ago, JeViCo said:

addCommandHandler("ttt",function()
	local x, y, z = getElementPosition ( localPlayer ) 
	local _,_,r = getElementRotation ( localPlayer ) 
	x = x - math.sin ( math.rad ( r ) ) * 2
	y = y + math.cos ( math.rad ( r ) ) * 2

	d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000,nil,nil,nil)
	w_main = dgsCreateWindow(0, 0, 100, 100, "test window", false)
	dgsSetParent(w_main,d3)
end)

](*,)

dgsSetProperty(interface,"faceTo",{faceTowardsX,faceTowardsY,faceTowardsZ})
Link to comment
18 minutes ago, Daniels69 said:

dgsSetProperty(interface,"faceTo",{faceTowardsX,faceTowardsY,faceTowardsZ})

same

addCommandHandler("ttt",function()
	local x, y, z = getElementPosition ( localPlayer )
	local px,py,pz = x,y,z
	local _,_,r = getElementRotation ( localPlayer ) 
	x = x - math.sin ( math.rad ( r ) ) * 2
	y = y + math.cos ( math.rad ( r ) ) * 2

	d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000,nil,nil,nil)
	w_main = dgsCreateWindow(0, 0, 100, 100, "test window", false)
	dgsSetParent(w_main,d3)
	dgsSetProperty(d3,"faceTo",{px,py,pz})
end)

 

Link to comment
  • Scripting Moderators
20 minutes ago, JeViCo said:

same


addCommandHandler("ttt",function()
	local x, y, z = getElementPosition ( localPlayer )
	local px,py,pz = x,y,z
	local _,_,r = getElementRotation ( localPlayer ) 
	x = x - math.sin ( math.rad ( r ) ) * 2
	y = y + math.cos ( math.rad ( r ) ) * 2

	d3 = dgsCreate3DInterface(x, y, z+1,2,2,512,512,0xFF000000,nil,nil,nil)
	w_main = dgsCreateWindow(0, 0, 100, 100, "test window", false)
	dgsSetParent(w_main,d3)
	dgsSetProperty(d3,"faceTo",{px,py,pz})
end)

 

sry, it's my fault, updatedgs

But it seems there is still a problem. I will fix it later :D

Thank you

  • Like 1
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...