Jump to content

Image World


Sticmy

Recommended Posts

Guys, I need help when it comes to putting an image on the world as I did, I don't like it

In this image as well as it is placed in that position when you move away you see it the same, without enlarging it or anything like that it is totally static
 

1omJO1c.png

Here is another image at the time when I walk away it gets bigger I did it in 2 ways but in those 2 ways I can't find a way to do it as I want it to be totally static even when I walk away at 500 meters
 

fzfFQY4.png


Code:
 

local TextureFile = nil
local ImagesTable = {
{1834.3446044922, -2398.0639648438, 13.5546875, "x.png"},
}

addEventHandler("onClientResourceStart", resourceRoot, function()
	for _, texture in ipairs(ImagesTable) do
		TextureFile = DxTexture(texture[4])
	end
end)
addEventHandler("onClientRender", getRootElement(), function()
	local pos = Vector3(localPlayer.position)
	for _, v in ipairs(ImagesTable) do
		local dist = math.sqrt( ( pos.x - v[1] ) ^ 2 + ( pos.y - v[2] ) ^ 2 + ( pos.z - v[3] ) ^ 2 )
		if dist >= 0 and dist <= 900 then
			if isLineOfSightClear( pos.x, pos.y, pos.z, v[1], v[2], v[3], false, false, false, false, false, false, false,localPlayer ) then
				local x, y = getScreenFromWorldPosition( v[1], v[2], v[3])
				if x and y then
					print(x, y)
					dxDrawImage(x-80, y-120, 120, 120, TextureFile, 0, 0, 0, tocolor(255, 255, 255, 255))
				end
			end
		end
	end
end)
-- destroyTexture
addEventHandler("onClientResourceStop", resourceRoot, function()
	if isElement(TextureFile) then
		TextureFile:destroy()
		TextureFile = nil;
	end
end)

--Another way I tried but couldn't
--[[
addEventHandler("onClientRender", getRootElement(), function()
	local pos = Vector3(localPlayer.position)
	local x, y, z = getCameraTarget()
	for i, v in ipairs(ImagesTable) do
		local distance = getDistanceBetweenPoints3D(pos.x, pos.y, pos.z, v[1], v[2], v[3])
		if distance >= 0 and distance <= 200 then
			dxDrawMaterialLine3D(v[1], v[2], v[3] + 1, v[1], v[2], v[3], TextureFile, 1, tocolor( 255, 255, 255, 255 ))
		end
	end
end)
]]

 

Link to comment
1 minute ago, yani said:

try lowering if dist >= 0 and dist <= 900 to a value you like

There it is already look at the code, the problem is not that, what I want to make the image is static so it moves away or not simply static and does not enlarge or anything like that when moving away from the image obviously will take the limit of the distance to be seen.

Link to comment
Just now, Sticmy said:

There it is already look at the code, the problem is not that, what I want to make the image is static so it moves away or not simply static and does not enlarge or anything like that when moving away from the image obviously will take the limit of the distance to be seen.

then you wouldn't have to link the element position but replace it with simple image size, I don't really have an idea but I am trying to help

Link to comment
12 minutes ago, yani said:

then you wouldn't have to link the element position but replace it with simple image size, I don't really have an idea but I am trying to help

I also have no idea how I could achieve it, I just have to wait for another one to help me, also thanks bro

  • Like 1
Link to comment

The "Chat bubble" scripts on MTA Resources have a function that resizes them according to distance, you could try and rip it from them.
https://community.multitheftauto.com/index.php?p=resources&s=details&id=7254
https://community.multitheftauto.com/index.php?p=resources&s=details&id=14295
https://community.multitheftauto.com/index.php?p=resources&s=details&id=12008

You could also use this if you really wanted too.

 

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