Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2021-08-20, 14:35


eksdi123







Wiek: 25
Na forum: 1982 dni
Posty: 26
Nick w MP: Kupson



Respekt: 50

Witam!
Mam ma?y problemik a mianowicie wgra?em nowy radar aczkolwiek dalej po zalogowaniu si? na serwer stary wci?? si? pojawia....
Doda?em do radaru " showPlayerHudComponent("radar", false)" natomiast dalej nic..
M?g?by kto? doradzi? co zrobi? ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-20, 14:45


N0TH1NG

Mod-Team






Wiek: 20
Na forum: 2705 dni
Posty: 286
Nick w MP: N0TH1NG

Piwa: 626

Respekt: 830
Respekt: 830Respekt: 830

U?ywasz przestarza?ej funkcji spr?buj u?y? tego:
Więcej informacji znajdziesz w Wikipedii MTA:

setPlayerHudComponentVisible

Druga sprawa je?li masz to po stronie servera pierwszy argument to gracz, a nie komponent, je?li client to nie musisz dodawa? przed komponentem gracza.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-20, 15:20


eksdi123







Wiek: 25
Na forum: 1982 dni
Posty: 26
Nick w MP: Kupson



Respekt: 50

Kod:

local radarTab = {billboard = nil, quad = nil, renderTarget = nil, tiles = {}, blips = {}, custom = {tiles = {}, blips = {}, materials = {}}, enabled = false}
local scx, scy = guiGetScreenSize()

-- window settings
local windowSize = {200, 125}
local blipSize = 0.5

windowSize = {windowSize[1] * (scy / 600) , windowSize[2] * (scy / 600)}
local windowStart = {scx * 0.012, scy * 0.97 - windowSize[2]}
--blipSize = blipSize * (scy / 600)
local addSize = 10 * (scy / 600)
local borderDist = 0.1
local cullDist = 1500

-- color settings
local healthOkay = {102, 204, 102}
local healthBad = {200, 200, 0}
local healthCritical = {200, 0, 0}
local armorColor1 = tocolor(0, 102, 255, 100)
local oxygenColor1 = tocolor(255, 255, 0, 100)
local armorColor2 = tocolor(0, 102, 255, 190)
local oxygenColor2 = tocolor(255, 255, 0, 190)

-- 3D map settings
local backgroundColor = tocolor(125, 168, 210, 255) -- map background
local renderTargetColor = tocolor(255, 255, 255, 190) -- map tiles, zones
local rectangleColor = tocolor(0, 0, 0, 175)
local camHeight = {255, 455} -- #1 for ped #2 for veh
local camAngle = {-90, -55} -- #1 for ped #2 for veh
local arrowSize = 35 -- player arrow

-- don't touch
local clipDistance = {0.3, 4500}
local fieldOfView = math.rad(80)


------------------------------------------------------------------------------------------------------------------
-- onClientResourceStart/Stop
------------------------------------------------------------------------------------------------------------------
addEventHandler("onClientResourceStart", resourceRoot, function()
setPlayerHudComponentVisible("radar", false)
radarTab.blip = nil
radarTab.quad = nil
radarTab.renderTarget = nil
radarTab.enabled = createTileTextures() and createBlipTextures()
radarTab.renderTarget = dxCreateRenderTarget(windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, true)
if radarTab.enabled and radarTab.renderTarget then
radarTab.blip = dxCreateShader("fx/image2D_manual_blip.fx")
radarTab.quad = dxCreateShader("fx/image3D_manual.fx")
if radarTab.quad and radarTab.blip then
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0 )
dxSetShaderValue( radarTab.quad, "sElementPosition", 0, 0, 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", 0, 0 )
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
dxSetShaderValue( radarTab.quad, "sFov", fieldOfView )
dxSetShaderValue( radarTab.quad, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( radarTab.quad, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( radarTab.quad, "sScrRes", scx, scy )
dxSetShaderValue( radarTab.quad, "bIsArrow", false )

dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0 )
dxSetShaderValue( radarTab.blip, "sElementPosition", 0, 0, 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", 0, 0 )
dxSetShaderValue( radarTab.blip, "sFov", fieldOfView )
dxSetShaderValue( radarTab.blip, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( radarTab.blip, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( radarTab.blip, "sScrRes", scx, scy )
dxSetShaderValue( radarTab.blip, "bIsBorder", false )
dxSetShaderValue( radarTab.blip, "fBorderDist", borderDist )

radarTab.enabled = true
else
outputChatBox('Radar3D: Create shader fail')
radarTab.enabled = false
end
else
outputChatBox('Radar3D: Create tile textures fail')
destroyTileTextures()
end
collectgarbage("setpause",100)
end
)

addEventHandler("onClientResourceStop", resourceRoot, function()
setPlayerHudComponentVisible("radar", true)
destroyTileTextures()
destroyBlipTextures()
if radarTab.quad then
destroyElement(radarTab.quad)
end
if radarTab.blip then
destroyElement(radarTab.blip)
end
if isElement(radarTab.renderTarget) then
destroyElement(radarTab.renderTarget)
end
end
)

------------------------------------------------------------------------------------------------------------------
-- render 3dRadar
------------------------------------------------------------------------------------------------------------------
local timeValue = 0
local tickCount = getTickCount()
addEventHandler("onClientPreRender", root, function()
if tickCount + 25 > getTickCount() then return end
tickCount = getTickCount()
if isPedInVehicle ( localPlayer ) and timeValue < 1 then
timeValue = timeValue + 0.025
end
if not isPedInVehicle ( localPlayer ) and timeValue > 0 then
timeValue = timeValue - 0.025
end
end
)

-- count those only once
-- hud
local hudPos = {windowStart[1] - math.floor(windowSize[1] / 100) * 2, windowStart[2] - math.floor(windowSize[2] / 75) * 2}
local hudSiz = {windowSize[1] + math.floor(windowSize[1] / 100) * 4, windowSize[2] + math.floor(windowSize[2] / 75) * (4 + 5)}
local rad1Pos = {windowStart[1], windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local rad2Pos = {windowStart[1] + math.floor(windowSize[1] / 2 + windowSize[1] / 200), windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local radSiz = {math.floor(windowSize[1] / 2 - windowSize[1] / 400), math.floor(windowSize[2] / 75) * 4}

addEventHandler("onClientRender", root, function()
if not radarTab.enabled then return end
-- draw stats and stuff
--dxDrawRectangle(hudPos[1], hudPos[2], hudSiz[1], hudSiz[2], rectangleColor)

local health = math.max(math.min(getElementHealth(localPlayer) / (0.232018558500192 * getPedStat(localPlayer, 24) -32.018558511152), 1), 0)
local armor = math.max(math.min(getPedArmor(localPlayer) / 100, 1), 0)
local oxygen = math.max(math.min(getPedOxygenLevel(localPlayer) / (1.5 * getPedStat(localPlayer, 225) + 1000), 1), 0)

local r, g, b
if health >= 0.25 then
r, g, b = interpolateBetween(healthBad[1], healthBad[2], healthBad[3], healthOkay[1], healthOkay[2], healthOkay[3], math.floor(health*20)/10, "InOutQuad")
else
r, g, b = interpolateBetween(healthCritical[1], healthCritical[2], healthCritical[3], healthBad[1], healthBad[2], healthBad[3], math.floor(health*20)/10, "InOutQuad")
end

local col = tocolor(r, g, b, 190)
local bg = tocolor(r, g, b, 100)

--dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1], radSiz[2], bg)
--dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1] * health, radSiz[2], col)

if alwaysRenderOxygen or (oxygen < 1 or isElementInWater(localPlayer)) then
local rad3PosX = windowStart[1] + math.floor(windowSize[1] * 0.75 + windowSize[1] / 150)
local rad3SizX = math.floor(windowSize[1] / 4 - windowSize[1] / 200)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], rad3SizX, radSiz[2], armorColor1)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * rad3SizX, radSiz[2], armorColor2)
--dxDrawRectangle(rad3PosX, rad2Pos[2], rad3SizX, radSiz[2], oxygenColor1)
--dxDrawRectangle(rad3PosX, rad2Pos[2], oxygen * rad3SizX, radSiz[2], oxygenColor2)
else
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], radSiz[1], radSiz[2], armorColor1)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * radSiz[1], radSiz[2], armorColor2)
end

-- switch to 3d map render target
dxSetRenderTarget(radarTab.renderTarget)
dxDrawRectangle(0, 0, scx, scy, backgroundColor)

-- get camera matrix
local camMat = getElementMatrix(getCamera())

-- calculate radar view
local altPosZ = camHeight[1] + ((camHeight[2] - camHeight[1]) * (timeValue + 0.05))
local altRotX = math.rad(camAngle[1] - ((camAngle[1] - camAngle[2]) * (timeValue + 0.05)))
local altRotZ = vec2Angle(camMat[2][1], camMat[2][2])

-- create a matrix based on above
local thisPos = camMat[4]
if isElement(localPlayer) then
if isElementStreamedIn(localPlayer) then
thisPos[1], thisPos[2] = getElementPosition(localPlayer)
end
end

dxSetShaderValue( radarTab.quad, "bIsArrow", false )
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0)
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )

dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0)

dxSetShaderValue( radarTab.quad, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.quad, "sCameraInputRotation", altRotX, 0, altRotZ )

dxSetShaderValue( radarTab.blip, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.blip, "sCameraInputRotation", altRotX, 0, altRotZ )

local plDimension = getElementDimension(localPlayer)
local plInterior = getElementInterior(localPlayer)

-- draw map tiles
if plInterior == 0 then
for x=0, 5, 1 do
for y=0, 5, 1 do
if ( math.abs(radarTab.tiles[x][y].position[1] - thisPos[1]) < cullDist and math.abs(radarTab.tiles[x][y].position[2] - thisPos[2]) < cullDist ) then

dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, radarTab.tiles[x][y].shader, 0, 0, 0 )
end
end
end
end

for k, v in ipairs(radarTab.custom.tiles) do
if v.enabled then
if plInterior == v.interior then
if ( math.abs(v.position[1] - thisPos[1]) < cullDist and math.abs(v.position[2] - thisPos[2]) < cullDist ) then
if isElement(v.texture) then

dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
end
end
end
end
end

dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[64] )

-- draw radar areas
for k, v in ipairs(getElementsByType("radararea")) do
local raPos = {getElementPosition(v)}
local raSiz = {getRadarAreaSize(v)}

if getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then
local bcR, bcG, bcB, bcA = getRadarAreaColor(v)
bcA = math.min(bcA, 200)

dxSetShaderValue( radarTab.quad, "sElementPosition", raPos[1] + raSiz[1] / 2, raPos[2] + raSiz[2] / 2, 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", raSiz[1], raSiz[2] )
dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )
end
end

for k, v in ipairs(radarTab.custom.materials) do
if v.enabled then
if plInterior == v.interior then
if ( math.abs(v.position[1] - thisPos[1]) < cullDist and math.abs(v.position[2] - thisPos[2]) < cullDist ) then
if isElement(v.texture) then

dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
end
end
end
end
end

-- skip to original RT
dxSetRenderTarget()

dxDrawImageSection( windowStart[1], windowStart[2], windowSize[1], windowSize[2],
addSize, addSize, windowSize[1], windowSize[2], radarTab.renderTarget, 0, 0, 0, renderTargetColor )

-- set and clear map RT
dxSetRenderTarget( radarTab.renderTarget, true )

dxSetShaderValue( radarTab.blip, "bIsBorder", false )
local plaPos = {getElementPosition(localPlayer)}

-- draw blips
for k, v in ipairs(getElementsByType("blip")) do
local bliPos = {getElementPosition(v)}
if bliPos[1] and bliPos[2] then
local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
if actualDist <= getBlipVisibleDistance(v) and getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then
local bid = getElementData(v, "customIcon") or getBlipIcon(v)
local _, _, _, bcA = getBlipColor(v)
local bcR, bcG, bcB = 255, 255, 255
if getBlipIcon(v) == 0 then
bcR, bcG, bcB = getBlipColor(v)
end
local bS = getBlipSize(v) * 0.75

dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[bid] )
dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )
end
end
end

-- draw custom blips
for k, v in ipairs(radarTab.custom.blips) do
if v.enabled then
local bliPos = v.position
if bliPos[1] and bliPos[2] then
local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
local maxDist = v.distance
if actualDist <= maxDist and v.dimension == plDimension and v.interior == plInterior then
if isElement(v.texture) then
local bS = v.size * 0.75

dxSetShaderValue( radarTab.blip, "sTexColor", v.texture )
dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, v.color )
end
end
end
end
end

-- get arrow texture
dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[2] )

-- get ped arrow yaw
local plVec = getElementMatrix(localPlayer)[2]
local plAngle = vec2Angle(plVec[1], plVec[2])
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, plAngle )

-- set the remaining renderer stuff for arrow
dxSetShaderValue( radarTab.quad, "sElementPosition", plaPos[1], plaPos[2], 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", arrowSize, arrowSize )
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "bIsArrow", true )
dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0 )

dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[4] )
dxSetShaderValue( radarTab.blip, "sElementPosition", thisPos[1], thisPos[2] + 3000, 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", blipSize * 2.5, blipSize * 2.5 )
dxSetShaderValue( radarTab.blip, "bIsBorder", true )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0 )

-- skip to original RT
dxSetRenderTarget()
dxDrawImage(windowStart[1], windowStart[2], windowSize[1], windowSize[2], "tex/radar_frame.png")
-- draw the player arrow
dxDrawImage(windowStart[1] - addSize, windowStart[2] - addSize, windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, radarTab.renderTarget, 0, 0, 0)
end
)

