Jump to content

Firehose


FaydenFX.

Recommended Posts

firehose = {}

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
	if type(sEventName) == 'string' and isElement(pElementAttachedTo) and type(func) == 'function' then
	local aAttachedFunctions = getEventHandlers(sEventName, pElementAttachedTo)
	if type(aAttachedFunctions) == 'table' and #aAttachedFunctions > 0 then for i,v in ipairs(aAttachedFunctions) do if v == func then return true end end end 
	end return false
end

addCommandHandler("firehose", function()
	local data = getElementData(localPlayer, "player:firehose")
	if not data then setElementData(localPlayer, "player:firehose", {["holder"] = "evidently"}) checkPlayerObject(localPlayer) else setElementData(localPlayer, "player:firehose", {["holder"] = "deficiency"}) end
end)

local function checkPlayerObject(player)
	if not player or not isElement(player) or getElementType(player) ~= "player" then return false end
	
	local data = getElementData(player, "player:firehose")
	if data["holder"] == "evidently" then
		local position = {getElementPosition(player)}
		table.insert(firehose, {x=position[1], y=position[2], z=position[3]})
		
		if not isEventHandlerAdded("onClientRender", root, firehoseRender) then
			addEventHandler("onClientRender", root, firehoseRender)
		end
	else
		if isEventHandlerAdded("onClientRender", root, firehoseRender) then
			removeEventHandler("onClientRender", root, firehoseRender)
		end
	end
end

function firehoseRender()
	for i,v in pairs(firehose) do
		if (firehose[i + 1] ~= nil) then
			dxDrawLine3D(firehose[i].x, firehose[i].y, firehose[i].z+0.3, firehose[i + 1].x, firehose[i + 1].y, firehose[i + 1].z+0.3, tocolor(255, 255, 255, 255), 10)
		else
			dxDrawLine3D(firehose[i].x, firehose[i].y, firehose[i].z+0.3, firehose[i + 1].x, firehose[i + 1].y, firehose[i + 1].z+0.3, tocolor(255, 255, 255, 255), 10)
		end
	end
end

 

It does not work, any ideas?

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