Jump to content

DrawText não funciona


Recommended Posts

Boa noite...

Então... Eu estou tentando fazer um script para criar um texto no mapa com dxDrawText, só que está muito bugado... Eu mudo a posição e ele para de mostrar, aí eu volto ele aparece de novo... E aí ele não some depois da posição... Não estou entendendo mais nada...
Se puderem me ajudar...

client.Lua

function texto()
    local x,y,z = getElementPosition( source )
 if getDistanceBetweenPoints3D(0 , 0, 4 + 5, x, y, z) < 10 then
  local coords = {getScreenFromWorldPosition(1007.8150024414, -1993.7969970703, 13.155365943909)}
  if coords[1] and coords[2] then
   dxDrawText("teste", coords[1], coords[2], coords[1], coords[2], tocolor(0, 5, 254, 255), 4.00, "sans", "center", "center", false, false, false, false, false)
  end
 end
end
addEventHandler("onClientRender", root,texto)

 

meta.xml

<meta>
     <script src="client.Lua" type="client"/>
</meta>

 

 

* e não tem nenhum erro no console ou no debugscript...

Edited by SrPattif
Link to comment

Aqui está o erro, os três primeiros argumentos não condiz com a posição desejada do texto resultando em um não aparecimento do texto mediante a verificação de distancia

if getDistanceBetweenPoints3D(0 , 0, 4 + 5, x, y, z) < 10 then

Desta forma, deve solucionar o problema:

local pX,pY,pZ = 1007.8150024414, -1993.7969970703, 13.155365943909

function texto()
    local x,y,z = getElementPosition( source )
    if getDistanceBetweenPoints3D(pX, pY, pZ, x, y, z) < 10 then
        local coords = {getScreenFromWorldPosition(pX,pY,pZ)}
        if coords[1] and coords[2] then
            dxDrawText("teste", coords[1], coords[2], coords[1], coords[2], tocolor(0, 5, 254, 255), 4.00, "sans", "center", "center", false, false, false, false, false)
        end
    end
end
addEventHandler("onClientRender", root,texto)
  • Thanks 1
Link to comment
59 minutes ago, MainSCR said:

Aqui está o erro, os três primeiros argumentos não condiz com a posição desejada do texto resultando em um não aparecimento do texto mediante a verificação de distancia


if getDistanceBetweenPoints3D(0 , 0, 4 + 5, x, y, z) < 10 then

Desta forma, deve solucionar o problema:


local pX,pY,pZ = 1007.8150024414, -1993.7969970703, 13.155365943909

function texto()
    local x,y,z = getElementPosition( source )
    if getDistanceBetweenPoints3D(pX, pY, pZ, x, y, z) < 10 then
        local coords = {getScreenFromWorldPosition(pX,pY,pZ)}
        if coords[1] and coords[2] then
            dxDrawText("teste", coords[1], coords[2], coords[1], coords[2], tocolor(0, 5, 254, 255), 4.00, "sans", "center", "center", false, false, false, false, false)
        end
    end
end
addEventHandler("onClientRender", root,texto)



Funcionou amigo, só tive que fazer uma pequena alteração...

Para quem mais tiver esse problema, está aqui o código funcionando 100%
 

local pX,pY,pZ = 1018.9672241211, -1992.4956054688, 13.155365943909

function texto()
    local x,y,z = getElementPosition( getLocalPlayer() )
    if getDistanceBetweenPoints3D(pX, pY, pZ, x, y, z) < 10 then
        local coords = {getScreenFromWorldPosition(pX,pY,pZ)}
        if coords[1] and coords[2] then
            dxDrawText("teste", coords[1], coords[2], coords[1], coords[2], tocolor(0, 5, 254, 255), 4.00, "sans", "center", "center", false, false, false, false, false)
        end
    end
end
addEventHandler("onClientRender", root,texto)

 

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