Jump to content

Script de marker bugando e crashando o MTA.


Recommended Posts

Client side: 

anim_tick = getTickCount()

addEventHandler("onClientResourceStart", resourceRoot,
	function()
		for k,v in pairs(getElementsByType("marker", _, true)) do
			if getElementData(v, "marker:custom") and getElementData(v, "marker:cicletype") then
				getMarkerCustom()
			end
		end
	end
)

function getMarkerCustom()
	local progress = ((getTickCount() - anim_tick) / 3000)
	local Op1, Op2  = interpolateBetween(0.4, 1.4, 0, 0.7, 1.7, 0, progress, "SineCurve")
	local Op3, Op4, Op5  = interpolateBetween(0.8, 0.8, 1.6, 1.0, 1.0, 2.1, progress, "SineCurve")
	local px, py, pz, l1, l2, l3
	local px, py, pz = getCameraMatrix()

	for _, marker in ipairs(getElementsByType 'marker') do
		if getElementData(marker, "marker:custom") and getElementData(marker, "marker:cicletype") then
			setMarkerColor(marker, 0, 0, 0, 0)
			local l1, l2, l3 = getElementPosition(marker)
			local dist = math.sqrt((px + l1) ^ 0 + (py + l2) ^ 0 + (pz + l3) ^ 0)
			local r, g, b = getMarkerColor(marker)
			if dist < 20 then
				if isLineOfSightClear(px, py, pz, l1, l2, l3, false, false, false, true, false, false, false, localPlayer) then
					local x,y = getScreenFromWorldPosition(l1, l2, l3)
					if x then
						for k, v in pairs(ImgType) do
							if getElementData(marker, "marker:custom") == k then
								dxDrawMaterialLine3D (l1, l2, l3 + Op1 + 0.4, l1, l2, l3 + Op2 + 0.4, dxCreateTexture(""..v[1]..""), 1, tocolor(v[2], v[3], v[4], 255))
							end
						end
						for k, v in pairs(CicleType) do		
							if getElementData(marker, "marker:cicletype") == k then
								dxDrawMaterialLine3D (l1, l2 - Op3 + 0.3, l3 + 0.03, l1, l2 + Op4 - 0.3, l3 + 0.03, dxCreateTexture(""..v[1]..""), Op5 - 0.7, tocolor(v[2], v[3], v[4], 255), 0, 0, -1730900)
							end
						end
					end
				end
			end
		end
	end
end
addEventHandler("onClientRender", root, getMarkerCustom)

Shared side:

ImgType = { -- ID, Imagem Logo, R, G, B
	[1] = {"assets/tipos/1.png", 255, 255, 255}, -- CETA
	[2] = {"assets/tipos/2.png", 255, 255, 255}, -- MALETA
	[3] = {"assets/tipos/3.png", 255, 255, 255}, -- ANONYMOUS
	[4] = {"assets/tipos/4.png", 255, 255, 255}, -- CHOQUE
	[5] = {"assets/tipos/5.png", 255, 255, 255}, -- GOE
	[6] = {"assets/tipos/6.png", 255, 255, 255}, -- CONCESSONARIA
	[7] = {"assets/tipos/7.png", 255, 255, 255}, -- DETRAN
	[8] = {"assets/tipos/8.png", 255, 255, 255}, -- MECANICO
	[9] = {"assets/tipos/9.png", 255, 255, 255}, -- POLICIA CIVIL
	[10] = {"assets/tipos/10.png", 255, 255, 255}, -- POLICIA FEDERAL
	[11] = {"assets/tipos/11.png", 255, 255, 255}, -- POLICIA MILITAR
	[12] = {"assets/tipos/12.png", 255, 255, 255}, -- POLICIA RODOVIARIA FEDERAL
	[13] = {"assets/tipos/13.png", 255, 255, 255}, -- SAMU
	[14] = {"assets/tipos/8.png", 255, 20, 147}, -- MECANICO COR ROSA
}

CicleType = { -- ID, Imagem Circulo, R, G, B
	[1] = {"assets/circulos/1.png", 255, 255, 255}, -- CICULO PADRÂO BRANCO
	[2] = {"assets/circulos/1.png", 255, 20, 147}, -- CICULO PADRÂO ROSA
	[3] = {"assets/circulos/1.png", 58, 95, 205}, -- CICULO PADRÂO AZUL ROYAL
}

Server side

concessonaria1 = createMarker (1778.1500000000,-1772.000000000,12.70305099487, "cylinder", 1.5, 255, 255, 255, 0 )
setElementData(concessonaria1, "marker:custom", 6) -- MARKER ID IMAGEM ( TIPO 6 = CONCESSONARIA)
setElementData(concessonaria1, "marker:cicletype", 3) -- MARKER ID CIRCULO ( TIPO 3 = CICULO PADRAO AZUL)

Debugscript:

spacer.png

Acredito que o problema é no for, mas não sei como resolver... ?

Link to comment
  • 1 month later...

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