Jump to content

[Help] dxDrawText


Recommended Posts

Don't know if it will work, couse I didn't test it, but...

addEventHandler( "onClientRender", root, 
    function( ) 
        local peds = getElementsByType("ped") 
        if (#peds > 0) then 
            for _,ped in ipairs(peds) do 
                if (getElementData(ped, "robberped")) then 
                    local pX,pY,pZ = getElementPosition(ped) --ped's position 
                    local tX,tY,tZ = pX,pY,pZ+1 --text's position 
                    local x,y,z = getElementPosition(localPlayer) --player's position 
                    local maxDistance = 30 
                    local distance = getDistanceBetweenPoints3D(x, y, z, tX, tY, tZ) 
                    if (distance <= maxDistance) then 
                        local wX, wY = getScreenFromWorldPosition(tX, tY, tZ) 
                        if (wX and wY) then 
                            dxDrawText("Robber Job", wX + 2, wY + 2, _, _, tocolor(0, 0, 0, 200), 2, "arial", "center", "center") 
                            dxDrawText("Robber Job", wX, wY, _, _, tocolor(0, 255, 0, 200), 2, "arial", "center", "center") 
                        end 
                    end 
                end 
            end 
        end 
    end 
) 

And serverside

function robberPed () 
    local ped = createPed ( 19, 2054.4609375, -1760.5224609375, 13.546875 ) 
    setElementData(ped, "robberped", true) 
    setElementFrozen ( ped, true ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, robberPed ) 

Link to comment
    addEventHandler( "onClientRender", root, 
        function( ) 
            local peds = getElementsByType("ped") 
            if (#peds > 0) then 
                local x,y,z = getElementPosition(localPlayer) 
                for k,ped in ipairs(peds) do 
                    if (getElementData(ped, "robberped")) then 
                        local pX,pY,pZ = getElementPosition(ped) --ped's position 
                        local tX,tY,tZ = pX,pY,pZ+1 --text's position 
                        local maxDistance = 30 
                        local distance = getDistanceBetweenPoints3D(x, y, z, tX, tY, tZ) 
                        if (distance <= maxDistance) then 
                            local wX, wY = getScreenFromWorldPosition(tX, tY, tZ) 
                            if (wX and wY) then 
                                dxDrawText("Robber Job", wX + 2, wY + 2, _, _, tocolor(0, 0, 0, 200), 2, "arial", "center", "center") 
                                dxDrawText("Robber Job", wX, wY, _, _, tocolor(0, 255, 0, 200), 2, "arial", "center", "center") 
                            end 
                        end 
                    end 
                end 
            end 
        end 
    ) 

It works.

Link to comment

Copy again. I tested it, and It works.

    addEventHandler( "onClientRender", root, 
        function( ) 
            local peds = getElementsByType("ped") 
            if (#peds > 0) then 
                local x,y,z = getElementPosition(localPlayer) 
                for k,ped in ipairs(peds) do 
                    if (getElementData(ped, "robberped")) then 
                        local pX,pY,pZ = getElementPosition(ped) --ped's position 
                        local tX,tY,tZ = pX,pY,pZ+1 --text's position 
                        local maxDistance = 30 
                        local distance = getDistanceBetweenPoints3D(x, y, z, tX, tY, tZ) 
                        if (distance <= maxDistance) then 
                            local wX, wY = getScreenFromWorldPosition(tX, tY, tZ) 
                            if (wX and wY) then 
                                dxDrawText("Robber Job", wX + 2, wY + 2, _, _, tocolor(0, 0, 0, 200), 2, "arial", "center", "center") 
                                dxDrawText("Robber Job", wX, wY, _, _, tocolor(0, 255, 0, 200), 2, "arial", "center", "center") 
                            end 
                        end 
                    end 
                end 
            end 
        end 
    ) 

Link to comment
Copy again. I tested it, and It works.
    addEventHandler( "onClientRender", root, 
        function( ) 
            local peds = getElementsByType("ped") 
            if (#peds > 0) then 
                local x,y,z = getElementPosition(localPlayer) 
                for k,ped in ipairs(peds) do 
                    if (getElementData(ped, "robberped")) then 
                        local pX,pY,pZ = getElementPosition(ped) --ped's position 
                        local tX,tY,tZ = pX,pY,pZ+1 --text's position 
                        local maxDistance = 30 
                        local distance = getDistanceBetweenPoints3D(x, y, z, tX, tY, tZ) 
                        if (distance <= maxDistance) then 
                            local wX, wY = getScreenFromWorldPosition(tX, tY, tZ) 
                            if (wX and wY) then 
                                dxDrawText("Robber Job", wX + 2, wY + 2, _, _, tocolor(0, 0, 0, 200), 2, "arial", "center", "center") 
                                dxDrawText("Robber Job", wX, wY, _, _, tocolor(0, 255, 0, 200), 2, "arial", "center", "center") 
                            end 
                        end 
                    end 
                end 
            end 
        end 
    ) 

oh sorry my bad, worked like a charm, Thanks bro

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