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

Wysłany: 2021-01-20, 23:48


NoNamik







Wiek: 35
Na forum: 2327 dni
Posty: 288
Nick w MP: JestemNoNamem

Piwa: 379

Respekt: 60

Witam mam skrypt z eclipserpg na markery lecz jest jeden problem gdy np dam marker typu "arrow" to s? dwa markery ten arrow i podmianka jak to zrobic by byla tylko podmianka markeru na "cylindrze" a na reszcie byly normalne



MARKER_DRAW_DISTANCE = 9999
MARKER_FADE_DISTANCE = MARKER_DRAW_DISTANCE-10
MARKER_REFRESH_TIMEOUT = 500 -- czas w ms co ile wyszukuje markery w poblizu 
tick_rotation=getTickCount()
local markers = {}
local textures = {}
local iconSize = Vector2(0.8, 0.8)

function findRotation(from_x, from_y, to_x, to_y)
    local result = -math.deg(math.atan2(to_x - from_x, to_y - from_y))
    
    return result < 0 and result + 360 or result
end

local thisTick = getTickCount()

local font = dxCreateFont('f.ttf',15)

function renderCustomMarkers()
    local cx, cy, cz = getCameraMatrix()
    local rx, ry, rz = getElementRotation(getCamera())
    local posPlayerX, posPlayerY, posPlayerZ=getElementPosition(localPlayer)
    local pX,pY,pZ=getElementRotation(localPlayer)
    --local tick = math.abs(getTickCount() % 2500 - 2500/2) / 2500/2
    local tick = interpolateBetween(0,0,0,0.3,0,0, (getTickCount()-thisTick)/2500, "SineCurve")
    
    for i, marker in ipairs(markers) do 
        if isElement(marker) then
            local x, y, z = getElementPosition(marker)
            local radius = getMarkerSize(marker) or 3 
            local color = {getMarkerColor(marker)} or {255, 255, 255, 255}
            local icon = getElementData(marker, "icon") or "marker"
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, x, y, z)
            local progress = (dist-MARKER_FADE_DISTANCE)/(MARKER_DRAW_DISTANCE-MARKER_FADE_DISTANCE)
            color[4] = math.max(0, math.min(255 - (255*progress), 255))
            
            if isOnScreen(x, y, z, radius*0.25) and color[4] > 0 then

                local i1, i2=interpolateBetween(0,0,0,360,0,0,(getTickCount()-tick_rotation)/1250, "OutQuad")
                if (getTickCount()-tick_rotation) > 1250 then 
                    tick_rotation=getTickCount()
                end 
                drawTransformedMaterial(textures[icon.."_icon"], x, y, z+iconSize.y*1.5+tick, pX-90, pY, pZ, iconSize.x-0.3, iconSize.y-0.3, color, 0, 0, 0, posPlayerX, posPlayerY, posPlayerZ)
                
                local lightColor = color 
                --lightColor[4] = (lightColor[4]*0.8) - ((lightColor[4]*0.3)*tick)
                lightColor[4] = lightColor[4] - (tick*10)

                drawTransformedMaterial(textures.marker_ring1, x, y, z+0.1, 0, 0, i1, radius+0.4, radius+0.4, lightColor, 0, 0, 0, 0, 0, 0)
                --drawTransformedMaterial(textures.marker_ring2, x, y, z+0.1, 0, 0, i2, radius+0.4, radius+0.4, lightColor, 0, 0, 0, 0, 0, 0)
            end

            if getElementData(marker, 'marker:text') and dist < 20 then 
                local sx,sy = getScreenFromWorldPosition(x,y,z + 0.4*1.5+tick)
                if sx and sy then 
                    local alpha = ((20/255 - dist/255) * 255)/15 * 255
                    local size = ((20/1 - dist/1) * 1)/15 * 1

                    dxDrawText(getElementData(marker, 'marker:text') or '',sx,sy,sx,sy,tocolor(255,255,255,alpha ),math.max(0.1,size),font,'center','center',false,false,false,false,false)
                end 
            end 

        end
    end
