Jump to content

[Help] Not rendering, again


Kazafka

Recommended Posts

Code:

function getElementSpeed(theElement, unit)
    -- Check arguments for errors
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    local elementType = getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

function isElementOutSide(elem)
	if elem then
		if getElementInterior(elem) == 0 then
			return true
		else
			return false
		end
	else
		return false
	end
end

pliki = {
	mapa = "files/map.png", --Domyślna tekstura mapy
	gracz = "files/player.png", --Domyślna tekstura gracza
}
	
hud = {
	szer = 320, --Długość i wysokość radaru, tego nie zmieniamy pod żadnym pozorem
	przez = 200, --Przeźroczystość
	unit = 3000 / 6000, --Unity, radzę nie zmieniać
	wiel = 320, --Wielkość mapy, też radzę nie zmieniać
	rot = true --Obrót minimapki
}

ustawienia = {
	dispHud = true, --Wyświatlaj mapę
	current_minimap = 2 --Obecna tekstóra minimapy
}

deweloper = {
	false, --Opcja dewelopera #1
	false, --Opcja dewelopera #2
	false --Opcja dewelopera #3
}

addEventHandler("onClientResourceStart", resourceRoot, function()
	setPlayerHudComponentVisible("radar", false)
	
	minimap = dxCreateRenderTarget(hud.szer, hud.szer, true)
	full = dxCreateRenderTarget(hud.szer + 5, hud.szer + 5, true)
end)

addEventHandler("onClientResourceStop", resourceRoot, function()
	setPlayerHudComponentVisible("radar", true)
end)

addEventHandler("onClientRender", root, function()
	if ustawienia.dispHud then
		local w, h = guiGetScreenSize()
	
		local x, y, z = getElementPosition(localPlayer)
		
		local rx, ry, rz = getElementRotation(localPlayer)
		
		local x = x * hud.unit
		local y = y * hud.unit
		
		if deweloper[1] then
			outputChatBox(tostring(x) .. ", " .. tostring(y))
		end
		
		dxSetRenderTarget(minimap, false)
		dxSetBlendMode("blend")
		
		local zeroX = 1314
		local zeroY = 1322
		
		local mapX = x + zeroX + 15
		local mapY = y + zeroY
		
		local zoneX, zoneY, zoneZ = getElementPosition(localPlayer)
		
		if isElementOutSide(localPlayer) then
			dxDrawImageSection(0, 0, hud.wiel, hud.wiel, mapX, mapY, hud.wiel, hud.wiel, pliki.mapa, 0, 0, 0, tocolor(255, 255, 255, hud.przez))
		else
			dxDrawImageSection(0, 0, hud.wiel, hud.wiel, mapX, mapY, hud.wiel, hud.wiel, pliki.int, 0, 0, 0, tocolor(255, 255, 255, hud.przez), "nil")
		end
		
		if deweloper[3] then
			outputChatBox(tostring(getElementInterior(localPlayer)))
		end
		
		dxDrawImage(hud.szer / 2, hud.szer / 2, 20, 20, pliki.gracz, 180 + rz, 0, 0, tocolor(255, 255, 255, hud.przez))
		
		dxSetRenderTarget(full, false)
		if hud.rot then
			dxDrawImage(1, h - hud.szer - 1, hud.szer, hud.szer, minimap, rz)
		else
			dxDrawImage(1, h - hud.szer - 1, hud.szer, hud.szer, minimap)
			dxDrawRectangle(0, h - hud.szer - 5, hud.szer + 5, 5, tocolor(0, 0, 0, hud.przez))
			dxDrawRectangle(hud.szer, h - hud.szer, 5, hud.szer, tocolor(0, 0, 0, hud.przez))
		end
		dxSetRenderTarget()
		
		dxDrawImage(0, h - hud.szer, hud.szer + 5, hud.szer + 5, full)
		
		dxDrawRectangle(0, h - hud.szer, 170, 20, tocolor(0, 0, 0, hud.przez))
		
		if isElementOutSide(localPlayer) then
			dxDrawText(getZoneName(zoneX, zoneY, zoneZ), 5, h - hud.szer + 2, 0, 0, tocolor(255, 255, 255, hud.przez), 1.0, 1.0, "default"--[[, "left", "top", false, false, false, false, false, rz]])
		else
			dxDrawText("Interior number " .. tostring(getElementInterior(localPlayer)), 5, h - hud.szer, 0, 0, tocolor(255, 255, 0, hud.przez), 1.0, 1.0, "default-bold"--[[, "left", "top", false, false, false, false, false, rz]])
		end
		
		dxSetTextureEdge(minimap, "border", tocolor(0, 0, 0, hud.przez))
	end
end)

bindKey("n", "down", function()
	if isPlayerHudComponentVisible("radar") then
		setPlayerHudComponentVisible("radar", false)
		ustawienia.dispHud = true
	else
		setPlayerHudComponentVisible("radar", true)
		ustawienia.dispHud = false
	end
end)

Output is nothing.

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