------------------------------------------------------------------------------------------------------------------
-- tile textures
------------------------------------------------------------------------------------------------------------------
function setTileShaderValues(this)
dxSetShaderValue( this.shader, "sTexColor", this.texture )
dxSetShaderValue( this.shader, "sElementRotation", this.rotation )
dxSetShaderValue( this.shader, "sElementPosition", this.position )
dxSetShaderValue( this.shader, "sElementSize", this.size )
dxSetShaderValue( this.shader, "sFov", fieldOfView )
dxSetShaderValue( this.shader, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( this.shader, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( this.shader, "sScrRes", scx, scy )

end

function createTileTextures()
local isTexValid = true
radarTab.tiles = {}
for x=0, 5, 1 do
radarTab.tiles[x] = {}
for y=0, 5, 1 do
radarTab.tiles[x][y] = {}
radarTab.tiles[x][y].position = {-3000 + 1000 * x + 500, 3000 - 1000 * y - 500, 0}
radarTab.tiles[x][y].size = {1000, 1000}
radarTab.tiles[x][y].rotation = {0, 0, 0}
radarTab.tiles[x][y].texture = dxCreateTexture("tex/radar/tile_"..y.."_"..x..".dds")
radarTab.tiles[x][y].shader = dxCreateShader("fx/image3D_manual_quad.fx")
isTexValid = isElement(radarTab.tiles[x][y].texture) and isElement(radarTab.tiles[x][y].shader) and isTexValid
if isTexValid then
setTileShaderValues(radarTab.tiles[x][y])
end
end
end
return isTexValid
end

function destroyTileTextures()
local isTexValid = true
for x=0, 5, 1 do
for y=0, 5, 1 do
if isElement(radarTab.tiles[x][y].texture) then
isTexValid = destroyElement(radarTab.tiles[x][y].texture) and destroyElement(radarTab.tiles[x][y].shader) and isTexValid
end
end
end
return isTexValid
end

function createBlipTextures()
local isTexValid = true
for x=0, 65, 1 do
radarTab.blips[x] = dxCreateTexture("tex/blip/"..x..".png", "dxt5", false, "clamp")
isTexValid = isElement(radarTab.blips[x]) and isTexValid
end
return isTexValid
end

function destroyBlipTextures()
local isTexValid = true
for x=0, 65, 1 do
if isElement(radarTab.blips[x]) then
isTexValid = destroyElement(radarTab.blips[x]) and isTexValid
end
end
return isTexValid
end

------------------------------------------------------------------------------------------------------------------
-- exports handling
------------------------------------------------------------------------------------------------------------------
customBlip = {}
function customBlip.create(posX, posY, posZ, tTexture, size, colR, colG, colB, colA, visibleDistance)
local w = findEmptyEntry(radarTab.custom.blips)
radarTab.custom.blips[w] = {}
radarTab.custom.blips[w].texture = tTexture
radarTab.custom.blips[w].position = {posX, posY, posZ}
radarTab.custom.blips[w].rotation = {0, 0, 0}
radarTab.custom.blips[w].size = size
radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.blips[w].distance = visibleDistance
radarTab.custom.blips[w].interior = 0
radarTab.custom.blips[w].dimension = 0

if isElement(radarTab.custom.blips[w].texture) then
radarTab.custom.blips[w].shader = dxCreateShader("fx/image2D_manual_blip.fx.fx")
if isElement(radarTab.custom.blips[w].shader) then
setTileShaderValues(radarTab.custom.blips[w])
radarTab.custom.blips[w].enabled = true
return w
end
end
radarTab.custom.blips[w].enabled = false
return false
end

function customBlip.destroy(w)
radarTab.custom.blips[w].enabled = false
if isElement(radarTab.custom.blips[w].shader) then
destroyElement(radarTab.custom.blips[w].shader)
end
radarTab.custom.blips[w].tTexture = nil
end

function customBlip.setTexture(w, tTexture)
radarTab.custom.blips[w].tTexture = tTexture
end

function customBlip.setPosition(w, posX, posY, posZ)
radarTab.custom.blips[w].position = {posX, posY, posZ}
end

function customBlip.setColor(w, colR, colG, colB, colA)
radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
end

function customBlip.setSize(w, size)
radarTab.custom.blips[w].size = size
end

function customBlip.setDistance(w, dist)
radarTab.custom.blips[w].distance = dist
end

function customBlip.setInterior(w, interior)
radarTab.custom.blips[w].interior = interior
end

function customBlip.setDimension(w, dimension)
radarTab.custom.blips[w].dimension = dimension
end

customTile = {}
function customTile.create(tTexture, posX, posY, posZ, rotX, rotY, rotZ, sizX, sizY, colR, colG, colB, colA , isBill)
local w = findEmptyEntry(radarTab.custom.tiles)
radarTab.custom.tiles[w] = {}
radarTab.custom.tiles[w].texture = tTexture
radarTab.custom.tiles[w].position = {posX, posY, posZ}
radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.tiles[w].size = {sizX, sizY}
radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.tiles[w].isBillboard = isBill
radarTab.custom.tiles[w].cull = 2
radarTab.custom.tiles[w].interior = 0

if isElement(radarTab.custom.tiles[w].texture) then
radarTab.custom.tiles[w].shader = dxCreateShader("fx/image3D_manual.fx")
if isElement(radarTab.custom.tiles[w].shader) then
setTileShaderValues(radarTab.custom.tiles[w])
dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", 2)
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)
dxSetShaderValue(radarTab.custom.tiles[w].shader, "bIsArrow", false)
radarTab.custom.tiles[w].enabled = true
return w
end
end
radarTab.custom.tiles[w].enabled = false
return false
end

function customTile.destroy(w)
radarTab.custom.tiles[w].enabled = false
if isElement(radarTab.custom.tiles[w].shader) then
destroyElement(radarTab.custom.tiles[w].shader)
end
radarTab.custom.tiles[w].tTexture = nil
end

function customTile.setTexture(w, tTexture)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].tTexture = tTexture
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sTexColor", tTexture)
end
end

function customTile.setPosition(w, posX, posY, posZ)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].position = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementPosition", posX, posY, posZ)
end
end

function customTile.setRotation(w, rotX, rotY, rotZ)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementRotation", rotX, rotY, rotZ)
end
end

function customTile.setColor(w, colR, colG, colB, colA)
radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
end

function customTile.setSize(w, sizeX, sizeY)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].size = {sizeX, sizeY}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementSize", sizeX, sizeY)
end
end

function customTile.setInterior(w, interior)
radarTab.custom.tiles[w].interior = interior
end

function customTile.setBillboard(w, isBill)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].isBillboard = isBill
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)
end
end

function customTile.setCullMode(w, cull)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].cull = cull
dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", cull)
end
end

customMaterial = {}
function customMaterial.createLine3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, width, colR, colG, colB, colA, isBill, isSoft)
local w = findEmptyEntry(radarTab.custom.materials)
radarTab.custom.materials[w] = {}
if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
else radarTab.custom.materials[w].texture = radarTab.blips[64]
end
radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
radarTab.custom.materials[w].position3 = {0, 0, 0}
radarTab.custom.materials[w].position4 = {0, 0, 0}
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.materials[w].size = {width, 0}
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.materials[w].isBillboard = isBill
radarTab.custom.materials[w].cull = 1
radarTab.custom.materials[w].interior = 0

if isElement(radarTab.custom.materials[w].texture) then
radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_line.fx")
if isElement(radarTab.custom.materials[w].shader) then
setTileShaderValues(radarTab.custom.materials[w])
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)
radarTab.custom.materials[w].enabled = true
return w
end
end
radarTab.custom.materials[w].enabled = false
return false
end

function customMaterial.createBezier3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z, width, colR, colG, colB, colA, isBill, isSoft)
local w = findEmptyEntry(radarTab.custom.materials)
radarTab.custom.materials[w] = {}
if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
else radarTab.custom.materials[w].texture = radarTab.blips[64]
end
radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
radarTab.custom.materials[w].position3 = {pos3X, pos3Y, pos3Z}
radarTab.custom.materials[w].position4 = {pos4X, pos4Y, pos4Z}
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.materials[w].size = {width, 0}
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.materials[w].isBillboard = isBill
radarTab.custom.materials[w].cull = 1
radarTab.custom.materials[w].interior = 0

if isElement(radarTab.custom.materials[w].texture) then
radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_bezier.fx")
if isElement(radarTab.custom.materials[w].shader) then
setTileShaderValues(radarTab.custom.materials[w])
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", pos3X, pos3Y, pos3Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", pos4X, pos4Y, pos4Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
local pointDist = getDistanceBetweenPoints3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z) +
getDistanceBetweenPoints3D(pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z) +
getDistanceBetweenPoints3D(pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z)
dxSetShaderTessellation(radarTab.custom.materials[w].shader, 1, math.ceil(pointDist))
dxSetShaderValue(radarTab.custom.materials[w].shader, "sTesselation", math.ceil(pointDist))
radarTab.custom.materials[w].enabled = true
return w
end
end
radarTab.custom.materials[w].enabled = false
return false
end

function customMaterial.destroy(w)
radarTab.custom.materials[w].enabled = false
if isElement(radarTab.custom.materials[w].shader) then
destroyElement(radarTab.custom.materials[w].shader)
end
radarTab.custom.materials[w].tTexture = nil
end

function customMaterial.setTexture(w, tTexture)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].tTexture = tTexture
dxSetShaderValue( radarTab.custom.materials[w].shader, "sTexColor", tTexture)
end
end

function customMaterial.setPosition(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementPosition", posX, posY, posZ)
end
end

function customMaterial.setPosition1(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position1 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", posX, posY, posZ)
end
end

function customMaterial.setPosition2(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position2 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", posX, posY, posZ)
end
end

function customMaterial.setPosition3(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position3 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", posX, posY, posZ)
end
end

function customMaterial.setPosition4(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position4 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", posX, posY, posZ)
end
end

function customMaterial.setRotation(w, rotX, rotY, rotZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementRotation", rotX, rotY, rotZ)
end
end

function customMaterial.setColor(w, colR, colG, colB, colA)
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
end

function customMaterial.setSize(w, sizeX, sizeY)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].size = {sizeX, sizeY}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementSize", sizeX, sizeY)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", sizeX)
end
end

function customMaterial.setInterior(w, interior)
radarTab.custom.materials[w].interior = interior
end

function customMaterial.setBillboard(w, isBill)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].isBillboard = isBill
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
end
end

function customMaterial.setCullMode(w, cull)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].cull = cull
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", cull)
end
end

------------------------------------------------------------------------------------------------------------------
-- helper functions
------------------------------------------------------------------------------------------------------------------
function findEmptyEntry(inTable)
for index,value in ipairs(inTable) do
if not value.enabled then
return index
end
end
return #inTable + 1
end

function vec2Angle(x, y)
local t = -(math.atan2(x, y))
if t < 0 then t = t + (2 * math.pi) end
return t
end


To jest strona klienta..
M?g?by? pom?c to rozgry??? Bo jakos ze mna to nie chce wsp??pracowac...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-20, 15:29


N0TH1NG

Mod-Team






Wiek: 20
Na forum: 2705 dni
Posty: 286
Nick w MP: N0TH1NG

Piwa: 626

Respekt: 830
Respekt: 830Respekt: 830

"eksdi123" napisał/a:

Kod:

local radarTab = {billboard = nil, quad = nil, renderTarget = nil, tiles = {}, blips = {}, custom = {tiles = {}, blips = {}, materials = {}}, enabled = false}
local scx, scy = guiGetScreenSize()

-- window settings
local windowSize = {200, 125}
local blipSize = 0.5

windowSize = {windowSize[1] * (scy / 600) , windowSize[2] * (scy / 600)}
local windowStart = {scx * 0.012, scy * 0.97 - windowSize[2]}
--blipSize = blipSize * (scy / 600)
local addSize = 10 * (scy / 600)
local borderDist = 0.1
local cullDist = 1500

-- color settings
local healthOkay = {102, 204, 102}
local healthBad = {200, 200, 0}
local healthCritical = {200, 0, 0}
local armorColor1 = tocolor(0, 102, 255, 100)
local oxygenColor1 = tocolor(255, 255, 0, 100)
local armorColor2 = tocolor(0, 102, 255, 190)
local oxygenColor2 = tocolor(255, 255, 0, 190)

-- 3D map settings
local backgroundColor = tocolor(125, 168, 210, 255) -- map background
local renderTargetColor = tocolor(255, 255, 255, 190) -- map tiles, zones
local rectangleColor = tocolor(0, 0, 0, 175)
local camHeight = {255, 455} -- #1 for ped #2 for veh
local camAngle = {-90, -55} -- #1 for ped #2 for veh
local arrowSize = 35 -- player arrow

-- don't touch
local clipDistance = {0.3, 4500}
local fieldOfView = math.rad(80)


------------------------------------------------------------------------------------------------------------------
-- onClientResourceStart/Stop
------------------------------------------------------------------------------------------------------------------
addEventHandler("onClientResourceStart", resourceRoot, function()
setPlayerHudComponentVisible("radar", false)
radarTab.blip = nil
radarTab.quad = nil
radarTab.renderTarget = nil
radarTab.enabled = createTileTextures() and createBlipTextures()
radarTab.renderTarget = dxCreateRenderTarget(windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, true)
if radarTab.enabled and radarTab.renderTarget then
radarTab.blip = dxCreateShader("fx/image2D_manual_blip.fx")
radarTab.quad = dxCreateShader("fx/image3D_manual.fx")
if radarTab.quad and radarTab.blip then
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0 )
dxSetShaderValue( radarTab.quad, "sElementPosition", 0, 0, 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", 0, 0 )
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
dxSetShaderValue( radarTab.quad, "sFov", fieldOfView )
dxSetShaderValue( radarTab.quad, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( radarTab.quad, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( radarTab.quad, "sScrRes", scx, scy )
dxSetShaderValue( radarTab.quad, "bIsArrow", false )

dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0 )
dxSetShaderValue( radarTab.blip, "sElementPosition", 0, 0, 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", 0, 0 )
dxSetShaderValue( radarTab.blip, "sFov", fieldOfView )
dxSetShaderValue( radarTab.blip, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( radarTab.blip, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( radarTab.blip, "sScrRes", scx, scy )
dxSetShaderValue( radarTab.blip, "bIsBorder", false )
dxSetShaderValue( radarTab.blip, "fBorderDist", borderDist )

radarTab.enabled = true
else
outputChatBox('Radar3D: Create shader fail')
radarTab.enabled = false
end
else
outputChatBox('Radar3D: Create tile textures fail')
destroyTileTextures()
end
collectgarbage("setpause",100)
end
)

addEventHandler("onClientResourceStop", resourceRoot, function()
setPlayerHudComponentVisible("radar", true)
destroyTileTextures()
destroyBlipTextures()
if radarTab.quad then
destroyElement(radarTab.quad)
end
if radarTab.blip then
destroyElement(radarTab.blip)
end
if isElement(radarTab.renderTarget) then
destroyElement(radarTab.renderTarget)
end
end
)

------------------------------------------------------------------------------------------------------------------
-- render 3dRadar
------------------------------------------------------------------------------------------------------------------
local timeValue = 0
local tickCount = getTickCount()
addEventHandler("onClientPreRender", root, function()
if tickCount + 25 > getTickCount() then return end
tickCount = getTickCount()
if isPedInVehicle ( localPlayer ) and timeValue < 1 then
timeValue = timeValue + 0.025
end
if not isPedInVehicle ( localPlayer ) and timeValue > 0 then
timeValue = timeValue - 0.025
end
end
)

-- count those only once
-- hud
local hudPos = {windowStart[1] - math.floor(windowSize[1] / 100) * 2, windowStart[2] - math.floor(windowSize[2] / 75) * 2}
local hudSiz = {windowSize[1] + math.floor(windowSize[1] / 100) * 4, windowSize[2] + math.floor(windowSize[2] / 75) * (4 + 5)}
local rad1Pos = {windowStart[1], windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local rad2Pos = {windowStart[1] + math.floor(windowSize[1] / 2 + windowSize[1] / 200), windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local radSiz = {math.floor(windowSize[1] / 2 - windowSize[1] / 400), math.floor(windowSize[2] / 75) * 4}

addEventHandler("onClientRender", root, function()
if not radarTab.enabled then return end
-- draw stats and stuff
--dxDrawRectangle(hudPos[1], hudPos[2], hudSiz[1], hudSiz[2], rectangleColor)

local health = math.max(math.min(getElementHealth(localPlayer) / (0.232018558500192 * getPedStat(localPlayer, 24) -32.018558511152), 1), 0)
local armor = math.max(math.min(getPedArmor(localPlayer) / 100, 1), 0)
local oxygen = math.max(math.min(getPedOxygenLevel(localPlayer) / (1.5 * getPedStat(localPlayer, 225) + 1000), 1), 0)

local r, g, b
if health >= 0.25 then
r, g, b = interpolateBetween(healthBad[1], healthBad[2], healthBad[3], healthOkay[1], healthOkay[2], healthOkay[3], math.floor(health*20)/10, "InOutQuad")
else
r, g, b = interpolateBetween(healthCritical[1], healthCritical[2], healthCritical[3], healthBad[1], healthBad[2], healthBad[3], math.floor(health*20)/10, "InOutQuad")
end

local col = tocolor(r, g, b, 190)
local bg = tocolor(r, g, b, 100)

--dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1], radSiz[2], bg)
--dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1] * health, radSiz[2], col)

if alwaysRenderOxygen or (oxygen < 1 or isElementInWater(localPlayer)) then
local rad3PosX = windowStart[1] + math.floor(windowSize[1] * 0.75 + windowSize[1] / 150)
local rad3SizX = math.floor(windowSize[1] / 4 - windowSize[1] / 200)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], rad3SizX, radSiz[2], armorColor1)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * rad3SizX, radSiz[2], armorColor2)
--dxDrawRectangle(rad3PosX, rad2Pos[2], rad3SizX, radSiz[2], oxygenColor1)
--dxDrawRectangle(rad3PosX, rad2Pos[2], oxygen * rad3SizX, radSiz[2], oxygenColor2)
else
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], radSiz[1], radSiz[2], armorColor1)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * radSiz[1], radSiz[2], armorColor2)
end

