Jump to content

Rendering problem


Recommended Posts

Hello, I made an AFK script, which is checks if the player is afk or not. But the image rendering is not working. It should draw an image upper the player's head if he is afk. Here's the rendering part:

function renderAfk() 
local x, y, z = getElementPosition(getLocalPlayer()) 
    if (isElement(value)) then 
        if getElementType(value) == "player" then 
            local px, py, pz = getPedBonePosition(value, 6) 
         
            local dist = getDistanceBetweenPoints3D(x, y, z, px, py, pz) 
            local lx, ly, lz = getCameraMatrix() 
            local vehicle = getPedOccupiedVehicle(value) 
            local collision, cx, cy, cz, element = processLineOfSight(lx, ly, lz, px, py, pz+1, true, true, true, true, false, false, true, false, vehicle) 
         
            if not (collision) then 
                local screenX, screenY = getScreenFromWorldPosition(px, py, pz+0.5) 
             
                if (screenX and screenY) then 
                    dist = dist / 5 
                     
                    if (dist<1) then dist = 1 end 
                    if (dist>4 and reconx) then dist = 4 end 
                 
                    local offset = 70 / dist 
     
                    local afk = getElementData(getLocalPlayer(),"afk") 
                    if afk then 
                        dxDrawImage(screenX, screenY, 100 / dist, 85 / dist, "afk.png") 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientRender", getRootElement(), renderAfk) 

If someone could help, please help me!

Link to comment
Where's "value" defined? also, you want to draw it on everyone's head if they are AFK? because this would only work for the local player.

Yes, I want to draw it on everyone's head who is away from keyboard. And what do you mean in value? You mean where is this element data defined?

local afk = getElementData(getLocalPlayer(),"afk") 

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