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?