Jump to content

Rendering problem


Recommended Posts

Posted

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!

Your signature image is too large.

Removed

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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") 

Your signature image is too large.

Removed

Posted

Might want to consider using several events. Doing a lot of calculations and processing using onClientRender is likely to cause lag. You'll be doing all of that 30-60 times per second... :roll:

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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