Military Guy Posted April 10, 2020 Share Posted April 10, 2020 how to draw the corners of the target box outline? Как сделать обводку машин и игроков, когда садишься в машину? Link to comment
alexaxel705 Posted April 11, 2020 Share Posted April 11, 2020 (edited) local screenWidth, screenHeight = guiGetScreenSize() local scalex = (screenWidth/1920) local scaley = (screenHeight/1080) local PlayerBones = {1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 51, 52, 53, 54} function Target() for _, thePlayer in pairs(getElementsByType("player", root, true)) do local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0 for bones in pairs(PlayerBones) do local x,y,z = getPedBonePosition(thePlayer, PlayerBones[bones]) x,y = getScreenFromWorldPosition(x,y,z) if(x and y) then maxx = math.max(x, maxx) maxy = math.max(y, maxy) minx = math.min(x, minx) miny = math.min(y, miny) end end dxDrawLine(maxx, maxy, maxx, miny, tocolor(255,255,255,255), 2) dxDrawLine(maxx, miny, minx, miny, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx, maxy, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, maxx, maxy, tocolor(255,255,255,255), 2) end for _, theVehicle in pairs(getElementsByType("vehicle", root, true)) do local VehicleBones = getVehicleComponents(theVehicle) local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0 for bones in pairs(VehicleBones) do local x,y,z = getVehicleComponentPosition(theVehicle, bones, "world") x,y = getScreenFromWorldPosition(x,y,z) if(x and y) then maxx = math.max(x, maxx) maxy = math.max(y, maxy) minx = math.min(x, minx) miny = math.min(y, miny) end end local sizeBox = 10 dxDrawLine(maxx, maxy, maxx+sizeBox, maxy, tocolor(255,255,255,255), 2) dxDrawLine(maxx+sizeBox, maxy, maxx+sizeBox, maxy-sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(maxx, miny, maxx+sizeBox, miny, tocolor(255,255,255,255), 2) dxDrawLine(maxx+sizeBox, miny, maxx+sizeBox, miny+sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, minx+sizeBox, maxy, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, minx, maxy-sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx+sizeBox, miny, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx, miny+sizeBox, tocolor(255,255,255,255), 2) end end function VehEnt() addEventHandler("onClientRender", root, Target) end addEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt) function VehExt() removeEventHandler("onClientRender", root, Target) end addEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt) Edited April 11, 2020 by alexaxel705 Link to comment
Military Guy Posted April 11, 2020 Author Share Posted April 11, 2020 17 hours ago, alexaxel705 said: local screenWidth, screenHeight = guiGetScreenSize() local scalex = (screenWidth/1920) local scaley = (screenHeight/1080) local PlayerBones = {1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 51, 52, 53, 54} function Target() for _, thePlayer in pairs(getElementsByType("player", root, true)) do local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0 for bones in pairs(PlayerBones) do local x,y,z = getPedBonePosition(thePlayer, PlayerBones[bones]) x,y = getScreenFromWorldPosition(x,y,z) if(x and y) then maxx = math.max(x, maxx) maxy = math.max(y, maxy) minx = math.min(x, minx) miny = math.min(y, miny) end end dxDrawLine(maxx, maxy, maxx, miny, tocolor(255,255,255,255), 2) dxDrawLine(maxx, miny, minx, miny, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx, maxy, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, maxx, maxy, tocolor(255,255,255,255), 2) end for _, theVehicle in pairs(getElementsByType("vehicle", root, true)) do local VehicleBones = getVehicleComponents(theVehicle) local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0 for bones in pairs(VehicleBones) do local x,y,z = getVehicleComponentPosition(theVehicle, bones, "world") x,y = getScreenFromWorldPosition(x,y,z) if(x and y) then maxx = math.max(x, maxx) maxy = math.max(y, maxy) minx = math.min(x, minx) miny = math.min(y, miny) end end local sizeBox = 10 dxDrawLine(maxx, maxy, maxx+sizeBox, maxy, tocolor(255,255,255,255), 2) dxDrawLine(maxx+sizeBox, maxy, maxx+sizeBox, maxy-sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(maxx, miny, maxx+sizeBox, miny, tocolor(255,255,255,255), 2) dxDrawLine(maxx+sizeBox, miny, maxx+sizeBox, miny+sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, minx+sizeBox, maxy, tocolor(255,255,255,255), 2) dxDrawLine(minx, maxy, minx, maxy-sizeBox, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx+sizeBox, miny, tocolor(255,255,255,255), 2) dxDrawLine(minx, miny, minx, miny+sizeBox, tocolor(255,255,255,255), 2) end end function VehEnt() addEventHandler("onClientRender", root, Target) end addEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt) function VehExt() removeEventHandler("onClientRender", root, Target) end addEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt) А можно сделать так, что бы такой вид был только при посадке в определённую машину ?(Например сел в Инфернус и только в нём будут обводиться игроки и машины) Link to comment
alexaxel705 Posted April 12, 2020 Share Posted April 12, 2020 function VehEnt(theVehicle, seat) if(getElementModel(theVehicle) == 411) then addEventHandler("onClientRender", root, Target) end end addEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt) function VehExt(theVehicle, seat) if(getElementModel(theVehicle) == 411) then removeEventHandler("onClientRender", root, Target) end end addEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt) 1 Link to comment
Military Guy Posted April 12, 2020 Author Share Posted April 12, 2020 1 hour ago, alexaxel705 said: function VehEnt(theVehicle, seat) if(getElementModel(theVehicle) == 411) then addEventHandler("onClientRender", root, Target) endendaddEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt)function VehExt(theVehicle, seat) if(getElementModel(theVehicle) == 411) then removeEventHandler("onClientRender", root, Target) endendaddEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt) Спасибо бро! Люблю и уважаю тя 1 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