end 

function getNearbyMarkers()
    local cx, cy, cz = getCameraMatrix()
    if font == 'default-bold' then 
        font = exports['lrpg-dxGui']:dxGetFont('default') or 'default-bold'
    end 
    markers = {}
    for k, v in ipairs(getElementsWithinRange(cx,cy,cz, 75, 'marker')) do 
        if getMarkerType(v) ~= 'corona' then 
            local x, y, z = getElementPosition(v)
            if getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) < MARKER_DRAW_DISTANCE*2 then 

                local r,g,b=getMarkerColor(v)
                setMarkerColor(v, r,g,b, 0)

                table.insert(markers, v)
            end
        end 
    end
end 

addEventHandler("onClientResourceStart", resourceRoot, function()
    textures.marker_icon = dxCreateTexture("images/marker.png", "argb",false,'wrap')
    textures.get_car_icon = dxCreateTexture("images/icons/get_car.png", "argb",false,'wrap')
    textures.store_car_icon = dxCreateTexture("images/icons/store_car.png", "argb",false,'wrap')
    textures.station_lpg_icon = dxCreateTexture("images/icons/station_lpg.png", "argb",false,'wrap')
    textures.marker_ring1 = dxCreateTexture('images/marker_1.png',"argb",false,'wrap')
    textures.marker_ring2 = dxCreateTexture('images/marker_2.png',"argb",false,'wrap')

    textures.light = dxCreateTexture("images/light.png")

    setTimer(getNearbyMarkers, MARKER_REFRESH_TIMEOUT, 0)
    addEventHandler("onClientRender", root, renderCustomMarkers)
end)

addEventHandler('onClientResourceStop',resourceRoot,function()
    for i,v in ipairs(getElementsByType('marker')) do 
        local r,g,b = getMarkerColor(v)
        setMarkerColor(v, r,g,b,255)
    end 
end) 



Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-21, 09:11


Mikołajj







Wiek: 23
Na forum: 3026 dni
Posty: 303
Nick w MP: Mikołaj

Piwa: 132

Respekt: 91

Na ko?cu skryptu podmie?:

addEventHandler('onClientResourceStop',resourceRoot,function()
    for i,v in ipairs(getElementsByType('marker')) do 
        local r,g,b = getMarkerColor(v)
        setMarkerColor(v, r,g,b,255)
    end 
end) 


Na:

addEventHandler('onClientResourceStop',resourceRoot,function()
    for i,v in ipairs(getElementsByType('marker')) do 
        local r,g,b = getMarkerColor(v)
        setMarkerColor(v, r,g,b,0)
    end 
end) 


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
NoNamik
Wysłany: 2021-01-22, 01:08


NoNamik







Wiek: 35
Na forum: 2327 dni
Posty: 288
Nick w MP: JestemNoNamem

Piwa: 379

Respekt: 60

Miko?ajj, nie chodzi mi o to zeby usunac markery z normalnego gta tylko zeby usunac podmianke wszedzie markerow tylko zostawic na cylindrze

zrobilem tak lecz dziala tylko na pierwszy typ markeru w tym przypadku 'checkpoint' tak jakby 'andow' wgl nie wykrywalo i kolejnych typow markerow

Kod:

function getNearbyMarkers()
local cx, cy, cz = getCameraMatrix()
if font == 'default-bold' then
font = exports['lrpg-dxGui']:dxGetFont('default') or 'default-bold'
end
markers = {}
for k, v in ipairs(getElementsWithinRange(cx,cy,cz, 75, 'marker')) do
if getMarkerType(v) ~= 'checkpoint' and 'ring' and 'arrow' and 'corona' then
local x, y, z = getElementPosition(v)
if getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) < MARKER_DRAW_DISTANCE*2 then

local r,g,b=getMarkerColor(v)
setMarkerColor(v, r,g,b, 0)

table.insert(markers, v)
end
end
end
end


Postaw piwo autorowi tego posta
 

 
Tagi: markery
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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