Jump to content

Solved


1LoL1

Recommended Posts

Hello, i have this script why i have this error? and how i can change color of dxDrawText to yellow? Please can anyone help me?

Warnings:

WARNING: Bad argument @ 'dxDrawText' [Expected vector2 at argument2, got boolean]

WARNING: Bad argument @ 'dxDrawText' [Expected vector2 at argument2, got boolean] [DUP x264]

addEventHandler("onClientRender", getRootElement(), 
function () 
for k,veh in pairs(getElementsByType("vehicle")) do 
if isElementOnScreen(veh) then 
    local x, y, z = getElementPosition(veh) 
    local X, Y = getScreenFromWorldPosition(x,y,z) 
    local px, py, pz = getElementPosition(getLocalPlayer()) 
    local test = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
    if test < 40 then 
    dxDrawText("TEXT", X, Y)   
            end 
        end 
    end 
end) 

Edited by Guest
Link to comment
addEventHandler("onClientRender", getRootElement(), 
function () 
    for k,veh in pairs(getElementsByType("vehicle")) do 
        if isElementOnScreen(veh) then 
            local x, y, z = getElementPosition(veh) 
            local X, Y = getScreenFromWorldPosition(x,y,z) 
            local px, py, pz = getElementPosition(getLocalPlayer()) 
            local test = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
            if test < 40 then 
                dxDrawText("TEXT",353,675,671,713,tocolor(255,255,0,255),1.10,"arial","left","top",false,false,false)   
            end 
        end 
    end 
end) 

Link to comment
addEventHandler("onClientRender", getRootElement(), 
function () 
    for k,veh in pairs(getElementsByType("vehicle")) do 
        if isElementOnScreen(veh) then 
            local x, y, z = getElementPosition(veh) 
            local X, Y = getScreenFromWorldPosition(x,y,z) 
            local px, py, pz = getElementPosition(getLocalPlayer()) 
            local test = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
            if test < 40 then 
                dxDrawText("TEXT",353,675,671,713,tocolor(255,255,0,255),1.10,"arial","left","top",false,false,false)   
            end 
        end 
    end 
end) 

Not work i don't see "TEXT" :(

My code work normally but have 2 warning and i need change color to yellow.

Link to comment

Yeah now I got you, try that

addEventHandler("onClientRender", getRootElement(), 
function () 
    for k,veh in pairs(getElementsByType("vehicle")) do 
        if isElementOnScreen(veh) then 
            local x, y, z = getElementPosition(veh) 
            local X, Y = getScreenFromWorldPosition(x,y,z) 
            local px, py, pz = getElementPosition(getLocalPlayer()) 
            local test = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
            if test < 40 then 
             dxDrawText("TEXT", X, Y, X, Y,tocolor(255,255,0,255),1.5,"bankgothic", "center"))     
           end 
        end 
    end 
end) 

Link to comment
Yeah now I got you, try that
addEventHandler("onClientRender", getRootElement(), 
function () 
    for k,veh in pairs(getElementsByType("vehicle")) do 
        if isElementOnScreen(veh) then 
            local x, y, z = getElementPosition(veh) 
            local X, Y = getScreenFromWorldPosition(x,y,z) 
            local px, py, pz = getElementPosition(getLocalPlayer()) 
            local test = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
            if test < 40 then 
             dxDrawText("TEXT", X, Y, X, Y,tocolor(255,255,0,255),1.5,"bankgothic", "center"))     
           end 
        end 
    end 
end) 

