Dzsozi (h03) Posted April 3, 2014 Share Posted April 3, 2014 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
Castillo Posted April 3, 2014 Share Posted April 3, 2014 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. Link to comment
Dzsozi (h03) Posted April 3, 2014 Author Share Posted April 3, 2014 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
Dealman Posted April 3, 2014 Share Posted April 3, 2014 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... Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now