-- switch to 3d map render target
dxSetRenderTarget(radarTab.renderTarget)
dxDrawRectangle(0, 0, scx, scy, backgroundColor)

-- get camera matrix
local camMat = getElementMatrix(getCamera())

-- calculate radar view
local altPosZ = camHeight[1] + ((camHeight[2] - camHeight[1]) * (timeValue + 0.05))
local altRotX = math.rad(camAngle[1] - ((camAngle[1] - camAngle[2]) * (timeValue + 0.05)))
local altRotZ = vec2Angle(camMat[2][1], camMat[2][2])

-- create a matrix based on above
local thisPos = camMat[4]
if isElement(localPlayer) then
if isElementStreamedIn(localPlayer) then
thisPos[1], thisPos[2] = getElementPosition(localPlayer)
end
end

dxSetShaderValue( radarTab.quad, "bIsArrow", false )
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0)
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )

dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0)

dxSetShaderValue( radarTab.quad, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.quad, "sCameraInputRotation", altRotX, 0, altRotZ )

dxSetShaderValue( radarTab.blip, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.blip, "sCameraInputRotation", altRotX, 0, altRotZ )

local plDimension = getElementDimension(localPlayer)
local plInterior = getElementInterior(localPlayer)

-- draw map tiles
if plInterior == 0 then
for x=0, 5, 1 do
for y=0, 5, 1 do
if ( math.abs(radarTab.tiles[x][y].position[1] - thisPos[1]) < cullDist and math.abs(radarTab.tiles[x][y].position[2] - thisPos[2]) < cullDist ) then

dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, radarTab.tiles[x][y].shader, 0, 0, 0 )
end
end
end
end

for k, v in ipairs(radarTab.custom.tiles) do
if v.enabled then
if plInterior == v.interior then
if ( math.abs(v.position[1] - thisPos[1]) < cullDist and math.abs(v.position[2] - thisPos[2]) < cullDist ) then
if isElement(v.texture) then

dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
end
end
end
end
end

dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[64] )

-- draw radar areas
for k, v in ipairs(getElementsByType("radararea")) do
local raPos = {getElementPosition(v)}
local raSiz = {getRadarAreaSize(v)}

if getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then
local bcR, bcG, bcB, bcA = getRadarAreaColor(v)
bcA = math.min(bcA, 200)

dxSetShaderValue( radarTab.quad, "sElementPosition", raPos[1] + raSiz[1] / 2, raPos[2] + raSiz[2] / 2, 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", raSiz[1], raSiz[2] )
dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )
end
end

for k, v in ipairs(radarTab.custom.materials) do
if v.enabled then
if plInterior == v.interior then
if ( math.abs(v.position[1] - thisPos[1]) < cullDist and math.abs(v.position[2] - thisPos[2]) < cullDist ) then
if isElement(v.texture) then

dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
end
end
end
end
end

-- skip to original RT
dxSetRenderTarget()

dxDrawImageSection( windowStart[1], windowStart[2], windowSize[1], windowSize[2],
addSize, addSize, windowSize[1], windowSize[2], radarTab.renderTarget, 0, 0, 0, renderTargetColor )

-- set and clear map RT
dxSetRenderTarget( radarTab.renderTarget, true )

dxSetShaderValue( radarTab.blip, "bIsBorder", false )
local plaPos = {getElementPosition(localPlayer)}

-- draw blips
for k, v in ipairs(getElementsByType("blip")) do
local bliPos = {getElementPosition(v)}
if bliPos[1] and bliPos[2] then
local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
if actualDist <= getBlipVisibleDistance(v) and getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then
local bid = getElementData(v, "customIcon") or getBlipIcon(v)
local _, _, _, bcA = getBlipColor(v)
local bcR, bcG, bcB = 255, 255, 255
if getBlipIcon(v) == 0 then
bcR, bcG, bcB = getBlipColor(v)
end
local bS = getBlipSize(v) * 0.75

dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[bid] )
dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )
end
end
end

-- draw custom blips
for k, v in ipairs(radarTab.custom.blips) do
if v.enabled then
local bliPos = v.position
if bliPos[1] and bliPos[2] then
local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
local maxDist = v.distance
if actualDist <= maxDist and v.dimension == plDimension and v.interior == plInterior then
if isElement(v.texture) then
local bS = v.size * 0.75

dxSetShaderValue( radarTab.blip, "sTexColor", v.texture )
dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, v.color )
end
end
end
end
end

-- get arrow texture
dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[2] )

-- get ped arrow yaw
local plVec = getElementMatrix(localPlayer)[2]
local plAngle = vec2Angle(plVec[1], plVec[2])
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, plAngle )

-- set the remaining renderer stuff for arrow
dxSetShaderValue( radarTab.quad, "sElementPosition", plaPos[1], plaPos[2], 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", arrowSize, arrowSize )
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "bIsArrow", true )
dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0 )

dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[4] )
dxSetShaderValue( radarTab.blip, "sElementPosition", thisPos[1], thisPos[2] + 3000, 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", blipSize * 2.5, blipSize * 2.5 )
dxSetShaderValue( radarTab.blip, "bIsBorder", true )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0 )

-- skip to original RT
dxSetRenderTarget()
dxDrawImage(windowStart[1], windowStart[2], windowSize[1], windowSize[2], "tex/radar_frame.png")
-- draw the player arrow
dxDrawImage(windowStart[1] - addSize, windowStart[2] - addSize, windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, radarTab.renderTarget, 0, 0, 0)
end
)

------------------------------------------------------------------------------------------------------------------
-- tile textures
------------------------------------------------------------------------------------------------------------------
function setTileShaderValues(this)
dxSetShaderValue( this.shader, "sTexColor", this.texture )
dxSetShaderValue( this.shader, "sElementRotation", this.rotation )
dxSetShaderValue( this.shader, "sElementPosition", this.position )
dxSetShaderValue( this.shader, "sElementSize", this.size )
dxSetShaderValue( this.shader, "sFov", fieldOfView )
dxSetShaderValue( this.shader, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( this.shader, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( this.shader, "sScrRes", scx, scy )

end

function createTileTextures()
local isTexValid = true
radarTab.tiles = {}
for x=0, 5, 1 do
radarTab.tiles[x] = {}
for y=0, 5, 1 do
radarTab.tiles[x][y] = {}
radarTab.tiles[x][y].position = {-3000 + 1000 * x + 500, 3000 - 1000 * y - 500, 0}
radarTab.tiles[x][y].size = {1000, 1000}
radarTab.tiles[x][y].rotation = {0, 0, 0}
radarTab.tiles[x][y].texture = dxCreateTexture("tex/radar/tile_"..y.."_"..x..".dds")
radarTab.tiles[x][y].shader = dxCreateShader("fx/image3D_manual_quad.fx")
isTexValid = isElement(radarTab.tiles[x][y].texture) and isElement(radarTab.tiles[x][y].shader) and isTexValid
if isTexValid then
setTileShaderValues(radarTab.tiles[x][y])
end
end
end
return isTexValid
end

function destroyTileTextures()
local isTexValid = true
for x=0, 5, 1 do
for y=0, 5, 1 do
if isElement(radarTab.tiles[x][y].texture) then
isTexValid = destroyElement(radarTab.tiles[x][y].texture) and destroyElement(radarTab.tiles[x][y].shader) and isTexValid
end
end
end
return isTexValid
end

function createBlipTextures()
local isTexValid = true
for x=0, 65, 1 do
radarTab.blips[x] = dxCreateTexture("tex/blip/"..x..".png", "dxt5", false, "clamp")
isTexValid = isElement(radarTab.blips[x]) and isTexValid
end
return isTexValid
end

function destroyBlipTextures()
local isTexValid = true
for x=0, 65, 1 do
if isElement(radarTab.blips[x]) then
isTexValid = destroyElement(radarTab.blips[x]) and isTexValid
end
end
return isTexValid
end

------------------------------------------------------------------------------------------------------------------
-- exports handling
------------------------------------------------------------------------------------------------------------------
customBlip = {}
function customBlip.create(posX, posY, posZ, tTexture, size, colR, colG, colB, colA, visibleDistance)
local w = findEmptyEntry(radarTab.custom.blips)
radarTab.custom.blips[w] = {}
radarTab.custom.blips[w].texture = tTexture
radarTab.custom.blips[w].position = {posX, posY, posZ}
radarTab.custom.blips[w].rotation = {0, 0, 0}
radarTab.custom.blips[w].size = size
radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.blips[w].distance = visibleDistance
radarTab.custom.blips[w].interior = 0
radarTab.custom.blips[w].dimension = 0

if isElement(radarTab.custom.blips[w].texture) then
radarTab.custom.blips[w].shader = dxCreateShader("fx/image2D_manual_blip.fx.fx")
if isElement(radarTab.custom.blips[w].shader) then
setTileShaderValues(radarTab.custom.blips[w])
radarTab.custom.blips[w].enabled = true
return w
end
end
radarTab.custom.blips[w].enabled = false
return false
end

function customBlip.destroy(w)
radarTab.custom.blips[w].enabled = false
if isElement(radarTab.custom.blips[w].shader) then
destroyElement(radarTab.custom.blips[w].shader)
end
radarTab.custom.blips[w].tTexture = nil
end

function customBlip.setTexture(w, tTexture)
radarTab.custom.blips[w].tTexture = tTexture
end

function customBlip.setPosition(w, posX, posY, posZ)
radarTab.custom.blips[w].position = {posX, posY, posZ}
end

function customBlip.setColor(w, colR, colG, colB, colA)
radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
end

function customBlip.setSize(w, size)
radarTab.custom.blips[w].size = size
end

function customBlip.setDistance(w, dist)
radarTab.custom.blips[w].distance = dist
end

function customBlip.setInterior(w, interior)
radarTab.custom.blips[w].interior = interior
end

function customBlip.setDimension(w, dimension)
radarTab.custom.blips[w].dimension = dimension
end

customTile = {}
function customTile.create(tTexture, posX, posY, posZ, rotX, rotY, rotZ, sizX, sizY, colR, colG, colB, colA , isBill)
local w = findEmptyEntry(radarTab.custom.tiles)
radarTab.custom.tiles[w] = {}
radarTab.custom.tiles[w].texture = tTexture
radarTab.custom.tiles[w].position = {posX, posY, posZ}
radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.tiles[w].size = {sizX, sizY}
radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.tiles[w].isBillboard = isBill
radarTab.custom.tiles[w].cull = 2
radarTab.custom.tiles[w].interior = 0

if isElement(radarTab.custom.tiles[w].texture) then
radarTab.custom.tiles[w].shader = dxCreateShader("fx/image3D_manual.fx")
if isElement(radarTab.custom.tiles[w].shader) then
setTileShaderValues(radarTab.custom.tiles[w])
dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", 2)
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)
dxSetShaderValue(radarTab.custom.tiles[w].shader, "bIsArrow", false)
radarTab.custom.tiles[w].enabled = true
return w
end
end
radarTab.custom.tiles[w].enabled = false
return false
end

function customTile.destroy(w)
radarTab.custom.tiles[w].enabled = false
if isElement(radarTab.custom.tiles[w].shader) then
destroyElement(radarTab.custom.tiles[w].shader)
end
radarTab.custom.tiles[w].tTexture = nil
end

function customTile.setTexture(w, tTexture)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].tTexture = tTexture
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sTexColor", tTexture)
end
end

