Jump to content

Recommended Posts

Hello, i'm doing this post today because i need help with this. I've tried everything but i have not succeeded, i want to know how i can center this image under my feets, i mean, under the player, ¡just there! without losing that size ((( x, y, z_ground, 1, 2.5))) in the picture..

2KBpuXkRS9a9MSPYeb57gQ.png

This is the script script, i hope u can help me with this pleaaaaaase :/

local imagen = dxCreateTexture( "test.png" )
local activado = { }
local players = getElementsByType( 'player' )

function dxDrawImage3D(x,y,z,w,h,m,c,r,...) 
    local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z 
    return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white, ...) 
end 

addEventHandler( "onClientRender", root,
	function( )
		for i=1, #players do
			local p = players[i]
			if activado[ p ] == true then
				local x, y, z = getElementPosition( p )
				local z_ground = getGroundPosition( x, y, z )
                dxDrawImage3D( x, y, z_ground, 1, 2.5, imagen, tocolor( 0, 255, 230, 255 ), 0, x, y, z )
			end
		end
	end
)
		
function removeEffect( player )
	if activado[ player ] == true then
		activado[ player ] = nil
	end
end

addEvent( "vip:farvel", true )
addEventHandler( "vip:farvel", getRootElement( ),

	function( player )
		if not activado[ player ] or activado[ player ] == nil then
			activado[ player ] = true
			setTimer( removeEffect, 5000, 1, player )
		end
	end
)

Thanks, also, i hope you can read this and help me.

Link to comment
addEventHandler( "onClientRender", root,
	function( )
		for i=1, #players do
			local p = players[i]
			if activado[ p ] == true then
				local x, y, z = getElementPosition( p )
				local z_ground = getGroundPosition( x, y, z )
				getPedBonePosition ( player,3 )
                dxDrawImage3D( x, y, z_ground, 1, 2.5, imagen, tocolor( 0, 255, 230, 255 ), 0, x, y, z )
			end
		end
	end
)

something like this? :( 

Edited by Lalalu
Link to comment

 i think it's better to keep the first code
and play with x + y
 

addEventHandler( "onClientRender", root,
	function( )
		for i=1, #players do
			local p = players[i]
			if activado[ p ] == true then
				local x, y, z = getElementPosition( p )
				local z_ground = getGroundPosition( x, y, z )
                dxDrawImage3D( x+0.4, y+0.4, z_ground, 1, 2.5, imagen, tocolor( 0, 255, 230, 255 ), 0, x, y, z )
			end
		end
	end
)

try to play with it until it be under the player feet

 

Link to comment
  • Moderators
?

dxDrawImage3D( x-0.5, y-1.25, z_ground, 1, 2.5, imagen, tocolor( 0, 255, 230, 255 ), 0, x, y, z +1 )

Using not a square image is a terrible mistake, but try this.

 

 

2 hours ago, Lalalu said:

still not working x2 :|, lmao

And would you please stop that.
Saying that is means the same as: 'I am too lazy to follow instructions and I will be waiting for somebody else to do it for me'

You don't want to say that to people that are trying to help you.

  • Like 1
Link to comment

 

sorry? jesus. I didn't say it in a bad way, i said that it did not work simply and nothing else, i did not give him instructions, nor did I tell him what to do, and in fact he helped me a lot, i understood certain things, he offered to help me, i never told him to do all the work, I'm not a "scripter" or anything like that, but that doesn't mean that i'm a jerk and i let them do all the work, so.. thanks.

Link to comment
  • Moderators

@Lalalu

I know you didn't want to say that, because that would be very inhuman, but I just informed you what kind of effect it would have when a scripter says that to a scripter. You do not want people to get angry right? Then take my advice.

 

Another thing, this is the scripting section. If you post code here, everybody would expect you to be a scripter. If you aren't a scripter, then make sure to write that down at the start of the topic. If you do not write that down, people would expect you to be capable of solve small adjustments like this. So make sure that the helpers are aware of your limitations. If I knew that you were not a scripter, I wouldn't have pointed out that this matter in the first place.

 

I hope this information will help you in the future.

 


Is the image position correct now?

If not, be specific and show results(screenshots + code for example).

 

 

 

  • Like 1
Link to comment

Yes, you have reason, and yeah it's already working with your line, 1000thank you, but i think..., i mean, i want to edit some more because i want to understand a little bit more about dxDrawImage3d

Edited by Lalalu
  • Like 1
Link to comment
  • Moderators

dxDrawImage3D( x - 0.5, y - 1.25, z_ground, 1, 2.5, imagen, tocolor( 0, 255, 230, 255 ), 0, x, y, z +1 )

 

XSIZE / 2 = XOFFSET

YSIZE / 2 = YOFFSET

 

 


 

-- I am HERE on the LEFT / TOP--
-----\--/-----
------\/------

--LEFT / TOP-------------------- 

--------------------------------

--------------------------------

--------------------------------

----------------RIGHT / BOTTOM--

LEFT / TOP = player position

The size will be added in to the direction of the RIGHT / BOTTOM corner.

SIZE   > +
\/

+

 

Subtract 50% of the X Size and Y Size of the LEFT / TOP, will adjust the image position so that the image middle position is at the player position.

 

--LEFT / TOP--------------------

--------------------------------

-------I WANT TO BE HERE--------

--------------------------------

----------------RIGHT / BOTTOM--

 

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