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

Wysłany: 2019-12-21, 15:10


Nywis







Wiek: 29
Na forum: 2847 dni
Posty: 60
Nick w MP: Nywis

Piwa: 14

Respekt: 45,3

Posiadam kod podmieniajacy markery, a dokladniej cylindry, aczkolwiek problem tkwi w tym, i? gdy postawi? marker na np. dim 12, czy te? dam interior, to ten marker widoczny jest te? na dim 0.




MARKER_DRAW_DISTANCE 3000
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.80.8)

function findRotation(from_xfrom_yto_xto_y)
    local result = -math.deg(math.atan2(to_x from_xto_y from_y))
    
    return result and result 360 or result
end

local thisTick getTickCount()

local font exports['lrpg-markery']:dxGetFont('light') or 'default-bold'

function renderCustomMarkers()
    local cxcycz getCameraMatrix()
    local rxryrz getElementRotation(getCamera())
    local posPlayerXposPlayerYposPlayerZ=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 imarker in ipairs(markers) do 
        if isElement(markerthen
            local xygetElementPosition(marker)
            local radius getMarkerSize(marker) or 3 
            local color = {getMarkerColor(marker)} or {255255255255}
            local icon getElementData(marker"icon") or "marker"
            local dist getDistanceBetweenPoints3D(cxcyczxyz)
            local progress = (dist-MARKER_FADE_DISTANCE)/(MARKER_DRAW_DISTANCE-MARKER_FADE_DISTANCE)
            color[4] = math.max(0math.min(255 - (255*progress), 255))
            
            if isOnScreen(xyzradius*0.25) and color[4] > 0 then

                local i1i2=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"], xyz+iconSize.y*1.5+tickpX-90pYpZiconSize.x-0.3iconSize.y-0.3color000posPlayerXposPlayerYposPlayerZ)
                
                local lightColor color 
                --lightColor[4] = (lightColor[4]*0.8) - ((lightColor[4]*0.3)*tick)
                lightColor[4] = lightColor[4] - (tick*10)

                drawTransformedMaterial(textures.marker_ring1xyz+0.100i1radius+0.4radius+0.4lightColor000000)
                --drawTransformedMaterial(textures.marker_ring2xyz+0.100i2radius+0.4radius+0.4lightColor000000)
            end

            if getElementData(marker'marker:text') and dist 20 then 
                local sx,sy getScreenFromWorldPosition(x,y,0.4*1.5+tick)
                if sx and sy then 
                    local alpha = ((20/255 dist/255) * 255)/15 255
                    local size = ((20/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 cxcycz getCameraMatrix()
    if font == 'default-bold' then 
        font dxCreateFont("light.ttf"15)
    end 
    markers = {}
    for kv in ipairs(getElementsWithinRange(cx,cy,cz75'marker')) do 
        if getMarkerType(v) ~= 'corona' then 
            local xygetElementPosition(v)
            if getDistanceBetweenPoints3D(xyzcxcycz) < MARKER_DRAW_DISTANCE*2 then 

                local r,g,b=getMarkerColor(v)
                setMarkerColor(vr,g,b0)

                table.insert(markersv)
            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(getNearbyMarkersMARKER_REFRESH_TIMEOUT0)
    addEventHandler("onClientRender"rootrenderCustomMarkers)
end)

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


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-21, 18:23


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W onClientRenderze musisz sprawdza? czy gracz jest w tym samym dimensionie co marker, kt?ry rysujesz.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-21, 19:00


Nywis







Wiek: 29
Na forum: 2847 dni
Posty: 60
Nick w MP: Nywis

Piwa: 14

Respekt: 45,3

"Wilq" napisał/a:

W onClientRenderze musisz sprawdza? czy gracz jest w tym samym dimensionie co marker, kt?ry rysujesz.


Czyli jak to powinno wygl?da?? Aby by?o tak, ?e postawi? marker na dimensionie np. 9 i aby nie by?o go na ?adnym innym dimensionie?


    setTimer(getNearbyMarkersMARKER_REFRESH_TIMEOUT0)
    addEventHandler("onClientRender"rootrenderCustomMarkers)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-21, 19:10


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Jeszcze raz: sprawdzaj czy gracz jest w tym samym dimensionie co marker w evencie onClientRender (tam gdzie tworzysz te markery).

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-21, 19:51


Nywis







Wiek: 29
Na forum: 2847 dni
Posty: 60
Nick w MP: Nywis

Piwa: 14

Respekt: 45,3

"Wilq" napisał/a:

Jeszcze raz: sprawdzaj czy gracz jest w tym samym dimensionie co marker w evencie onClientRender (tam gdzie tworzysz te markery).


No to tak jest, dobrze wszystko, nawet jak wy??cz? ten skrypt z tzw. podmiank? tych marker?w, to te markery znikaj? z innych dimension?w, a jak w??cz?, to s? na ka?dym

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-21, 21:47


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

To dodaj sprawdzanie jeszcze w funkcji getNearbyMarkers i wy?lij kod po zmianach.

Postaw piwo autorowi tego posta
 

 
Tagi: jest :: nie :: tak :: kodzie :: markerami?
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Co jest nie tak w kodzie z markerami? 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