function customTile.setPosition(w, posX, posY, posZ)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].position = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementPosition", posX, posY, posZ)
end
end

function customTile.setRotation(w, rotX, rotY, rotZ)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementRotation", rotX, rotY, rotZ)
end
end

function customTile.setColor(w, colR, colG, colB, colA)
radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
end

function customTile.setSize(w, sizeX, sizeY)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].size = {sizeX, sizeY}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementSize", sizeX, sizeY)
end
end

function customTile.setInterior(w, interior)
radarTab.custom.tiles[w].interior = interior
end

function customTile.setBillboard(w, isBill)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].isBillboard = isBill
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)
end
end

function customTile.setCullMode(w, cull)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].cull = cull
dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", cull)
end
end

customMaterial = {}
function customMaterial.createLine3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, width, colR, colG, colB, colA, isBill, isSoft)
local w = findEmptyEntry(radarTab.custom.materials)
radarTab.custom.materials[w] = {}
if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
else radarTab.custom.materials[w].texture = radarTab.blips[64]
end
radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
radarTab.custom.materials[w].position3 = {0, 0, 0}
radarTab.custom.materials[w].position4 = {0, 0, 0}
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.materials[w].size = {width, 0}
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.materials[w].isBillboard = isBill
radarTab.custom.materials[w].cull = 1
radarTab.custom.materials[w].interior = 0

if isElement(radarTab.custom.materials[w].texture) then
radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_line.fx")
if isElement(radarTab.custom.materials[w].shader) then
setTileShaderValues(radarTab.custom.materials[w])
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)
radarTab.custom.materials[w].enabled = true
return w
end
end
radarTab.custom.materials[w].enabled = false
return false
end

function customMaterial.createBezier3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z, width, colR, colG, colB, colA, isBill, isSoft)
local w = findEmptyEntry(radarTab.custom.materials)
radarTab.custom.materials[w] = {}
if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
else radarTab.custom.materials[w].texture = radarTab.blips[64]
end
radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
radarTab.custom.materials[w].position3 = {pos3X, pos3Y, pos3Z}
radarTab.custom.materials[w].position4 = {pos4X, pos4Y, pos4Z}
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.materials[w].size = {width, 0}
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.materials[w].isBillboard = isBill
radarTab.custom.materials[w].cull = 1
radarTab.custom.materials[w].interior = 0

if isElement(radarTab.custom.materials[w].texture) then
radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_bezier.fx")
if isElement(radarTab.custom.materials[w].shader) then
setTileShaderValues(radarTab.custom.materials[w])
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", pos3X, pos3Y, pos3Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", pos4X, pos4Y, pos4Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
local pointDist = getDistanceBetweenPoints3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z) +
getDistanceBetweenPoints3D(pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z) +
getDistanceBetweenPoints3D(pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z)
dxSetShaderTessellation(radarTab.custom.materials[w].shader, 1, math.ceil(pointDist))
dxSetShaderValue(radarTab.custom.materials[w].shader, "sTesselation", math.ceil(pointDist))
radarTab.custom.materials[w].enabled = true
return w
end
end
radarTab.custom.materials[w].enabled = false
return false
end

function customMaterial.destroy(w)
radarTab.custom.materials[w].enabled = false
if isElement(radarTab.custom.materials[w].shader) then
destroyElement(radarTab.custom.materials[w].shader)
end
radarTab.custom.materials[w].tTexture = nil
end

function customMaterial.setTexture(w, tTexture)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].tTexture = tTexture
dxSetShaderValue( radarTab.custom.materials[w].shader, "sTexColor", tTexture)
end
end

function customMaterial.setPosition(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementPosition", posX, posY, posZ)
end
end

function customMaterial.setPosition1(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position1 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", posX, posY, posZ)
end
end

function customMaterial.setPosition2(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position2 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", posX, posY, posZ)
end
end

function customMaterial.setPosition3(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position3 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", posX, posY, posZ)
end
end

function customMaterial.setPosition4(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position4 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", posX, posY, posZ)
end
end

function customMaterial.setRotation(w, rotX, rotY, rotZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementRotation", rotX, rotY, rotZ)
end
end

function customMaterial.setColor(w, colR, colG, colB, colA)
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
end

function customMaterial.setSize(w, sizeX, sizeY)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].size = {sizeX, sizeY}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementSize", sizeX, sizeY)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", sizeX)
end
end

function customMaterial.setInterior(w, interior)
radarTab.custom.materials[w].interior = interior
end

function customMaterial.setBillboard(w, isBill)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].isBillboard = isBill
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
end
end

function customMaterial.setCullMode(w, cull)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].cull = cull
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", cull)
end
end

------------------------------------------------------------------------------------------------------------------
-- helper functions
------------------------------------------------------------------------------------------------------------------
function findEmptyEntry(inTable)
for index,value in ipairs(inTable) do
if not value.enabled then
return index
end
end
return #inTable + 1
end

function vec2Angle(x, y)
local t = -(math.atan2(x, y))
if t < 0 then t = t + (2 * math.pi) end
return t
end


To jest strona klienta..
M?g?by? pom?c to rozgry??? Bo jakos ze mna to nie chce wsp??pracowac...

Spr?buj zmieni? resourceRoot na root, je?li nie to poka? ewentualne b??dy z /debugscript 3

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-20, 17:01


Matikmontana

Modern Stories






Wiek: 22
Na forum: 2473 dni
Posty: 423
Nick w MP: Mazeusz*

Piwa: 1015

Respekt: 130
Respekt: 130

Ostrzeżeń: 60%
Nie wykluczone ?e jest jaki? inny skrypt kt?ry w??cza ten radar ponownie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-21, 00:13


eksdi123







Wiek: 25
Na forum: 1982 dni
Posty: 26
Nick w MP: Kupson



Respekt: 50

"Alanowskyy" napisał/a:

"eksdi123" napisał/a:

Kod:

local radarTab = {billboard = nil, quad = nil, renderTarget = nil, tiles = {}, blips = {}, custom = {tiles = {}, blips = {}, materials = {}}, enabled = false}
local scx, scy = guiGetScreenSize()

-- window settings
local windowSize = {200, 125}
local blipSize = 0.5

windowSize = {windowSize[1] * (scy / 600) , windowSize[2] * (scy / 600)}
local windowStart = {scx * 0.012, scy * 0.97 - windowSize[2]}
--blipSize = blipSize * (scy / 600)
local addSize = 10 * (scy / 600)
local borderDist = 0.1
local cullDist = 1500

-- color settings
local healthOkay = {102, 204, 102}
local healthBad = {200, 200, 0}
local healthCritical = {200, 0, 0}
local armorColor1 = tocolor(0, 102, 255, 100)
local oxygenColor1 = tocolor(255, 255, 0, 100)
local armorColor2 = tocolor(0, 102, 255, 190)
local oxygenColor2 = tocolor(255, 255, 0, 190)

-- 3D map settings
local backgroundColor = tocolor(125, 168, 210, 255) -- map background
local renderTargetColor = tocolor(255, 255, 255, 190) -- map tiles, zones
local rectangleColor = tocolor(0, 0, 0, 175)
local camHeight = {255, 455} -- #1 for ped #2 for veh
local camAngle = {-90, -55} -- #1 for ped #2 for veh
local arrowSize = 35 -- player arrow

-- don't touch
local clipDistance = {0.3, 4500}
local fieldOfView = math.rad(80)


------------------------------------------------------------------------------------------------------------------
-- onClientResourceStart/Stop
------------------------------------------------------------------------------------------------------------------
addEventHandler("onClientResourceStart", resourceRoot, function()
setPlayerHudComponentVisible("radar", false)
radarTab.blip = nil
radarTab.quad = nil
radarTab.renderTarget = nil
radarTab.enabled = createTileTextures() and createBlipTextures()
radarTab.renderTarget = dxCreateRenderTarget(windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, true)
if radarTab.enabled and radarTab.renderTarget then
radarTab.blip = dxCreateShader("fx/image2D_manual_blip.fx")
radarTab.quad = dxCreateShader("fx/image3D_manual.fx")
if radarTab.quad and radarTab.blip then
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0 )
dxSetShaderValue( radarTab.quad, "sElementPosition", 0, 0, 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", 0, 0 )
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
dxSetShaderValue( radarTab.quad, "sFov", fieldOfView )
dxSetShaderValue( radarTab.quad, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( radarTab.quad, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( radarTab.quad, "sScrRes", scx, scy )
dxSetShaderValue( radarTab.quad, "bIsArrow", false )

dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0 )
dxSetShaderValue( radarTab.blip, "sElementPosition", 0, 0, 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", 0, 0 )
dxSetShaderValue( radarTab.blip, "sFov", fieldOfView )
dxSetShaderValue( radarTab.blip, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( radarTab.blip, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( radarTab.blip, "sScrRes", scx, scy )
dxSetShaderValue( radarTab.blip, "bIsBorder", false )
dxSetShaderValue( radarTab.blip, "fBorderDist", borderDist )

radarTab.enabled = true
else
outputChatBox('Radar3D: Create shader fail')
radarTab.enabled = false
end
else
outputChatBox('Radar3D: Create tile textures fail')
destroyTileTextures()
end
collectgarbage("setpause",100)
end
)

addEventHandler("onClientResourceStop", resourceRoot, function()
setPlayerHudComponentVisible("radar", true)
destroyTileTextures()
destroyBlipTextures()
if radarTab.quad then
destroyElement(radarTab.quad)
end
if radarTab.blip then
destroyElement(radarTab.blip)
end
if isElement(radarTab.renderTarget) then
destroyElement(radarTab.renderTarget)
end
end
)

------------------------------------------------------------------------------------------------------------------
-- render 3dRadar
------------------------------------------------------------------------------------------------------------------
local timeValue = 0
local tickCount = getTickCount()
addEventHandler("onClientPreRender", root, function()
if tickCount + 25 > getTickCount() then return end
tickCount = getTickCount()
if isPedInVehicle ( localPlayer ) and timeValue < 1 then
timeValue = timeValue + 0.025
end
if not isPedInVehicle ( localPlayer ) and timeValue > 0 then
timeValue = timeValue - 0.025
end
end
)

-- count those only once
-- hud
local hudPos = {windowStart[1] - math.floor(windowSize[1] / 100) * 2, windowStart[2] - math.floor(windowSize[2] / 75) * 2}
local hudSiz = {windowSize[1] + math.floor(windowSize[1] / 100) * 4, windowSize[2] + math.floor(windowSize[2] / 75) * (4 + 5)}
local rad1Pos = {windowStart[1], windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local rad2Pos = {windowStart[1] + math.floor(windowSize[1] / 2 + windowSize[1] / 200), windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local radSiz = {math.floor(windowSize[1] / 2 - windowSize[1] / 400), math.floor(windowSize[2] / 75) * 4}

addEventHandler("onClientRender", root, function()
if not radarTab.enabled then return end
-- draw stats and stuff
--dxDrawRectangle(hudPos[1], hudPos[2], hudSiz[1], hudSiz[2], rectangleColor)

local health = math.max(math.min(getElementHealth(localPlayer) / (0.232018558500192 * getPedStat(localPlayer, 24) -32.018558511152), 1), 0)
local armor = math.max(math.min(getPedArmor(localPlayer) / 100, 1), 0)
local oxygen = math.max(math.min(getPedOxygenLevel(localPlayer) / (1.5 * getPedStat(localPlayer, 225) + 1000), 1), 0)

local r, g, b
if health >= 0.25 then
r, g, b = interpolateBetween(healthBad[1], healthBad[2], healthBad[3], healthOkay[1], healthOkay[2], healthOkay[3], math.floor(health*20)/10, "InOutQuad")
else
r, g, b = interpolateBetween(healthCritical[1], healthCritical[2], healthCritical[3], healthBad[1], healthBad[2], healthBad[3], math.floor(health*20)/10, "InOutQuad")
end

local col = tocolor(r, g, b, 190)
local bg = tocolor(r, g, b, 100)

--dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1], radSiz[2], bg)
--dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1] * health, radSiz[2], col)

if alwaysRenderOxygen or (oxygen < 1 or isElementInWater(localPlayer)) then
local rad3PosX = windowStart[1] + math.floor(windowSize[1] * 0.75 + windowSize[1] / 150)
local rad3SizX = math.floor(windowSize[1] / 4 - windowSize[1] / 200)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], rad3SizX, radSiz[2], armorColor1)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * rad3SizX, radSiz[2], armorColor2)
--dxDrawRectangle(rad3PosX, rad2Pos[2], rad3SizX, radSiz[2], oxygenColor1)
--dxDrawRectangle(rad3PosX, rad2Pos[2], oxygen * rad3SizX, radSiz[2], oxygenColor2)
else
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], radSiz[1], radSiz[2], armorColor1)
--dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * radSiz[1], radSiz[2], armorColor2)
end

