Jump to content

Very annoying onClientPreRender and onClientRender issue


f8upd8

Recommended Posts

I using onClientPreRender to draw images above players like this:

--Clientside
function dxDrawImageOnElement(element,Image,distance,relX,relY,relZ,alpha,checkBuildings,checkVehicles,checkPeds,checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)
				if type(element) == "userdata" then
				local x2, y2, z2 = getElementPosition(localPlayer)
				local x, y, z = getElementPosition(element)
				if not x then
					outputChatBox("Failed.", 255, 0, 0)
				else
					outputChatBox(relX..relY..relZ, 0, 255, 0)
				end
				local distance = distance or 20
				local relX = relX or 1
				local relY = relY or 1
				local relZ = relZ or 1
				local width = width or 1
        local checkBuildings = checkBuildings or true
        local checkVehicles = checkVehicles or false
        local checkPeds = checkPeds or false
        local checkObjects = checkObjects or true
        local checkDummies = checkDummies or true
        local seeThroughStuff = seeThroughStuff or false
        local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false
        local ignoredElement = ignoredElement or nil
				if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then
					local sx, sy = getScreenFromWorldPosition(x, y, z+relZ)
					if(sx) and (sy) then
						local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
						if(distanceBetweenPoints < distance) then
							dxDrawMaterialLine3D(x+relX, y+relY, z+1+relZ-(distanceBetweenPoints/distance), x+relX, y+relY, z+relZ, Image, width-(distanceBetweenPoints/distance), tocolor(R or 255, G or 255, B or 255, alpha or 255))
						end
					end
			end
	end
	end
addEventHandler("onClientPreRender", getRootElement(), function ()
dxDrawImageOnElement(element,image,distance,relX,relY,relZ,alpha,checkBuildings,checkVehicles,checkPeds,checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)
    end)

This working well! Images is apearing.

But look at client logs:

[2017-07-24 23:12:57] WARNING: ddessentials\client.lua:3: Bad argument @ 'getElementPosition' [Expected element at argument 1, got boolean]  [DUP x215]
[2017-07-24 23:12:57] WARNING: ddessentials\client.lua:16: Bad argument @ 'isLineOfSightClear' [Expected vector3 at argument 1, got boolean]  [DUP x215]
[2017-07-24 23:12:57] WARNING: ddessentials\client.lua:3: Bad argument @ 'getElementPosition' [Expected element at argument 1, got boolean]
[2017-07-24 23:12:57] WARNING: ddessentials\client.lua:16: Bad argument @ 'isLineOfSightClear' [Expected vector3 at argument 1, got boolean]
[2017-07-24 23:13:03] WARNING: ddessentials\client.lua:3: Bad argument @ 'getElementPosition' [Expected element at argument 1, got boolean]  [DUP x215]
[2017-07-24 23:13:03] WARNING: ddessentials\client.lua:16: Bad argument @ 'isLineOfSightClear' [Expected vector3 at argument 1, got boolean]  [DUP x215]
[2017-07-24 23:13:03] WARNING: ddessentials\client.lua:3: Bad argument @ 'getElementPosition' [Expected element at argument 1, got boolean]
[2017-07-24 23:13:03] WARNING: ddessentials\client.lua:16: Bad argument @ 'isLineOfSightClear' [Expected vector3 at argument 1, got boolean]

And i really hate this. This generating continuosly and i can't read client logs anymore. How can i avoid this crap?

 

Edited by f8upd8
Link to comment

Try it :
 


function dxDrawImageOnElement(TheElement,Image,distance,height,width,R,G,B,alpha)
				local x, y, z = getElementPosition(TheElement)
				local x2, y2, z2 = getElementPosition(localPlayer)
				local distance = distance or 20
				local height = height or 1
				local width = width or 1
                                local checkBuildings = checkBuildings or true
                                local checkVehicles = checkVehicles or false
                                local checkPeds = checkPeds or false
                                local checkObjects = checkObjects or true
                                local checkDummies = checkDummies or true
                                local seeThroughStuff = seeThroughStuff or false
                                local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false
                                local ignoredElement = ignoredElement or nil
				if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then
					local sx, sy = getScreenFromWorldPosition(x, y, z+height)
					if(sx) and (sy) then
						local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
						if(distanceBetweenPoints < distance) then
							dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance), x, y, z+height, Image, width-(distanceBetweenPoints/distance), tocolor(R or 255, G or 255, B or 255, alpha or 255))
						end
					end
			end
	end


addEventHandler("onClientPreRender", getRootElement(), function ()
dxDrawImageOnElement(element,image)
end)

and sure to defined the element and image

Link to comment

 

11 hours ago, iMr.WiFi..! said:

Try it :
 


function dxDrawImageOnElement(TheElement,Image,distance,height,width,R,G,B,alpha)
				local x, y, z = getElementPosition(TheElement)
				local x2, y2, z2 = getElementPosition(localPlayer)
				local distance = distance or 20
				local height = height or 1
				local width = width or 1
                                local checkBuildings = checkBuildings or true
                                local checkVehicles = checkVehicles or false
                                local checkPeds = checkPeds or false
                                local checkObjects = checkObjects or true
                                local checkDummies = checkDummies or true
                                local seeThroughStuff = seeThroughStuff or false
                                local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false
                                local ignoredElement = ignoredElement or nil
				if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then
					local sx, sy = getScreenFromWorldPosition(x, y, z+height)
					if(sx) and (sy) then
						local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
						if(distanceBetweenPoints < distance) then
							dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance), x, y, z+height, Image, width-(distanceBetweenPoints/distance), tocolor(R or 255, G or 255, B or 255, alpha or 255))
						end
					end
			end
	end


addEventHandler("onClientPreRender", getRootElement(), function ()
dxDrawImageOnElement(element,image)
end)

and sure to defined the element and image

dxDrawImageOnElement was edited not just for lols. Reverting it to wiki state is worst thing that i can do.

7 hours ago, Jusonex said:

Filtering out bad function calls doesn't fix the problem, but only the symptoms.

Instead, you shouldn't add the onClient(Pre)Render event handler before element is not set.

It is very funny, but i even adden check "if not element outputChatBox("FAILURE", 255, 0, 0)". And i never seen "FAILURE" in the chat box.

To disable logs i adden check before isLineOfSightClear. This is only place when check works properly in this function.

Edited by f8upd8
Link to comment
  • Administrators
54 minutes ago, f8upd8 said:

*SOLVED*

Problem was more untrivial than i thought.

Would be good if you share your solution. This will help anyone who stumbles across this topic with a similar problem.

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