Jump to content

Help Needed


BogdanRTB

Recommended Posts

Hello, I just maked a script and I don't know why the dx gui don't appear when I type the command

This is the code:

localPlayer = getLocalPlayer()
local myMarker = createMarker( 2286.2451171875, -5.3291015625, 25.484375, "cylinder", 2, 255, 166, 0, 255)
local x, y, z = 2249.50390625, -89.0283203125, 26.484375
local dxfont0_dca = dxCreateFont(":cache/dca.ttf", 25)
local panel = nil

function dx_draw_buycar_info()
	if ( getDistanceBetweenPoints3D ( x, y, z, getElementPosition ( localPlayer ) ) ) < 50 then
		local coords = { getScreenFromWorldPosition ( x, y, z ) }
		if coords[1] and coords[2] then
			dxDrawText("#112192Inchirieri#ffffff\nFoloseste /rentveh pentru a inchiria un vehicul", coords[1], coords[2], coords[1], coords[2], tocolor(255,255,255), 1.5, "default-bold", "center", "center", false, false, false, true, false )
		end
	end
end
addEventHandler("onClientRender", root, dx_draw_buycar_info)

function rentVeh()
	if panel == "dealership" then
		dxDrawRectangle(581, 280, 755, 476, tocolor(136, 127, 118, 230), false)
		--dxDrawText("Ialomita Transport Public - Inchiriere Vehicule", 582, 283, 1337, 331, tocolor(17, 33, 146, 230), 1.00, dxfont0_dca, "center", "center", false, false, false, false, false)
		dxDrawLine(713, 333, 1203, 333, tocolor(17, 33, 146, 230), 1, false)
		dxDrawRectangle(600, 367, 223, 276, tocolor(77, 72, 67, 254), false)
		--dxDrawImage(605, 372, 212, 265, ":poze/lucrator.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
		dxDrawRectangle(845, 367, 223, 276, tocolor(77, 72, 67, 254), false)
		dxDrawRectangle(1092, 367, 223, 276, tocolor(77, 72, 67, 254), false)
		--dxDrawImage(850, 372, 212, 265, ":poze/lucrator.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
		--dxDrawImage(1098, 372, 212, 265, ":poze/lucrator.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
		dxDrawRectangle(852, 657, 210, 50, tocolor(77, 72, 67, 254), false)
		dxDrawRectangle(607, 657, 210, 50, tocolor(77, 72, 67, 254), false)
		dxDrawRectangle(1098, 657, 210, 50, tocolor(77, 72, 67, 254), false)
		dxDrawText("Inchiriaza", 607, 658, 817, 707, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false)
		dxDrawText("Inchiriaza", 852, 658, 1062, 707, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false)
		dxDrawText("Inchiriaza", 1098, 658, 1308, 707, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false)
		dxDrawRectangle(907, 727, 108, 24, tocolor(77, 72, 67, 254), false)
		dxDrawText("Inchide", 907, 728, 1015, 751, tocolor(17, 33, 146, 230), 1.50, "default", "center", "center", false, false, false, false, false)
    end
end

function buy_vehicle()
	if ( getDistanceBetweenPoints3D ( x, y, z, getElementPosition ( localPlayer ) ) ) < 5 then
		panel = "dealership"
	end
end	
addCommandHandler("rentveh", buy_vehicle)

 

Link to comment

Thanks! If I will have any questions I will ask you :)

23 minutes ago, The_GTA said:

You're welcome!

It seems like your DX UI is not finished yet. If you have any further trouble making your script then feel free to ask me.

Do you know how I can make the dx panel to disappear when I click on a dgs rectangle because I can't find any funciton for onDXRectangleClicked or something like this

Link to comment
21 minutes ago, BogdanRTB said:

Thanks! If I will have any questions I will ask you :)

Do you know how I can make the dx panel to disappear when I click on a dgs rectangle because I can't find any funciton for onDXRectangleClicked or something like this

Have you tried the onDgsMouseClick event? I don't see why you are mentioning DGS because you have not shown any code that is using DGS.

If you have no experience in math or the layout logic in general then I recommend you to use pre-made systems like DGS. I heard of many people who use DGS and it appears to be really well documented. Otherwise, you would have to check quite some coordinates on every onClientClick event + make your own clickable regions registration.

In your code above, to hide the DX UI you can simply do...

panel = nil
Edited by The_GTA
Link to comment
3 minutes ago, BogdanRTB said:

I am not talking about DGS, I am talking about DX because I can't find any onClientClick event for it

If you are drawing rectangles on screen using dxDrawRectangle family of functions then there is no element for it. While a rectangle is visible on screen then you can check click coordinates inside of an onClientClick event handler that match the bounding box of the drawing rectangle. For each drawing rectangle you can then manually assign an on-click handler function. Most importantly, you have to do this all by hand.

Edited by The_GTA
Link to comment
7 minutes ago, BogdanRTB said:

Yeah but I don't know how to create GUIS with DGS because on the geditor resource I use for creating them I don't have DGS I have only DX and Normal GUI

It looks like you can create "Normal GUI" with your "geditor" resource and then automatically convert it to dgs using a built-in dgs tool. I think that @xLive or @thisdp could assist you fully in this regard. There even are example commands on the wiki page. Would you mind trying it out?

Edited by The_GTA
  • 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...