-- switch to 3d map render target
dxSetRenderTarget(radarTab.renderTarget)
dxDrawRectangle(0, 0, scx, scy, backgroundColor)

-- get camera matrix
local camMat = getElementMatrix(getCamera())

-- calculate radar view
local altPosZ = camHeight[1] + ((camHeight[2] - camHeight[1]) * (timeValue + 0.05))
local altRotX = math.rad(camAngle[1] - ((camAngle[1] - camAngle[2]) * (timeValue + 0.05)))
local altRotZ = vec2Angle(camMat[2][1], camMat[2][2])

-- create a matrix based on above
local thisPos = camMat[4]
if isElement(localPlayer) then
if isElementStreamedIn(localPlayer) then
thisPos[1], thisPos[2] = getElementPosition(localPlayer)
end
end

dxSetShaderValue( radarTab.quad, "bIsArrow", false )
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0)
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )

dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0)

dxSetShaderValue( radarTab.quad, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.quad, "sCameraInputRotation", altRotX, 0, altRotZ )

dxSetShaderValue( radarTab.blip, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.blip, "sCameraInputRotation", altRotX, 0, altRotZ )

local plDimension = getElementDimension(localPlayer)
local plInterior = getElementInterior(localPlayer)

-- draw map tiles
if plInterior == 0 then
for x=0, 5, 1 do
for y=0, 5, 1 do
if ( math.abs(radarTab.tiles[x][y].position[1] - thisPos[1]) < cullDist and math.abs(radarTab.tiles[x][y].position[2] - thisPos[2]) < cullDist ) then

dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, radarTab.tiles[x][y].shader, 0, 0, 0 )
end
end
end
end

for k, v in ipairs(radarTab.custom.tiles) do
if v.enabled then
if plInterior == v.interior then
if ( math.abs(v.position[1] - thisPos[1]) < cullDist and math.abs(v.position[2] - thisPos[2]) < cullDist ) then
if isElement(v.texture) then

dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
end
end
end
end
end

dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[64] )

-- draw radar areas
for k, v in ipairs(getElementsByType("radararea")) do
local raPos = {getElementPosition(v)}
local raSiz = {getRadarAreaSize(v)}

if getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then
local bcR, bcG, bcB, bcA = getRadarAreaColor(v)
bcA = math.min(bcA, 200)

dxSetShaderValue( radarTab.quad, "sElementPosition", raPos[1] + raSiz[1] / 2, raPos[2] + raSiz[2] / 2, 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", raSiz[1], raSiz[2] )
dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )
end
end

for k, v in ipairs(radarTab.custom.materials) do
if v.enabled then
if plInterior == v.interior then
if ( math.abs(v.position[1] - thisPos[1]) < cullDist and math.abs(v.position[2] - thisPos[2]) < cullDist ) then
if isElement(v.texture) then

dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
end
end
end
end
end

-- skip to original RT
dxSetRenderTarget()

dxDrawImageSection( windowStart[1], windowStart[2], windowSize[1], windowSize[2],
addSize, addSize, windowSize[1], windowSize[2], radarTab.renderTarget, 0, 0, 0, renderTargetColor )

-- set and clear map RT
dxSetRenderTarget( radarTab.renderTarget, true )

dxSetShaderValue( radarTab.blip, "bIsBorder", false )
local plaPos = {getElementPosition(localPlayer)}

-- draw blips
for k, v in ipairs(getElementsByType("blip")) do
local bliPos = {getElementPosition(v)}
if bliPos[1] and bliPos[2] then
local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
if actualDist <= getBlipVisibleDistance(v) and getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then
local bid = getElementData(v, "customIcon") or getBlipIcon(v)
local _, _, _, bcA = getBlipColor(v)
local bcR, bcG, bcB = 255, 255, 255
if getBlipIcon(v) == 0 then
bcR, bcG, bcB = getBlipColor(v)
end
local bS = getBlipSize(v) * 0.75

dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[bid] )
dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )
end
end
end

-- draw custom blips
for k, v in ipairs(radarTab.custom.blips) do
if v.enabled then
local bliPos = v.position
if bliPos[1] and bliPos[2] then
local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
local maxDist = v.distance
if actualDist <= maxDist and v.dimension == plDimension and v.interior == plInterior then
if isElement(v.texture) then
local bS = v.size * 0.75

dxSetShaderValue( radarTab.blip, "sTexColor", v.texture )
dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, v.color )
end
end
end
end
end

-- get arrow texture
dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[2] )

-- get ped arrow yaw
local plVec = getElementMatrix(localPlayer)[2]
local plAngle = vec2Angle(plVec[1], plVec[2])
dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, plAngle )

-- set the remaining renderer stuff for arrow
dxSetShaderValue( radarTab.quad, "sElementPosition", plaPos[1], plaPos[2], 0 )
dxSetShaderValue( radarTab.quad, "sElementSize", arrowSize, arrowSize )
dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
dxSetShaderValue( radarTab.quad, "bIsArrow", true )
dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0 )

dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[4] )
dxSetShaderValue( radarTab.blip, "sElementPosition", thisPos[1], thisPos[2] + 3000, 0 )
dxSetShaderValue( radarTab.blip, "sElementSize", blipSize * 2.5, blipSize * 2.5 )
dxSetShaderValue( radarTab.blip, "bIsBorder", true )
dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0 )

-- skip to original RT
dxSetRenderTarget()
dxDrawImage(windowStart[1], windowStart[2], windowSize[1], windowSize[2], "tex/radar_frame.png")
-- draw the player arrow
dxDrawImage(windowStart[1] - addSize, windowStart[2] - addSize, windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, radarTab.renderTarget, 0, 0, 0)
end
)

------------------------------------------------------------------------------------------------------------------
-- tile textures
------------------------------------------------------------------------------------------------------------------
function setTileShaderValues(this)
dxSetShaderValue( this.shader, "sTexColor", this.texture )
dxSetShaderValue( this.shader, "sElementRotation", this.rotation )
dxSetShaderValue( this.shader, "sElementPosition", this.position )
dxSetShaderValue( this.shader, "sElementSize", this.size )
dxSetShaderValue( this.shader, "sFov", fieldOfView )
dxSetShaderValue( this.shader, "sClip", clipDistance[1], clipDistance[2] )
dxSetShaderValue( this.shader, "sAspect", windowSize[2] / windowSize[1] )
dxSetShaderValue( this.shader, "sScrRes", scx, scy )

end

function createTileTextures()
local isTexValid = true
radarTab.tiles = {}
for x=0, 5, 1 do
radarTab.tiles[x] = {}
for y=0, 5, 1 do
radarTab.tiles[x][y] = {}
radarTab.tiles[x][y].position = {-3000 + 1000 * x + 500, 3000 - 1000 * y - 500, 0}
radarTab.tiles[x][y].size = {1000, 1000}
radarTab.tiles[x][y].rotation = {0, 0, 0}
radarTab.tiles[x][y].texture = dxCreateTexture("tex/radar/tile_"..y.."_"..x..".dds")
radarTab.tiles[x][y].shader = dxCreateShader("fx/image3D_manual_quad.fx")
isTexValid = isElement(radarTab.tiles[x][y].texture) and isElement(radarTab.tiles[x][y].shader) and isTexValid
if isTexValid then
setTileShaderValues(radarTab.tiles[x][y])
end
end
end
return isTexValid
end

function destroyTileTextures()
local isTexValid = true
for x=0, 5, 1 do
for y=0, 5, 1 do
if isElement(radarTab.tiles[x][y].texture) then
isTexValid = destroyElement(radarTab.tiles[x][y].texture) and destroyElement(radarTab.tiles[x][y].shader) and isTexValid
end
end
end
return isTexValid
end

function createBlipTextures()
local isTexValid = true
for x=0, 65, 1 do
radarTab.blips[x] = dxCreateTexture("tex/blip/"..x..".png", "dxt5", false, "clamp")
isTexValid = isElement(radarTab.blips[x]) and isTexValid
end
return isTexValid
end

function destroyBlipTextures()
local isTexValid = true
for x=0, 65, 1 do
if isElement(radarTab.blips[x]) then
isTexValid = destroyElement(radarTab.blips[x]) and isTexValid
end
end
return isTexValid
end

------------------------------------------------------------------------------------------------------------------
-- exports handling
------------------------------------------------------------------------------------------------------------------
customBlip = {}
function customBlip.create(posX, posY, posZ, tTexture, size, colR, colG, colB, colA, visibleDistance)
local w = findEmptyEntry(radarTab.custom.blips)
radarTab.custom.blips[w] = {}
radarTab.custom.blips[w].texture = tTexture
radarTab.custom.blips[w].position = {posX, posY, posZ}
radarTab.custom.blips[w].rotation = {0, 0, 0}
radarTab.custom.blips[w].size = size
radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.blips[w].distance = visibleDistance
radarTab.custom.blips[w].interior = 0
radarTab.custom.blips[w].dimension = 0

if isElement(radarTab.custom.blips[w].texture) then
radarTab.custom.blips[w].shader = dxCreateShader("fx/image2D_manual_blip.fx.fx")
if isElement(radarTab.custom.blips[w].shader) then
setTileShaderValues(radarTab.custom.blips[w])
radarTab.custom.blips[w].enabled = true
return w
end
end
radarTab.custom.blips[w].enabled = false
return false
end

function customBlip.destroy(w)
radarTab.custom.blips[w].enabled = false
if isElement(radarTab.custom.blips[w].shader) then
destroyElement(radarTab.custom.blips[w].shader)
end
radarTab.custom.blips[w].tTexture = nil
end

function customBlip.setTexture(w, tTexture)
radarTab.custom.blips[w].tTexture = tTexture
end

function customBlip.setPosition(w, posX, posY, posZ)
radarTab.custom.blips[w].position = {posX, posY, posZ}
end

function customBlip.setColor(w, colR, colG, colB, colA)
radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
end

function customBlip.setSize(w, size)
radarTab.custom.blips[w].size = size
end

function customBlip.setDistance(w, dist)
radarTab.custom.blips[w].distance = dist
end

function customBlip.setInterior(w, interior)
radarTab.custom.blips[w].interior = interior
end

function customBlip.setDimension(w, dimension)
radarTab.custom.blips[w].dimension = dimension
end

customTile = {}
function customTile.create(tTexture, posX, posY, posZ, rotX, rotY, rotZ, sizX, sizY, colR, colG, colB, colA , isBill)
local w = findEmptyEntry(radarTab.custom.tiles)
radarTab.custom.tiles[w] = {}
radarTab.custom.tiles[w].texture = tTexture
radarTab.custom.tiles[w].position = {posX, posY, posZ}
radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.tiles[w].size = {sizX, sizY}
radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.tiles[w].isBillboard = isBill
radarTab.custom.tiles[w].cull = 2
radarTab.custom.tiles[w].interior = 0

if isElement(radarTab.custom.tiles[w].texture) then
radarTab.custom.tiles[w].shader = dxCreateShader("fx/image3D_manual.fx")
if isElement(radarTab.custom.tiles[w].shader) then
setTileShaderValues(radarTab.custom.tiles[w])
dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", 2)
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)
dxSetShaderValue(radarTab.custom.tiles[w].shader, "bIsArrow", false)
radarTab.custom.tiles[w].enabled = true
return w
end
end
radarTab.custom.tiles[w].enabled = false
return false
end

function customTile.destroy(w)
radarTab.custom.tiles[w].enabled = false
if isElement(radarTab.custom.tiles[w].shader) then
destroyElement(radarTab.custom.tiles[w].shader)
end
radarTab.custom.tiles[w].tTexture = nil
end

function customTile.setTexture(w, tTexture)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].tTexture = tTexture
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sTexColor", tTexture)
end
end

function customTile.setPosition(w, posX, posY, posZ)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].position = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementPosition", posX, posY, posZ)
end
end

function customTile.setRotation(w, rotX, rotY, rotZ)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementRotation", rotX, rotY, rotZ)
end
end

function customTile.setColor(w, colR, colG, colB, colA)
radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
end

function customTile.setSize(w, sizeX, sizeY)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].size = {sizeX, sizeY}
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementSize", sizeX, sizeY)
end
end

function customTile.setInterior(w, interior)
radarTab.custom.tiles[w].interior = interior
end

function customTile.setBillboard(w, isBill)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].isBillboard = isBill
dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)
end
end

function customTile.setCullMode(w, cull)
if radarTab.custom.tiles[w].enabled then
radarTab.custom.tiles[w].cull = cull
dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", cull)
end
end

customMaterial = {}
function customMaterial.createLine3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, width, colR, colG, colB, colA, isBill, isSoft)
local w = findEmptyEntry(radarTab.custom.materials)
radarTab.custom.materials[w] = {}
if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
else radarTab.custom.materials[w].texture = radarTab.blips[64]
end
radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
radarTab.custom.materials[w].position3 = {0, 0, 0}
radarTab.custom.materials[w].position4 = {0, 0, 0}
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.materials[w].size = {width, 0}
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.materials[w].isBillboard = isBill
radarTab.custom.materials[w].cull = 1
radarTab.custom.materials[w].interior = 0

