Jump to content

[help] showing name and distance when aiming


Recommended Posts

Hello i want to do script that when player aim, you will see player nick and distance between you and player that you aiming at ( sorry for english ) i did something like this

if playerTarget then
  local x,y,z = getElementPosition(playerTarget)
  local x,y,distance = getScreenFromWorldPosition (x,y,z+0.5)
  distance = 30
  if getElementData(playerTarget,"bandit") then
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) else
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) end
  local w = dxGetTextWidth(text,distance*0.033,"default-bold") 
  if w and x and y and text and distance then
    dxDrawText ( text.."("..(getDistanceBetweenPoints3D( x,y,z, getElementPosition ( localPlayer )))..")",x-(w/5),y,x-(w/5),y,tocolor(100, 255, 100, 200),distance*0.033,"bankgothic") end end end);

that line is the showing name and distance

dxDrawText text.."("..(getDistanceBetweenPoints3D( x,y,z, getElementPosition ( localPlayer )))..")",x-(w/5),y,x-(w/5),y,tocolor(100, 255, 100, 200),distance*0.033,"bankgothic")

but i dont know why i have so damn large output

spacer.png

Edited by LOOah
Link to comment
  • Scripting Moderators
3 hours ago, LOOah said:

Hello i want to do script that when player aim, you will see player nick and distance between you and player that you aiming at ( sorry for english ) i did something like this


if playerTarget then
  local x,y,z = getElementPosition(playerTarget)
  local x,y,distance = getScreenFromWorldPosition (x,y,z+0.5)
  distance = 30
  if getElementData(playerTarget,"bandit") then
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) else
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) end
  local w = dxGetTextWidth(text,distance*0.033,"default-bold") 
  if w and x and y and text and distance then
    dxDrawText ( text.."("..(getDistanceBetweenPoints3D( x,y,z, getElementPosition ( localPlayer )))..")",x-(w/5),y,x-(w/5),y,tocolor(100, 255, 100, 200),distance*0.033,"bankgothic") end end end);

that line is the showing name and distance


dxDrawText text.."("..(getDistanceBetweenPoints3D( x,y,z, getElementPosition ( localPlayer )))..")",x-(w/5),y,x-(w/5),y,tocolor(100, 255, 100, 200),distance*0.033,"bankgothic")

but i dont know why i have so damn large output

spacer.png

Perhaps it's your issue:

distance*0.033

It's a text scale.

Link to comment

That's because there are two variables called (x, y) 

8 hours ago, LOOah said:

and the 2nd variables only will be called here

8 hours ago, LOOah said:

dxDrawText ( text.."("..(getDistanceBetweenPoints3D( x,y,z, getElementPosition ( localPlayer )))..")",x-(w/5),y,x-(w/5),y,tocolor(100, 255, 100, 200),distance*0.033,"bankgothic")

 

Try this

if playerTarget then
  local xp,yp,zp = getElementPosition(playerTarget)
  local x,y,distance = getScreenFromWorldPosition (xp,yp,zp+0.5)
  distance = 30
  if getElementData(playerTarget,"bandit") then
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) else
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) end
  local w = dxGetTextWidth(text,distance*0.033,"default-bold") 
  if w and x and y and text and distance then
    dxDrawText ( text.."("..(getDistanceBetweenPoints3D( xp,yp,zp, getElementPosition ( localPlayer )))..")",x-(w/5),y,x-(w/5),y,tocolor(100, 255, 100, 200),distance*0.033,"bankgothic") end end end);

 

  • Thanks 1
Link to comment

 

1 hour ago, Sisqo0 said:

That's because there are two variables called (x, y) 

and the 2nd variables only will be called here

 

Try this


if playerTarget then
  local xp,yp,zp = getElementPosition(playerTarget)
  local x,y,distance = getScreenFromWorldPosition (xp,yp,zp+0.5)
  distance = 30
  if getElementData(playerTarget,"bandit") then
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) else
    text = string.gsub(getPlayerName(playerTarget), '#%x%x%x%x%x%x', '' ) end
  local w = dxGetTextWidth(text,distance*0.033,"default-bold") 
  if w and x and y and text and distance then
    dxDrawText ( text.."("..(getDistanceBetweenPoints3D( xp,yp,zp, getElementPosition ( localPlayer )))..")",x-(w/5),y,x-(w/5),y,tocolor(100, 255, 100, 200),distance*0.033,"bankgothic") end end end);

 

thanks mate

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