Jump to content

مساعده dxDrawLine3D


iiv03

Recommended Posts

هلا السلام عليكم

استخدمت dxDrawLine3D عشان اسوي مربع مثل ب صوره حقتي

بس ابغى شيئ واحد كيف اخلي لما الاعب يخرج من المربع ب الخط ثلاثي

لو خرج المنطقه يجي نص؟

function makeLineAppear()
	firstMarker = createMarker ( -224, 125,4, "cylinder",1,255,255,255,255 ) --marker1
	twoMarker = createMarker ( -200, 125,4, "cylinder",1,255,0,0,255 )--marker2
	threeMarker = createMarker ( -200, 157,6, "cylinder",1,0,255,0,255 )--marker3
	fourMarker = createMarker ( -224, 157,6, "cylinder",1,0,0,255,255 )--marker4
	addEventHandler("onClientRender", root, createLine)
outputChatBox("it's done")
end
function createLine ( )
	x1, y1, z1 = getElementPosition ( firstMarker )
	x2, y2, z2 = getElementPosition ( twoMarker ) 
	x3, y3, z3 = getElementPosition ( threeMarker ) 
	x4, y4, z4 = getElementPosition ( fourMarker ) 
	dxDrawLine3D ( x1, y1, z1, x2, y2, z2, tocolor ( 0, 255, 0, 230 ), 2) -- Marker 1 connected with marker 2
	dxDrawLine3D ( x2, y2, z2, x3, y3, z3, tocolor ( 0, 255, 0, 230 ), 2) -- Marker 2 connected with marker 3
	dxDrawLine3D ( x3, y3, z3, x4, y4, z4, tocolor ( 0, 255, 0, 230 ), 2) -- Marker 3 connected with marker 4
	dxDrawLine3D ( x4, y4, z4, x1, y1, z1, tocolor ( 0, 255, 0, 230 ), 2) -- Marker 4 connected with marker 1
end
addCommandHandler("work", makeLineAppear)

0p3x43u4kxhx.pngم

 

محاولتي ويجي تكرار

function makeLineAppear()
	firstMarker = createMarker ( -224, 125,4, "cylinder",1,255,255,255,255 )
	twoMarker = createMarker ( -200, 125,4, "cylinder",1,255,0,0,255 )
	threeMarker = createMarker ( -200, 157,6, "cylinder",1,0,255,0,255 )
	fourMarker = createMarker ( -224, 157,6, "cylinder",1,0,0,255,255 )
	addEventHandler("onClientRender", root, createLine)
outputChatBox("work")
end
function createLine ( )
	x1, y1, z1 = getElementPosition ( firstMarker )
	x2, y2, z2 = getElementPosition ( twoMarker ) 
	x3, y3, z3 = getElementPosition ( threeMarker ) 
	x4, y4, z4 = getElementPosition ( fourMarker ) 
	dxDrawLine3D ( x1, y1, z1, x2, y2, z2, tocolor ( 0, 255, 0, 230 ), 2) -- Create 3D Line between Marker1 and local player.
	dxDrawLine3D ( x2, y2, z2, x3, y3, z3, tocolor ( 0, 255, 0, 230 ), 2) -- Create 3D Line between Marker2 and local player.
	dxDrawLine3D ( x3, y3, z3, x4, y4, z4, tocolor ( 0, 255, 0, 230 ), 2) -- Create 3D Line between Marker2 and local player.
	dxDrawLine3D ( x4, y4, z4, x1, y1, z1, tocolor ( 0, 255, 0, 230 ), 2) -- Create 3D Line between Marker2 and local player.
	local notmarker = (x1 and y1 and z1)
	if not notmarker then
	--outputChatBox("you leave")
	else
	outputChatBox("you leave")
	end
end
addCommandHandler("work", makeLineAppear)

 

Edited by xFabel
Link to comment
local arena = { };

function arena.create ( )
	arena.marker = { };
	arena.marker[1] = createMarker ( -224, 125, 4, "cylinder", 1, 255, 255, 255, 255 )
	arena.marker[2] = createMarker ( -200, 125, 4, "cylinder", 1, 255, 0, 0, 255 )
	arena.marker[3] = createMarker ( -200, 157, 6, "cylinder", 1, 0, 255, 0, 255 )
	arena.marker[4] = createMarker ( -224, 157, 6, "cylinder", 1, 0, 0, 255, 255 )
	arena.attachMarker ( )
end
addCommandHandler ( "work", arena.create )

function arena.leave ( player )
	if player == localPlayer then
		outputChatBox ( "You have left the area" )
	end
end

function arena.borders ( )
	if not arena.run then return end
	for i, v in ipairs ( arena.attach ) do
		local x1, y1, z1 = getElementPosition ( v.fromMarker )
		local x2, y2, z2 = getElementPosition ( v.toMarker )
		dxDrawLine3D ( x1, y1, z1, x2, y2, z2, tocolor ( 0, 255, 0, 230 ), 2 )
	end
end
addEventHandler ( "onClientRender", root, arena.borders )

function arena.attachMarker ( )
	arena.attach = { };
	local fromID = 1
	while fromID <= 4 do
		local toID = ( ( fromID < 4 and fromID +1 ) or 1 )
		table.insert ( arena.attach, { fromMarker=arena.marker[fromID], toMarker=arena.marker[toID], distance=0 } )
		fromID = fromID +1
	end
	
	arena.positions ( )	
end

function arena.positions ( )
	arena.position = { };
	arena.position.marker = { };
	arena.position.center = { x = 0, y = 0, z = 0 };
	
	for i, v in ipairs ( arena.marker ) do
		arena.position.marker[i] = { };
		arena.position.marker[i].x, arena.position.marker[i].y, arena.position.marker[i].z = getElementPosition ( v )
	end
	
	local markerID = 1
	while markerID <= 4 do
		arena.position.center.x = arena.position.center.x + arena.position.marker[markerID].x
		arena.position.center.y = arena.position.center.y + arena.position.marker[markerID].y
		arena.position.center.z = arena.position.center.z + arena.position.marker[markerID].z
		markerID = markerID +1
	end
	arena.position.center.x = arena.position.center.x/4
	arena.position.center.y = arena.position.center.y/4
	arena.position.center.z = arena.position.center.z/4
	
	arena.createBorders ( )
end

function arena.createBorders ( )
	local x, y = { }, { }
	for i, v in ipairs ( arena.position.marker ) do
		table.insert ( x, v.x )
		table.insert ( y, v.y )
	end
	
	arena.borders = createColPolygon ( arena.position.center.x, arena.position.center.y, x[1], y[1], x[2], y[2], x[3], y[3], x[4], y[4] )
	addEventHandler ( "onClientColShapeLeave", arena.borders, arena.leave, false )
	
	arena.run = true
end

 

جرب ذا

ما انسى اللي ساعدني فيه 

 

بالتوفيق

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