Jump to content

Target Contour/Обводка Машин


Recommended Posts

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)

tar.png

Edited by alexaxel705
Link to comment
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)

tar.png

А можно сделать так, что бы такой вид был только при посадке в определённую машину ?(Например сел в Инфернус и только в нём будут обводиться игроки и машины)

Link to comment
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)

 

  • Like 1
Link to comment
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)

 

Спасибо бро! Люблю и уважаю тя :D

  • Like 1
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...