if isElement(radarTab.custom.materials[w].texture) then
radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_line.fx")
if isElement(radarTab.custom.materials[w].shader) then
setTileShaderValues(radarTab.custom.materials[w])
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)
radarTab.custom.materials[w].enabled = true
return w
end
end
radarTab.custom.materials[w].enabled = false
return false
end

function customMaterial.createBezier3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z, width, colR, colG, colB, colA, isBill, isSoft)
local w = findEmptyEntry(radarTab.custom.materials)
radarTab.custom.materials[w] = {}
if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
else radarTab.custom.materials[w].texture = radarTab.blips[64]
end
radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
radarTab.custom.materials[w].position3 = {pos3X, pos3Y, pos3Z}
radarTab.custom.materials[w].position4 = {pos4X, pos4Y, pos4Z}
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
radarTab.custom.materials[w].size = {width, 0}
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
radarTab.custom.materials[w].isBillboard = isBill
radarTab.custom.materials[w].cull = 1
radarTab.custom.materials[w].interior = 0

if isElement(radarTab.custom.materials[w].texture) then
radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_bezier.fx")
if isElement(radarTab.custom.materials[w].shader) then
setTileShaderValues(radarTab.custom.materials[w])
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", pos3X, pos3Y, pos3Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", pos4X, pos4Y, pos4Z)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
local pointDist = getDistanceBetweenPoints3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z) +
getDistanceBetweenPoints3D(pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z) +
getDistanceBetweenPoints3D(pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z)
dxSetShaderTessellation(radarTab.custom.materials[w].shader, 1, math.ceil(pointDist))
dxSetShaderValue(radarTab.custom.materials[w].shader, "sTesselation", math.ceil(pointDist))
radarTab.custom.materials[w].enabled = true
return w
end
end
radarTab.custom.materials[w].enabled = false
return false
end

function customMaterial.destroy(w)
radarTab.custom.materials[w].enabled = false
if isElement(radarTab.custom.materials[w].shader) then
destroyElement(radarTab.custom.materials[w].shader)
end
radarTab.custom.materials[w].tTexture = nil
end

function customMaterial.setTexture(w, tTexture)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].tTexture = tTexture
dxSetShaderValue( radarTab.custom.materials[w].shader, "sTexColor", tTexture)
end
end

function customMaterial.setPosition(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementPosition", posX, posY, posZ)
end
end

function customMaterial.setPosition1(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position1 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", posX, posY, posZ)
end
end

function customMaterial.setPosition2(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position2 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", posX, posY, posZ)
end
end

function customMaterial.setPosition3(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position3 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", posX, posY, posZ)
end
end

function customMaterial.setPosition4(w, posX, posY, posZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].position4 = {posX, posY, posZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", posX, posY, posZ)
end
end

function customMaterial.setRotation(w, rotX, rotY, rotZ)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementRotation", rotX, rotY, rotZ)
end
end

function customMaterial.setColor(w, colR, colG, colB, colA)
radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
end

function customMaterial.setSize(w, sizeX, sizeY)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].size = {sizeX, sizeY}
dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementSize", sizeX, sizeY)
dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", sizeX)
end
end

function customMaterial.setInterior(w, interior)
radarTab.custom.materials[w].interior = interior
end

function customMaterial.setBillboard(w, isBill)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].isBillboard = isBill
dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
end
end

function customMaterial.setCullMode(w, cull)
if radarTab.custom.materials[w].enabled then
radarTab.custom.materials[w].cull = cull
dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", cull)
end
end

------------------------------------------------------------------------------------------------------------------
-- helper functions
------------------------------------------------------------------------------------------------------------------
function findEmptyEntry(inTable)
for index,value in ipairs(inTable) do
if not value.enabled then
return index
end
end
return #inTable + 1
end

function vec2Angle(x, y)
local t = -(math.atan2(x, y))
if t < 0 then t = t + (2 * math.pi) end
return t
end


To jest strona klienta..
M?g?by? pom?c to rozgry??? Bo jakos ze mna to nie chce wsp??pracowac...

Spr?buj zmieni? resourceRoot na root, je?li nie to poka? ewentualne b??dy z /debugscript 3


W kt?rej linijce... ?

[ Dodano: 2021-08-21, 00:15 ]
[quote="Matikmontana"]Nie wykluczone ?e jest jaki? inny skrypt kt?ry w??cza ten radar ponownie.[/quote]

No ale mia?em inny dobrze dzia?ajacy radar po czym znalaz?em inny i go wgra?em no ale po zalogowaniu stary si? pokry? z tym...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-21, 08:06


N0TH1NG

Mod-Team






Wiek: 20
Na forum: 2705 dni
Posty: 286
Nick w MP: N0TH1NG

Piwa: 626

Respekt: 830
Respekt: 830Respekt: 830

"eksdi123" napisał/a:

W kt?rej linijce... ?

local radarTab = {billboard nilquad nilrenderTarget niltiles = {}, blips = {}, custom = {tiles = {}, blips = {}, materials = {}}, enabled false}
local scxscy guiGetScreenSize()

-- window settings
local windowSize = {200125}
local blipSize 0.5

windowSize = {windowSize[1] * (scy 600) , windowSize[2] * (scy 600)}
local windowStart = {scx 0.012scy 0.97 windowSize[2]}
--blipSize blipSize * (scy 600)
local addSize 10 * (scy 600)
local borderDist 0.1
local cullDist 1500

-- color settings
local healthOkay = {102204102}
local healthBad = {2002000}
local healthCritical = {20000}
local armorColor1 tocolor(0102255100)
local oxygenColor1 tocolor(2552550100)
local armorColor2 tocolor(0102255190)
local oxygenColor2 tocolor(2552550190)

-- 3D map settings
local backgroundColor tocolor(125168210255) -- map background
local renderTargetColor tocolor(255255255190) -- map tileszones
local rectangleColor tocolor(000175)
local camHeight = {255455} -- #1 for ped #2 for veh
local camAngle = {-90, -55} -- #1 for ped #2 for veh
local arrowSize 35 -- player arrow

-- don't touch
local clipDistance = {0.3, 4500}
local fieldOfView = math.rad(80)


------------------------------------------------------------------------------------------------------------------
-- onClientResourceStart/Stop
------------------------------------------------------------------------------------------------------------------
addEventHandler("onClientResourceStart", root, function()
    setPlayerHudComponentVisible("radar", false)
    radarTab.blip = nil
    radarTab.quad = nil
    radarTab.renderTarget = nil
    radarTab.enabled = createTileTextures() and createBlipTextures()
    radarTab.renderTarget = dxCreateRenderTarget(windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, true)
    if radarTab.enabled and radarTab.renderTarget then
        radarTab.blip = dxCreateShader("fx/image2D_manual_blip.fx")
        radarTab.quad = dxCreateShader("fx/image3D_manual.fx")
        if radarTab.quad and radarTab.blip then
            dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0 )
            dxSetShaderValue( radarTab.quad, "sElementPosition", 0, 0, 0 )
            dxSetShaderValue( radarTab.quad, "sElementSize", 0, 0 )    
            dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
            dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
            dxSetShaderValue( radarTab.quad, "sFov", fieldOfView )
            dxSetShaderValue( radarTab.quad, "sClip", clipDistance[1], clipDistance[2] )
            dxSetShaderValue( radarTab.quad, "sAspect", windowSize[2] / windowSize[1] )
            dxSetShaderValue( radarTab.quad, "sScrRes", scx, scy )
            dxSetShaderValue( radarTab.quad, "bIsArrow", false )
            
            dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0 )
            dxSetShaderValue( radarTab.blip, "sElementPosition", 0, 0, 0 )
            dxSetShaderValue( radarTab.blip, "sElementSize", 0, 0 )    
            dxSetShaderValue( radarTab.blip, "sFov", fieldOfView )
            dxSetShaderValue( radarTab.blip, "sClip", clipDistance[1], clipDistance[2] )
            dxSetShaderValue( radarTab.blip, "sAspect", windowSize[2] / windowSize[1] )
            dxSetShaderValue( radarTab.blip, "sScrRes", scx, scy )
            dxSetShaderValue( radarTab.blip, "bIsBorder", false )
            dxSetShaderValue( radarTab.blip, "fBorderDist", borderDist )
            
            radarTab.enabled = true
        else
            outputChatBox('Radar3DCreate shader fail')
            radarTab.enabled = false
        end
    else
        outputChatBox('Radar3DCreate tile textures fail')
        destroyTileTextures()
    end
    collectgarbage("setpause",100)
end
)

addEventHandler("onClientResourceStop", root, function()
    setPlayerHudComponentVisible("radar", true)
    destroyTileTextures()
    destroyBlipTextures()
    if radarTab.quad then
        destroyElement(radarTab.quad)
    end
    if radarTab.blip then
        destroyElement(radarTab.blip)
    end
    if isElement(radarTab.renderTarget) then
        destroyElement(radarTab.renderTarget)
    end
end
)

------------------------------------------------------------------------------------------------------------------
-- render 3dRadar
------------------------------------------------------------------------------------------------------------------
local timeValue = 0
local tickCount = getTickCount()
addEventHandler("onClientPreRender", root, function()
    if tickCount + 25 > getTickCount() then return end
    tickCount = getTickCount()
    if isPedInVehicle ( localPlayer ) and timeValue < 1 then
        timeValue = timeValue + 0.025
    end
    if not isPedInVehicle ( localPlayer ) and timeValue > 0 then
        timeValue = timeValue - 0.025
    end
end
)

-- count those only once
-- hud
local hudPos = {windowStart[1] - math.floor(windowSize[1] / 100) * 2, windowStart[2] - math.floor(windowSize[2] / 75) * 2}
local hudSiz = {windowSize[1] + math.floor(windowSize[1] / 100) * 4, windowSize[2] + math.floor(windowSize[2] / 75) * (4 + 5)}
local rad1Pos = {windowStart[1], windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local rad2Pos = {windowStart[1] + math.floor(windowSize[1] / 2 + windowSize[1] / 200), windowStart[2] + windowSize[2] + math.floor((windowSize[2] / 75) * 1.5)}
local radSiz = {math.floor(windowSize[1] / 2 - windowSize[1] / 400), math.floor(windowSize[2] / 75) *  4}
    
addEventHandler("onClientRender", root, function()
    if not radarTab.enabled then return end
    -- draw stats and stuff
    --dxDrawRectangle(hudPos[1], hudPos[2], hudSiz[1], hudSiz[2], rectangleColor)

    local health = math.max(math.min(getElementHealth(localPlayer) / (0.232018558500192 * getPedStat(localPlayer, 24) -32.018558511152), 1), 0)
    local armor = math.max(math.min(getPedArmor(localPlayer) / 100, 1), 0)
    local oxygen = math.max(math.min(getPedOxygenLevel(localPlayer) / (1.5 * getPedStat(localPlayer, 225) + 1000), 1), 0)
    
    local r, g, b
    if health >= 0.25 then
        r, g, b = interpolateBetween(healthBad[1], healthBad[2], healthBad[3], healthOkay[1], healthOkay[2], healthOkay[3], math.floor(health*20)/10, "InOutQuad")
    else
        r, g, b = interpolateBetween(healthCritical[1], healthCritical[2], healthCritical[3], healthBad[1], healthBad[2], healthBad[3], math.floor(health*20)/10, "InOutQuad")
    end
    
    local col = tocolor(r, g, b, 190)
    local bg = tocolor(r, g, b, 100)

    --dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1], radSiz[2], bg)
    --dxDrawRectangle(rad1Pos[1], rad1Pos[2], radSiz[1] * health, radSiz[2], col)

    if alwaysRenderOxygen or (oxygen < 1 or isElementInWater(localPlayer)) then
        local rad3PosX = windowStart[1] + math.floor(windowSize[1] * 0.75 + windowSize[1] / 150)
        local rad3SizX = math.floor(windowSize[1] / 4 - windowSize[1] / 200)
        --dxDrawRectangle(rad2Pos[1], rad2Pos[2], rad3SizX, radSiz[2], armorColor1)
        --dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * rad3SizX, radSiz[2], armorColor2)
        --dxDrawRectangle(rad3PosX, rad2Pos[2], rad3SizX, radSiz[2], oxygenColor1)
        --dxDrawRectangle(rad3PosX, rad2Pos[2], oxygen * rad3SizX, radSiz[2], oxygenColor2)
    else
        --dxDrawRectangle(rad2Pos[1], rad2Pos[2], radSiz[1], radSiz[2], armorColor1)
        --dxDrawRectangle(rad2Pos[1], rad2Pos[2], armor * radSiz[1], radSiz[2], armorColor2)
    end    
    
    -- switch to 3d map render target
    dxSetRenderTarget(radarTab.renderTarget)
    dxDrawRectangle(0, 0, scx, scy, backgroundColor)
    
    -- get camera matrix
    local camMat = getElementMatrix(getCamera())

    -- calculate radar view
    local altPosZ = camHeight[1] + ((camHeight[2] - camHeight[1]) * (timeValue + 0.05))
    local altRotX = math.rad(camAngle[1] - ((camAngle[1] - camAngle[2]) * (timeValue + 0.05)))
    local altRotZ = vec2Angle(camMat[2][1], camMat[2][2])

    -- create a matrix based on above
    local thisPos = camMat[4]
    if isElement(localPlayer) then
        if isElementStreamedIn(localPlayer) then
            thisPos[1], thisPos[2] = getElementPosition(localPlayer)
        end
    end

    dxSetShaderValue( radarTab.quad, "bIsArrow", false )
    dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, 0)
    dxSetShaderValue( radarTab.quad, "sIsBillboard", false )    

    dxSetShaderValue( radarTab.blip, "sElementRotation", 0, 0, 0)    
    
    dxSetShaderValue( radarTab.quad, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
    dxSetShaderValue( radarTab.quad, "sCameraInputRotation", altRotX, 0, altRotZ )
    
    dxSetShaderValue( radarTab.blip, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
    dxSetShaderValue( radarTab.blip, "sCameraInputRotation", altRotX, 0, altRotZ )
    
    local plDimension = getElementDimension(localPlayer)
    local plInterior = getElementInterior(localPlayer)
    
    -- draw map tiles    
    if plInterior == 0 then    
        for x=0, 5, 1 do
            for y=0, 5, 1 do
                if ( math.abs(radarTab.tiles[x][y].position[1] - thisPos[1]) < cullDist and  math.abs(radarTab.tiles[x][y].position[2] - thisPos[2]) < cullDist ) then        

                    dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
                    dxSetShaderValue( radarTab.tiles[x][y].shader, "sCameraInputRotation", altRotX, 0, altRotZ )

                    dxDrawImage( 0, 0, scx, scy, radarTab.tiles[x][y].shader, 0, 0, 0 )        
                end
            end
        end
    end

    for k, v in ipairs(radarTab.custom.tiles) do
        if v.enabled then
            if plInterior == v.interior then    
                if ( math.abs(v.position[1] - thisPos[1]) < cullDist and  math.abs(v.position[2] - thisPos[2]) < cullDist ) then
                    if isElement(v.texture) then
                    
                        dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
                        dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

                        dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
                    end
                end
            end
        end
    end
    
    dxSetShaderValue( radarTab.quad, "sIsBillboard", false )            
    dxSetShaderValue( radarTab.quad, "fCullMode", 2 )
    dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[64] )

    -- draw radar areas
    for k, v in ipairs(getElementsByType("radararea")) do
        local raPos = {getElementPosition(v)}
        local raSiz = {getRadarAreaSize(v)}

        if getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then    
            local bcR, bcG, bcB, bcA = getRadarAreaColor(v)
            bcA = math.min(bcA, 200)
            
            dxSetShaderValue( radarTab.quad, "sElementPosition", raPos[1] + raSiz[1] / 2, raPos[2] + raSiz[2] / 2, 0 )
            dxSetShaderValue( radarTab.quad, "sElementSize", raSiz[1], raSiz[2] )
            dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )    
        end
    end
    
    for k, v in ipairs(radarTab.custom.materials) do
        if v.enabled then
            if plInterior == v.interior then    
                if ( math.abs(v.position[1] - thisPos[1]) < cullDist and  math.abs(v.position[2] - thisPos[2]) < cullDist ) then
                    if isElement(v.texture) then
                    
                        dxSetShaderValue( v.shader, "sCameraInputPosition", thisPos[1], thisPos[2], altPosZ )
                        dxSetShaderValue( v.shader, "sCameraInputRotation", altRotX, 0, altRotZ )

                        dxDrawImage( 0, 0, scx, scy, v.shader, 0, 0, 0, v.color )
                    end
                end
            end
        end
    end    

    -- skip to original RT
    dxSetRenderTarget()    
    
    dxDrawImageSection( windowStart[1], windowStart[2], windowSize[1], windowSize[2],
                          addSize, addSize, windowSize[1], windowSize[2], radarTab.renderTarget, 0, 0, 0, renderTargetColor )

    -- set and clear map RT
    dxSetRenderTarget( radarTab.renderTarget, true )

    dxSetShaderValue( radarTab.blip, "bIsBorder", false )
    local plaPos = {getElementPosition(localPlayer)}
    
    -- draw blips
    for k, v in ipairs(getElementsByType("blip")) do
        local bliPos = {getElementPosition(v)}
        if bliPos[1] and bliPos[2] then
            local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
            if actualDist <= getBlipVisibleDistance(v) and getElementDimension(v) == plDimension and getElementInterior(v) == plInterior then
                local bid = getElementData(v, "customIcon") or getBlipIcon(v)        
                local _, _, _, bcA = getBlipColor(v)
                local bcR, bcG, bcB = 255, 255, 255
                if getBlipIcon(v) == 0 then
                    bcR, bcG, bcB = getBlipColor(v)
                end
                local bS = getBlipSize(v) * 0.75

                dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[bid] )            
                dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
                dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
                dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, tocolor(bcR, bcG, bcB, bcA) )    
            end
        end
    end

    -- draw custom blips
    for k, v in ipairs(radarTab.custom.blips) do
        if v.enabled then
            local bliPos = v.position
            if bliPos[1] and bliPos[2] then
                local actualDist = getDistanceBetweenPoints2D(plaPos[1], plaPos[2], bliPos[1], bliPos[2])
                local maxDist = v.distance
                if actualDist <= maxDist and v.dimension == plDimension and v.interior == plInterior then
                    if isElement(v.texture) then
                        local bS = v.size * 0.75

                        dxSetShaderValue( radarTab.blip, "sTexColor", v.texture )            
                        dxSetShaderValue( radarTab.blip, "sElementPosition", bliPos[1], bliPos[2], 0 )
                        dxSetShaderValue( radarTab.blip, "sElementSize", bS, bS )
                        dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0, v.color )
                    end
                end
            end
        end
    end

    -- get arrow texture
    dxSetShaderValue( radarTab.quad, "sTexColor", radarTab.blips[2] )
    
    -- get ped arrow yaw
    local plVec = getElementMatrix(localPlayer)[2]
    local plAngle = vec2Angle(plVec[1], plVec[2])
    dxSetShaderValue( radarTab.quad, "sElementRotation", 0, 0, plAngle )

    -- set the remaining renderer stuff for arrow
    dxSetShaderValue( radarTab.quad, "sElementPosition", plaPos[1], plaPos[2], 0 )
    dxSetShaderValue( radarTab.quad, "sElementSize", arrowSize, arrowSize )
    dxSetShaderValue( radarTab.quad, "sIsBillboard", false )
    dxSetShaderValue( radarTab.quad, "bIsArrow", true )
    dxDrawImage( 0, 0, scx, scy, radarTab.quad, 0, 0, 0 )
    
    dxSetShaderValue( radarTab.blip, "sTexColor", radarTab.blips[4] )            
    dxSetShaderValue( radarTab.blip, "sElementPosition", thisPos[1], thisPos[2] + 3000, 0 )
    dxSetShaderValue( radarTab.blip, "sElementSize", blipSize * 2.5, blipSize * 2.5 )
    dxSetShaderValue( radarTab.blip, "bIsBorder", true )
    dxDrawImage( 0, 0, scx, scy, radarTab.blip, 0, 0, 0 )    
    
    -- skip to original RT
    dxSetRenderTarget()    
    dxDrawImage(windowStart[1], windowStart[2], windowSize[1], windowSize[2], "tex/radar_frame.png")
    -- draw the player arrow
    dxDrawImage(windowStart[1] - addSize, windowStart[2] - addSize, windowSize[1] + 2 * addSize, windowSize[2] + 2 * addSize, radarTab.renderTarget, 0, 0, 0)
