DarkByte Posted September 25, 2015 Author Share Posted September 25, 2015 One last thing. When laser and image is aiming on a vehicle or a enemy to be red. Can you help me? Link to comment
Moderators IIYAMA Posted September 25, 2015 Moderators Share Posted September 25, 2015 Try this: local imageLocation = "image.png" local imageSizeX,imageSizeY = 100,100 local extendLine = function ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end local texture = dxCreateTexture(imageLocation,"dxt5") or imageLocation -- createTexture + fallback local renderTankLine = function () local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c","world" ) local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a","world" ) if x and x1 then local endX,endY,endZ = extendLine(x1,y1,z1,x,y,z,10000) local hit,endX2,endY2,endZ2,hitElement = processLineOfSight ( x,y,z,endX,endY,endZ, true, -- checkBuildings true, -- checkVehicles true, -- checkPlayers true, -- checkObjects true, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff theVeh -- ignoredElement ) local laserColor = tocolor(0,255,0,255) if hit then endX,endY,endZ = endX2,endY2,endZ2 if hitElement then local elementType = getElementType(hitElement) if elementType == "vehicle" or elementType == "ped" then laserColor = tocolor(255,0,0,255) end end end local imageCenterX,imageCenterY = getScreenFromWorldPosition (endX,endY,endZ) if imageCenterX and imageCenterY then dxDrawImage(imageCenterX-imageSizeX/2,imageCenterY-imageSizeY/2,imageSizeX,imageSizeY,texture) end dxDrawLine3D (x,y,z,endX,endY,endZ,laserColor,10) end end end addEventHandler("onClientRender",root,renderTankLine) Link to comment
DarkByte Posted September 25, 2015 Author Share Posted September 25, 2015 Yea its workin', but when player is aiming in his team mate laser turns in red but i don't need that Link to comment
Moderators IIYAMA Posted September 25, 2015 Moderators Share Posted September 25, 2015 That is not so hard, you can do that by yourself. getPlayerTeam 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