Thanks working. But i again see warning. :(

Link to comment

Thanks working. But i again see warning. :(

Which warning? post it here

Sorry warnings*

WARNING: Bad argument @ 'dxDrawText' [Expected vector2 at argument2, got boolean]

WARNING: Bad argument @ 'dxDrawText' [Expected vector2 at argument2, got boolean] [DUP x264]

Link to comment

It should works correctly, try it and tell me the result

addEventHandler("onClientRender", getRootElement(), 
function () 
    for k,veh in pairs(getElementsByType("vehicle")) do 
        if isElementOnScreen(veh) then 
            local x, y, z = getElementPosition(veh) 
            local X, Y = getScreenFromWorldPosition(x,y,z) 
            local px, py, pz = getElementPosition(getLocalPlayer()) 
            local dist = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
            if dist < 40 then 
            if X and Y then 
               dxDrawText("TEXT", X, Y, X, Y, tocolor(255,255,0,255),1.5, "bankgothic", "center")   
            end           
            end 
        end 
    end 
end) 

Link to comment
It should works correctly, try it and tell me the result
addEventHandler("onClientRender", getRootElement(), 
function () 
    for k,veh in pairs(getElementsByType("vehicle")) do 
        if isElementOnScreen(veh) then 
            local x, y, z = getElementPosition(veh) 
            local X, Y = getScreenFromWorldPosition(x,y,z) 
            local px, py, pz = getElementPosition(getLocalPlayer()) 
            local dist = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
            if dist < 40 then 
            if X and Y then 
               dxDrawText("TEXT", X, Y, X, Y, tocolor(255,255,0,255),1.5, "bankgothic", "center")   
            end           
            end 
        end 
    end 
end) 

Thanks Working perfect!!!. :mrgreen:

Link to comment

One question. Is possible

of this:

have01.png

have02.png

to

want01.png

want02.png

?

If yes here is code:

addEventHandler("onClientRender", getRootElement(), 
     function () 
     local x = -2844.7275390625 
     local y = 1290.7978515625 
     local z = 7.1015625 
     local X, Y = getScreenFromWorldPosition(x,y,z) 
     local px, py, pz = getElementPosition(getLocalPlayer()) 
     local distance = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
     if (distance < 10) then 
     if (X and Y) then 
     dxDrawText("Mechanic", X, Y - 100, X, Y,tocolor(255,255,255,255))  
        end 
    end 
end) 

Link to comment
Yes it's possible, you've to get the object's position and apply that on your code

i tried but not work :( and this is the code. Object i have in the code in x, y, z.

Code:

addEventHandler("onClientRender", getRootElement(), 
     function () 
     local x = -2844.7275390625 
     local y = 1290.7978515625 
     local z = 7.1015625 
     local X, Y = getScreenFromWorldPosition(x,y,z) 
     local px, py, pz = getElementPosition(getLocalPlayer()) 
     local distance = getDistanceBetweenPoints3D(x,y,z,px,py,pz) 
     if (distance < 10) then 
     if (X and Y) then 
     dxDrawText("Mechanic", X-30, Y-50, _, _,tocolor(255,255,255,255), 1, "default", "left", "top", false, false, false, false, false)  
        end 
    end 
end) 

Link to comment

Try that,

addEventHandler("onClientRender", getRootElement(), 
function () 
    local x, y, z = -2844.7275390625,1290.7978515625,7.1015625 
    local mx, my, mz = getCameraMatrix() 
    local distance = getDistanceBetweenPoints3D(x,y,z,mx,my,mz) 
    local X, Y = getScreenFromWorldPosition(x,y,z+1.1,0.05) 
    if (distance < 10) then 
        if (X and Y) then 
           dxDrawText("Mechanic", X, Y, X, Y, tocolor(255,255,255,255), 1, "default", "center", "center", false, false, false, false, false) 
        end 
    end 
end 
) 

Link to comment
Try that,
addEventHandler("onClientRender", getRootElement(), 
function () 
    local x, y, z = -2844.7275390625,1290.7978515625,7.1015625 
    local mx, my, mz = getCameraMatrix() 
    local distance = getDistanceBetweenPoints3D(x,y,z,mx,my,mz) 
    local X, Y = getScreenFromWorldPosition(x,y,z+1.1,0.05) 
    if (distance < 10) then 
        if (X and Y) then 
           dxDrawText("Mechanic", X, Y, X, Y, tocolor(255,255,255,255), 1, "default", "center", "center", false, false, false, false, false) 
        end 
    end 
end 
) 

This is what i need really thanks working now perfect!!!.

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