end
)

------------------------------------------------------------------------------------------------------------------
-- tile textures
------------------------------------------------------------------------------------------------------------------
function setTileShaderValues(this)
    dxSetShaderValue( this.shader, "sTexColor", this.texture )
    dxSetShaderValue( this.shader, "sElementRotation", this.rotation )
    dxSetShaderValue( this.shader, "sElementPosition", this.position )
    dxSetShaderValue( this.shader, "sElementSize", this.size )    
    dxSetShaderValue( this.shader, "sFov", fieldOfView )
    dxSetShaderValue( this.shader, "sClip", clipDistance[1], clipDistance[2] )
    dxSetShaderValue( this.shader, "sAspect", windowSize[2] / windowSize[1] )
    dxSetShaderValue( this.shader, "sScrRes", scx, scy )

end

function createTileTextures()
    local isTexValid = true
    radarTab.tiles = {}
    for x=0, 5, 1 do
        radarTab.tiles[x] = {}
        for y=0, 5, 1 do
            radarTab.tiles[x][y] = {}
            radarTab.tiles[x][y].position = {-3000 + 1000 * x + 500, 3000 - 1000 * y - 500, 0}
            radarTab.tiles[x][y].size = {1000, 1000}
            radarTab.tiles[x][y].rotation = {0, 0, 0}
             radarTab.tiles[x][y].texture = dxCreateTexture("tex/radar/tile_"..y.."_"..x..".dds")
            radarTab.tiles[x][y].shader = dxCreateShader("fx/image3D_manual_quad.fx")
            isTexValid = isElement(radarTab.tiles[x][y].texture) and isElement(radarTab.tiles[x][y].shader) and isTexValid
            if isTexValid then     
                setTileShaderValues(radarTab.tiles[x][y])
            end
        end    
    end
    return isTexValid
end

function destroyTileTextures()
    local isTexValid = true
    for x=0, 5, 1 do
        for y=0, 5, 1 do
            if isElement(radarTab.tiles[x][y].texture) then
                isTexValid = destroyElement(radarTab.tiles[x][y].texture) and destroyElement(radarTab.tiles[x][y].shader) and isTexValid
            end
        end    
    end
    return isTexValid
end

function createBlipTextures()
    local isTexValid = true
    for x=0, 65, 1 do
        radarTab.blips[x] = dxCreateTexture("tex/blip/"..x..".png", "dxt5", false, "clamp")
        isTexValid = isElement(radarTab.blips[x]) and isTexValid
    end
    return isTexValid
end

function destroyBlipTextures()
    local isTexValid = true
    for x=0, 65, 1 do
        if isElement(radarTab.blips[x]) then
            isTexValid = destroyElement(radarTab.blips[x]) and isTexValid
        end
    end
    return isTexValid
end

------------------------------------------------------------------------------------------------------------------
-- exports handling
------------------------------------------------------------------------------------------------------------------
customBlip = {}
function customBlip.create(posX, posY, posZ, tTexture, size, colR, colG, colB, colA, visibleDistance)
    local w = findEmptyEntry(radarTab.custom.blips)
    radarTab.custom.blips[w] = {}
    radarTab.custom.blips[w].texture = tTexture
    radarTab.custom.blips[w].position = {posX, posY, posZ}
    radarTab.custom.blips[w].rotation = {0, 0, 0}
    radarTab.custom.blips[w].size = size
    radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
    radarTab.custom.blips[w].distance = visibleDistance
    radarTab.custom.blips[w].interior = 0
    radarTab.custom.blips[w].dimension = 0
    
    if isElement(radarTab.custom.blips[w].texture) then
        radarTab.custom.blips[w].shader = dxCreateShader("fx/image2D_manual_blip.fx.fx")
        if isElement(radarTab.custom.blips[w].shader) then
            setTileShaderValues(radarTab.custom.blips[w])
            radarTab.custom.blips[w].enabled = true    
            return w
        end
    end
    radarTab.custom.blips[w].enabled = false
    return false
end

function customBlip.destroy(w)
    radarTab.custom.blips[w].enabled = false
    if isElement(radarTab.custom.blips[w].shader) then
        destroyElement(radarTab.custom.blips[w].shader)
    end
    radarTab.custom.blips[w].tTexture = nil    
end

function customBlip.setTexture(w, tTexture)
    radarTab.custom.blips[w].tTexture = tTexture    
end

function customBlip.setPosition(w, posX, posY, posZ)
    radarTab.custom.blips[w].position = {posX, posY, posZ}
end

function customBlip.setColor(w, colR, colG, colB, colA)
    radarTab.custom.blips[w].color = tocolor(colR, colG, colB, colA)
end

function customBlip.setSize(w, size)
    radarTab.custom.blips[w].size = size
end

function customBlip.setDistance(w, dist)
    radarTab.custom.blips[w].distance = dist
end

function customBlip.setInterior(w, interior)
    radarTab.custom.blips[w].interior = interior
end

function customBlip.setDimension(w, dimension)
    radarTab.custom.blips[w].dimension = dimension
end

customTile = {}
function customTile.create(tTexture, posX, posY, posZ, rotX, rotY, rotZ, sizX, sizY, colR, colG, colB, colA , isBill)
    local w = findEmptyEntry(radarTab.custom.tiles)
    radarTab.custom.tiles[w] = {}
    radarTab.custom.tiles[w].texture = tTexture
    radarTab.custom.tiles[w].position = {posX, posY, posZ}
    radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
    radarTab.custom.tiles[w].size = {sizX, sizY}
    radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
    radarTab.custom.tiles[w].isBillboard = isBill
    radarTab.custom.tiles[w].cull = 2
    radarTab.custom.tiles[w].interior = 0
    
    if isElement(radarTab.custom.tiles[w].texture) then
        radarTab.custom.tiles[w].shader = dxCreateShader("fx/image3D_manual.fx")
        if isElement(radarTab.custom.tiles[w].shader) then
            setTileShaderValues(radarTab.custom.tiles[w])
            dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", 2)
            dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)
            dxSetShaderValue(radarTab.custom.tiles[w].shader, "bIsArrow", false)
            radarTab.custom.tiles[w].enabled = true    
            return w
        end
    end
    radarTab.custom.tiles[w].enabled = false
    return false
end

function customTile.destroy(w)
    radarTab.custom.tiles[w].enabled = false
    if isElement(radarTab.custom.tiles[w].shader) then
        destroyElement(radarTab.custom.tiles[w].shader)
    end
    radarTab.custom.tiles[w].tTexture = nil
end

function customTile.setTexture(w, tTexture)
    if radarTab.custom.tiles[w].enabled then
        radarTab.custom.tiles[w].tTexture = tTexture
        dxSetShaderValue(radarTab.custom.tiles[w].shader, "sTexColor", tTexture)
    end
