KariiiM Posted June 30, 2015 Posted June 30, 2015 You want these direct x lines show in the screen when you press a "button"? You didnt explain well what you wanted to do,so it will be easy to help after understanding your point.
-Doc- Posted June 30, 2015 Author Posted June 30, 2015 OMG Do u saw handler? when i enter hydra to show the crosshair
KariiiM Posted June 30, 2015 Posted June 30, 2015 OMG Do u saw handler? when i enter hydra to show the crosshair Ah sorry i didnt take attention try this function crosshair () if getPedOccupiedVehicle(localPlayer) then if getElementModel(getPedOccupiedVehicle(localPlayer)) == 520 then local col2 = getElementData(veh, "r.col2") local col1 = getElementData(veh, "r.col1") if not(col2) or not(col1) then return end local x, y, z = getElementPosition(col2) local x1, y1, z1 = getElementPosition(col1) z1 = z1+getElementDistanceFromCentreOfMassToBaseOfModel(veh)*2 local hit, x2, y2, z2 = processLineOfSight(x, y, z, x1, y1, z1) if not(x2) or not(y2) or not(z2) then x2, y2, z2 = x, y, z end local sx, sy = getScreenFromWorldPosition(x2, y2, z2) if not(sx) or not(sy) then return end dxDrawLine(sx, sy-12.9, sx, sy+12.9, tocolor(0, 255, 0), 2) dxDrawLine(sx-12.9, sy, sx+12.9, sy, tocolor(0, 255, 0), 2) end end end addEventHandler("onClientRender", root, crosshair)
-Doc- Posted June 30, 2015 Author Posted June 30, 2015 Rechange the script function crosshair () if getPedOccupiedVehicle(localPlayer) then if getElementModel(getPedOccupiedVehicle(localPlayer)) == 520 then --there local veh = getPedOccupiedVehicle(gMe) --there local col2 = getElementData(veh, "r.col2") --there local col1 = getElementData(veh, "r.col1") if not(col2) or not(col1) then return end local x, y, z = getElementPosition(col2) local x1, y1, z1 = getElementPosition(col1) z1 = z1+getElementDistanceFromCentreOfMassToBaseOfModel(veh)*2 local hit, x2, y2, z2 = processLineOfSight(x, y, z, x1, y1, z1) if not(x2) or not(y2) or not(z2) then x2, y2, z2 = x, y, z end local sx, sy = getScreenFromWorldPosition(x2, y2, z2) if not(sx) or not(sy) then return end dxDrawLine(sx, sy-12.9, sx, sy+12.9, tocolor(0, 255, 0), 2) dxDrawLine(sx-12.9, sy, sx+12.9, sy, tocolor(0, 255, 0), 2) end end end addEventHandler("onClientRender", root, crosshair)
KariiiM Posted June 30, 2015 Posted June 30, 2015 (edited) Your error is about getPedOccupiedVehicle ,if this didnt works inform me to edit my post function crosshair () if getPedOccupiedVehicle(localPlayer) then if getElementModel(getPedOccupiedVehicle(localPlayer)) == 520 true then --there local veh = getPedOccupiedVehicle(gMe) --there local col2 = getElementData(veh, "r.col2") --there local col1 = getElementData(veh, "r.col1") if not(col2) or not(col1) then return end local x, y, z = getElementPosition(col2) local x1, y1, z1 = getElementPosition(col1) z1 = z1+getElementDistanceFromCentreOfMassToBaseOfModel(veh)*2 local hit, x2, y2, z2 = processLineOfSight(x, y, z, x1, y1, z1) if not(x2) or not(y2) or not(z2) then x2, y2, z2 = x, y, z end local sx, sy = getScreenFromWorldPosition(x2, y2, z2) if not(sx) or not(sy) then return end dxDrawLine(sx, sy-12.9, sx, sy+12.9, tocolor(0, 255, 0), 2) dxDrawLine(sx-12.9, sy, sx+12.9, sy, tocolor(0, 255, 0), 2) end end end addEventHandler("onClientRender", root, crosshair) Edited June 30, 2015 by Guest
KariiiM Posted June 30, 2015 Posted June 30, 2015 function crosshair () local vehicle = getPedOccupiedVehicle ( thePlayer ) if vehicle == 520 then
Tomas Posted June 30, 2015 Posted June 30, 2015 addEventHandler("onClientRender", getRootElement(), function ( ) if isPedInVehicle(localPlayer) then if getElementModel( getPedOccupiedVehicle(localPlayer) ) == 520 then local veh = getPedOccupiedVehicle(localPlayer) local col2 = getElementData(veh, "r.col2") local col1 = getElementData(veh, "r.col1") if not(col2) or not(col1) then return end local x, y, z = getElementPosition(col2) local x1, y1, z1 = getElementPosition(col1) z1 = z1+getElementDistanceFromCentreOfMassToBaseOfModel(veh)*2 local hit, x2, y2, z2 = processLineOfSight(x, y, z, x1, y1, z1) if not(x2) or not(y2) or not(z2) then x2, y2, z2 = x, y, z end local sx, sy = getScreenFromWorldPosition(x2, y2, z2) if not(sx) or not(sy) then return end dxDrawLine(sx, sy-12.9, sx, sy+12.9, tocolor(0, 255, 0), 2) dxDrawLine(sx-12.9, sy, sx+12.9, sy, tocolor(0, 255, 0), 2) end end end )
Moderators IIYAMA Posted June 30, 2015 Moderators Posted June 30, 2015 Why don't you take a look of what really happens? If you don't know how your code behaves, you will have a hard time fixing it... addEventHandler("onClientRender", getRootElement(), function ( ) if isPedInVehicle(localPlayer) then if getElementModel( getPedOccupiedVehicle(localPlayer) ) == 520 then local veh = getPedOccupiedVehicle(localPlayer) local col2 = getElementData(veh, "r.col2") local col1 = getElementData(veh, "r.col1") if not isElement(col2) or not isElement(col1) then return end local x, y, z = getElementPosition(col2) local x1, y1, z1 = getElementPosition(col1) -- dxDrawLine3D(x, y, z,x1, y1, z1,tocolor(255, 0, 0)) -- debug line 1 -- z1 = z1+getElementDistanceFromCentreOfMassToBaseOfModel(veh)*2 -- dxDrawLine3D(x, y, z,x1, y1, z1,tocolor(0, 0, 255)) -- debug line 2 -- local hit, x2, y2, z2 = processLineOfSight(x, y, z, x1, y1, z1) if not(x2) or not(y2) or not(z2) then x2, y2, z2 = x, y, z end -- dxDrawLine3D( x1, y1, z1,x2, y2, z2,tocolor(0, 255, 0)) -- debug line 3 -- local sx, sy = getScreenFromWorldPosition(x2, y2, z2) if not(sx) or not(sy) then return end dxDrawLine(sx, sy-12.9, sx, sy+12.9, tocolor(0, 255, 0), 2) dxDrawLine(sx-12.9, sy, sx+12.9, sy, tocolor(0, 255, 0), 2) end end end )
-.Paradox.- Posted July 1, 2015 Posted July 1, 2015 You're asking help on a public forum made for its members, And if you want a specific person to do it for you, Contact him/them in private and not post here your topic and then ask us to leave. I'm reporting this
Moderators IIYAMA Posted July 1, 2015 Moderators Posted July 1, 2015 Blue, I just gave you code to debug your code. What is the result?
Moderators IIYAMA Posted July 1, 2015 Moderators Posted July 1, 2015 No errors nothing Stupid answer, bye.
Moderators IIYAMA Posted July 2, 2015 Moderators Posted July 2, 2015 Whats stupid there i said no errorrs, or... It is stupid, because the code I posted doesn't show any debug text, but 3D lines. It seems you didn't even looked at it, you are wasting my time.
//_Dragon Posted December 27, 2015 Posted December 27, 2015 (edited) Removed Edited December 27, 2015 by Guest
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