Jump to content

Help DxDrawLine3D ?(


Recommended Posts

Posted

What should I do ? :(

j6BXVg.png
 

function DrawLaser(player)
	if getElementData(player, "laser.on") then
		local targetself = getPedTarget(player)
		if targetself and targetself == player then
			targetself = true
		else
			targetself = false
		end		
		
		if getElementData(player, "laser.aim") and IsPlayerWeaponValidForLaser(player) == true and targetself == false then
			local x,y,z = getPedWeaponMuzzlePosition(player)
			if not x then
				outputDebugString("getPedWeaponMuzzlePosition failed")
				x,y,z = getPedTargetStart(player)
			end
			local x2,y2,z2 = getPedTargetEnd(player)
			if not x2 then
				--outputDebugString("getPedTargetEnd failed")
				return
			end			
			local x3,y3,z3 = getPedTargetCollision(player)
			local r,g,b,a = GetLaserColor(player)
			if x3 then -- collision detected, draw til collision and add a dot
				dxDrawLine3D(x,y,z,x3,y3,z3, tocolor(r,g,b,a), laserWidth)
				DrawLaserDot(player, x3,y3,z3)
			else
				dxDrawLine3D(x,y,z,x2,y2,z2, tocolor(r,g,b,a), laserWidth) ----641.dize
				DestroyLaserDot(player)
			end
		else
			DestroyLaserDot(player) 
		end
	else
		DestroyLaserDot(player)
	end
end

 

Posted

I think the error is because you're using player both in your targetself variable and if statement. Try to change the if part to Something like if targetself == source. If you just use player like you did then it will do it for ALL the players targeted and it will Always hide the laser.

  • Like 1

If I helped you, make sure you click the reaction button on the right to support me!
It will grant me more visibility and will help me to help others!

If you have any kind of request or subject you would like to discuss about with me,
don't hesitate to send me a private message about it!

 

Posted
10 minutes ago, Galactix said:

Hatanın nedeni, oyuncuyu hem hedef kendiniz değişkeninde hem de ifadede kullanıyor olmanızdır. Eğer, eğer targetself == source gibi birşeyi değiştirmeyi deneyin. Eğer sadece senin gibi bir oyuncu kullanırsan, o zaman bunu TÜM oyuncular için yapacaktır ve daima lazeri gizleyecektir.

I did not understand.Do you want to add code 

Posted
function DrawLaser(player)
	if getElementData(player, "laser.on") then
		local targetself = getPedTarget(player)
		if targetself and targetself == source then
			targetself = true
		else
			targetself = false
		end		
		
		if getElementData(player, "laser.aim") and IsPlayerWeaponValidForLaser(player) == true and targetself == false then
			local x,y,z = getPedWeaponMuzzlePosition(player)
			if not x then
				outputDebugString("getPedWeaponMuzzlePosition failed")
				x,y,z = getPedTargetStart(player)
			end
			local x2,y2,z2 = getPedTargetEnd(player)
			if not x2 then
				--outputDebugString("getPedTargetEnd failed")
				return
			end			
			local x3,y3,z3 = getPedTargetCollision(player)
			local r,g,b,a = GetLaserColor(player)
			if x3 then -- collision detected, draw til collision and add a dot
				dxDrawLine3D(x,y,z,x3,y3,z3, tocolor(r,g,b,a), laserWidth)
				DrawLaserDot(player, x3,y3,z3)
			else
				dxDrawLine3D(x,y,z,x2,y2,z2, tocolor(r,g,b,a), laserWidth) ----641.dize
				DestroyLaserDot(player)
			end
		else
			DestroyLaserDot(player) 
		end
	else
		DestroyLaserDot(player)
	end

 

  • Like 1

If I helped you, make sure you click the reaction button on the right to support me!
It will grant me more visibility and will help me to help others!

If you have any kind of request or subject you would like to discuss about with me,
don't hesitate to send me a private message about it!

 

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