end

function customTile.setPosition(w, posX, posY, posZ)
    if radarTab.custom.tiles[w].enabled then
        radarTab.custom.tiles[w].position = {posX, posY, posZ}
        dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementPosition", posX, posY, posZ)
    end
end

function customTile.setRotation(w, rotX, rotY, rotZ)
    if radarTab.custom.tiles[w].enabled then
        radarTab.custom.tiles[w].rotation = {rotX, rotY, rotZ}
        dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementRotation", rotX, rotY, rotZ)
    end
end

function customTile.setColor(w, colR, colG, colB, colA)
    radarTab.custom.tiles[w].color = tocolor(colR, colG, colB, colA)
end

function customTile.setSize(w, sizeX, sizeY)
    if radarTab.custom.tiles[w].enabled then
        radarTab.custom.tiles[w].size = {sizeX, sizeY}
        dxSetShaderValue(radarTab.custom.tiles[w].shader, "sElementSize", sizeX, sizeY)
    end
end

function customTile.setInterior(w, interior)
    radarTab.custom.tiles[w].interior = interior
end

function customTile.setBillboard(w, isBill)
    if radarTab.custom.tiles[w].enabled then
        radarTab.custom.tiles[w].isBillboard = isBill
        dxSetShaderValue(radarTab.custom.tiles[w].shader, "sIsBillboard", isBill)    
    end
end

function customTile.setCullMode(w, cull)
    if radarTab.custom.tiles[w].enabled then
        radarTab.custom.tiles[w].cull = cull
        dxSetShaderValue(radarTab.custom.tiles[w].shader, "fCullMode", cull)    
    end
end

customMaterial = {}
function customMaterial.createLine3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, width, colR, colG, colB, colA, isBill, isSoft)
    local w = findEmptyEntry(radarTab.custom.materials)
    radarTab.custom.materials[w] = {}
    if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
        else radarTab.custom.materials[w].texture = radarTab.blips[64]
    end
    radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
    radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
    radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
    radarTab.custom.materials[w].position3 = {0, 0, 0}
    radarTab.custom.materials[w].position4 = {0, 0, 0}
    radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
    radarTab.custom.materials[w].size = {width, 0}
    radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
    radarTab.custom.materials[w].isBillboard = isBill
    radarTab.custom.materials[w].cull = 1
    radarTab.custom.materials[w].interior = 0
    
    if isElement(radarTab.custom.materials[w].texture) then
        radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_line.fx")
        if isElement(radarTab.custom.materials[w].shader) then
            setTileShaderValues(radarTab.custom.materials[w])
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)            
            radarTab.custom.materials[w].enabled = true    
            return w
        end
    end
    radarTab.custom.materials[w].enabled = false
    return false
end

function customMaterial.createBezier3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z, width, colR, colG, colB, colA, isBill, isSoft)
    local w = findEmptyEntry(radarTab.custom.materials)
    radarTab.custom.materials[w] = {}
    if isSoft then radarTab.custom.materials[w].texture = radarTab.blips[65]
        else radarTab.custom.materials[w].texture = radarTab.blips[64]
    end
    radarTab.custom.materials[w].position = {pos1X + ((pos2X - pos1X) / 2), pos1Y + ((pos2Y - pos1Y) / 2), pos1Z + ((pos2Z - pos1Z) / 2)}
    radarTab.custom.materials[w].position1 = {pos1X, pos1Y, pos1Z}
    radarTab.custom.materials[w].position2 = {pos2X, pos2Y, pos2Z}
    radarTab.custom.materials[w].position3 = {pos3X, pos3Y, pos3Z}
    radarTab.custom.materials[w].position4 = {pos4X, pos4Y, pos4Z}
    radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
    radarTab.custom.materials[w].size = {width, 0}
    radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
    radarTab.custom.materials[w].isBillboard = isBill
    radarTab.custom.materials[w].cull = 1
    radarTab.custom.materials[w].interior = 0
    
    if isElement(radarTab.custom.materials[w].texture) then
        radarTab.custom.materials[w].shader = dxCreateShader("fx/image3D_manual_bezier.fx")
        if isElement(radarTab.custom.materials[w].shader) then
            setTileShaderValues(radarTab.custom.materials[w])    
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", pos1X, pos1Y, pos1Z)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", pos2X, pos2Y, pos2Z)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", pos3X, pos3Y, pos3Z)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", pos4X, pos4Y, pos4Z)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", width)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", 1)
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)            
            local pointDist = getDistanceBetweenPoints3D(pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z) + 
                getDistanceBetweenPoints3D(pos2X, pos2Y, pos2Z, pos3X, pos3Y, pos3Z) +
                getDistanceBetweenPoints3D(pos3X, pos3Y, pos3Z, pos4X, pos4Y, pos4Z)
            dxSetShaderTessellation(radarTab.custom.materials[w].shader, 1, math.ceil(pointDist))
            dxSetShaderValue(radarTab.custom.materials[w].shader, "sTesselation", math.ceil(pointDist))        
            radarTab.custom.materials[w].enabled = true    
            return w
        end
    end
    radarTab.custom.materials[w].enabled = false
    return false
end

function customMaterial.destroy(w)
    radarTab.custom.materials[w].enabled = false
    if isElement(radarTab.custom.materials[w].shader) then
        destroyElement(radarTab.custom.materials[w].shader)
    end
    radarTab.custom.materials[w].tTexture = nil
end

function customMaterial.setTexture(w, tTexture)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].tTexture = tTexture
        dxSetShaderValue( radarTab.custom.materials[w].shader, "sTexColor", tTexture)
    end
end

function customMaterial.setPosition(w, posX, posY, posZ)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].position = {posX, posY, posZ}
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementPosition", posX, posY, posZ)
    end
end

function customMaterial.setPosition1(w, posX, posY, posZ)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].position1 = {posX, posY, posZ}
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition1", posX, posY, posZ)
    end
end

function customMaterial.setPosition2(w, posX, posY, posZ)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].position2 = {posX, posY, posZ}
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition2", posX, posY, posZ)
    end
end

function customMaterial.setPosition3(w, posX, posY, posZ)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].position3 = {posX, posY, posZ}
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition3", posX, posY, posZ)
    end
end

function customMaterial.setPosition4(w, posX, posY, posZ)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].position4 = {posX, posY, posZ}
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sPointPosition4", posX, posY, posZ)
    end
end

function customMaterial.setRotation(w, rotX, rotY, rotZ)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].rotation = {rotX, rotY, rotZ}
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementRotation", rotX, rotY, rotZ)
    end
end

function customMaterial.setColor(w, colR, colG, colB, colA)
    radarTab.custom.materials[w].color = tocolor(colR, colG, colB, colA)
end

function customMaterial.setSize(w, sizeX, sizeY)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].size = {sizeX, sizeY}
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sElementSize", sizeX, sizeY)
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sWidth", sizeX)
    end
end

function customMaterial.setInterior(w, interior)
    radarTab.custom.materials[w].interior = interior
end

function customMaterial.setBillboard(w, isBill)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].isBillboard = isBill
        dxSetShaderValue(radarTab.custom.materials[w].shader, "sIsBillboard", isBill)    
    end
end

function customMaterial.setCullMode(w, cull)
    if radarTab.custom.materials[w].enabled then
        radarTab.custom.materials[w].cull = cull
        dxSetShaderValue(radarTab.custom.materials[w].shader, "fCullMode", cull)    
    end
end

------------------------------------------------------------------------------------------------------------------
-- helper functions
------------------------------------------------------------------------------------------------------------------
function findEmptyEntry(inTable)
    for index,value in ipairs(inTable) do
        if not value.enabled then
            return index
        end
    end
    return #inTable + 1
end

function vec2Angle(x, y) 
    local t = -(math.atan2(x, y))
    if t < 0 then t = t + (2 * math.pi) end
    return t
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-21, 21:07


eksdi123







Wiek: 25
Na forum: 1982 dni
Posty: 26
Nick w MP: Kupson



Respekt: 50

Ehh... Dalej to samo, radary si? pokrywaj?...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-22, 16:24


_jvneczek







Wiek: 22
Na forum: 4325 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Zapewne jaki? inny skrypt wp?ywa ci na odpalenie starego radaru, musisz poszuka? setPlayerHudComponentVisible/showPlayerHudComponent i odpalanie radaru, albo nie zalecana wersja - wsadzenie setPlayerHudComponentVisible('radar', false) w render

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-23, 20:47


eksdi123







Wiek: 25
Na forum: 1982 dni
Posty: 26
Nick w MP: Kupson



Respekt: 50

No no rozumiem, ale jak to mo?liwe, ?e mia?em inny radar i on dzia?a poprawnie nic si? nie dzieje po czym go wy??cz? i w??cz? ten drugi to od razu po zalogowaniu stary si? uruchamia....

[ Dodano: 2021-08-23, 21:22 ]
I kurde w tym dobrze dzia?aj?cym radarze jest jeden kod lua, w kt?rym niema b?d? ja nie widz? funkcji "showPlayer.../setPlayer..."

Kod:

local blipTextureNames = {
"arrow",
"radardisc",
"radarRingPlane",
"radar_airYard",
"radar_ammugun",
"radar_barbers",
"radar_BIGSMOKE",
"radar_boatyard",
"radar_bulldozer",
"radar_burgerShot",
"radar_cash",
"radar_CATALINAPINK",
"radar_centre",
"radar_CESARVIAPANDO",
"radar_chicken",
"radar_CJ",
"radar_CRASH1",
"radar_dateDisco",
"radar_dateDrink",
"radar_dateFood",
"radar_diner",
"radar_emmetGun",
"radar_enemyAttack",
"radar_fire",
"radar_Flag",
"radar_gangB",
"radar_gangG",
"radar_gangN",
"radar_gangP",
"radar_gangY",
"radar_girlfriend",
"radar_gym",
"radar_hostpital",
"radar_impound",
"radar_light",
"radar_LocoSyndicate",
"radar_MADDOG",
"radar_mafiaCasino",
"radar_MCSTRAP",
"radar_modGarage",
"radar_north",
"radar_OGLOC",
"radar_pizza",
"radar_police",
"radar_propertyG",
"radar_propertyR",
"radar_qmark",
"radar_race",
"radar_runway",
"radar_RYDER",
"radar_saveGame",
"radar_school",
"radar_spray",
"radar_SWEET",
"radar_tattoo",
"radar_THETRUTH",
"radar_TORENO",
"radar_TorenoRanch",
"radar_triads",
"radar_triadsCasino",
"radar_truck",
"radar_tshirt",
"radar_waypoint",
"radar_WOOZIE",
"radar_ZERO",
}

local radarTextureNames = {
"radar00",
"radar01",
"radar02",
"radar03",
"radar04",
"radar05",
"radar06",
"radar07",
"radar08",
"radar09",
"radar10",
"radar11",
"radar12",
"radar13",
"radar14",
"radar15",
"radar16",
"radar17",
"radar18",
"radar19",
"radar20",
"radar21",
"radar22",
"radar23",
"radar24",
"radar25",
"radar26",
"radar27",
"radar28",
"radar29",
"radar30",
"radar31",
"radar32",
"radar33",
"radar34",
"radar35",
"radar36",
"radar37",
"radar38",
"radar39",
"radar40",
"radar41",
"radar42",
"radar43",
"radar44",
"radar45",
"radar46",
"radar47",
"radar48",
"radar49",
"radar50",
"radar51",
"radar52",
"radar53",
"radar54",
"radar55",
"radar56",
"radar57",
"radar58",
"radar59",
"radar60",
"radar61",
"radar62",
"radar63",
"radar64",
"radar65",
"radar66",
"radar67",
"radar68",
"radar69",
"radar70",
"radar71",
"radar72",
"radar73",
"radar74",
"radar75",
"radar76",
"radar77",
"radar78",
"radar79",
"radar80",
"radar81",
"radar82",
"radar83",
"radar84",
"radar85",
"radar86",
"radar87",
"radar88",
"radar89",
"radar90",
"radar91",
"radar92",
"radar93",
"radar94",
"radar95",
"radar96",
"radar97",
"radar98",
"radar99",
"radar100",
"radar101",
"radar102",
"radar103",
"radar104",
"radar105",
"radar106",
"radar107",
"radar108",
"radar109",
"radar110",
"radar111",
"radar112",
"radar113",
"radar114",
"radar115",
"radar116",
"radar117",
"radar118",
"radar119",
"radar120",
"radar121",
"radar122",
"radar123",
"radar124",
"radar125",
"radar126",
"radar127",
"radar128",
"radar129",
"radar130",
"radar131",
"radar132",
"radar133",
"radar134",
"radar135",
"radar136",
"radar137",
"radar138",
"radar139",
"radar140",
"radar141",
"radar142",
"radar143",
}

function replaceTexture(textureName, imgPath)
local textureReplaceShader = dxCreateShader("client/shaders/texture_replace.fx", 0, 0, false, "world")
local texture = dxCreateTexture(imgPath .. textureName .. ".png")
dxSetShaderValue(textureReplaceShader, "gTexture", texture)
engineApplyShaderToWorldTexture(textureReplaceShader, textureName)
end

function replaceRadarTextures()
for i, textureName in ipairs(blipTextureNames) do
replaceTexture(textureName, "client/img/radar/blips/")
end

for i, textureName in ipairs(radarTextureNames) do
replaceTexture(textureName, "client/img/radar/map/")
end
end

addEventHandler("onClientResourceStart", resourceRoot, replaceRadarTextures)
[color=yellow][/color]

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-08-28, 12:19


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Zalecenie : odpal sobie local server z czystymi plikami + ten tw?j zas?b wy?ej. Je?li dalej si? pojawi hud - napisz

Postaw piwo autorowi tego posta
 

 
Tagi: radar
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Radar Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku