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

Wysłany: 2020-07-28, 16:12


CytrusekLUA







Wiek: 22
Na forum: 2752 dni
Posty: 5
Nick w MP: MichaleQ



Respekt: 50

powiem wprost pr?buje napisa? autorski radar znajduj?cy si? w prawym g?rnym rogu ekranu. Niestety blipy nie chc? si? tworzy?, by? mo?e ja co? namiesza?em w kodzie wi?c prosz? o pomoc osoby lepsze w LUA odemnie.

kod blip?w:

for i,b in pairs(getElementsByType('blip')) do
            local bX, bY, bZ = getElementPosition(b);
            local pX, pY, pZ = getElementPosition(localPlayer);
            local _, _, crZ = getElementRotation(getCamera());
            local dist = getDistanceBetweenPoints3D(bX, bY, bZ, pX, pY, pZ);
            local maxdist = getBlipVisibleDistance(b);

            if (dist <= maxdist and getElementDimension(localPlayer) == getElementDimension(b) and getElementInterior(b) == getElementInterior(getCamera())) then
                local radius = dist/zoom;
                local direction = math.atan2(bX - pX, bY - pY) + math.rad(crZ);

                local blipX = w + math.sin(direction) * radius;
                local blipY = h + math.sin(direction) * radius;

                blipX = math.max(0, math.min(blipX, w));
                blipY = math.max(0, math.min(blipY, h));

                local path = ':radar/files/map_blips/radarBlip_'..getBlipIcon(b)..'.png';
                if (path) then
                    local color = tocolor(getBlipColor(b));
                    local size = tonumber(getBlipSize(b));

                    dxDrawImage(x + blipX - size/2, y + blipY - size/2, size, size, path, 0, 0, 0, color);
                else return
                end;
            end;
        end;


Oraz ca?o?? kodu:

local fileDirs = {
    map = ':radar/files/map_file/map.jpg',
    circle = ':radar/files/map_circle/circle.png',
    player = ':radar/files/player_blip/player.png',
    fx = ':radar/files/map_fx/hud_mask.fx',
};

local screenW, screenH = guiGetScreenSize();
local x, y, w, h = screenW * 0.8516, screenH * 0.0250, screenW * 0.1320, screenH * 0.2264
local render = true;
local radarTexture, radarCircleMask, radarShader, everythingOkay;

addEventHandler('onClientResourceStart', resourceRoot, function()
    radarTexture = dxCreateTexture(fileDirs.map);
    radarCircleMask = dxCreateTexture(fileDirs.circle);
    radarShader = dxCreateShader(fileDirs.fx);

    everythingOkay = radarTexture and radarCircleMask and radarShader;
    if (everythingOkay) then
        dxSetShaderValue(radarShader, 'sPicTexture', radarTexture);
        dxSetShaderValue(radarShader, 'sMaskTexture', radarCircleMask);
    end;

    setPlayerHudComponentVisible('all', false);
    --setPlayerHudComponentVisible('radar', true);
end);

addEventHandler('onClientRender', root, function()
    if (render == false) then return end;
    if (everythingOkay) then
        dxSetShaderValue(radarShader, 'sMaskTexture', radarCircleMask);
        
        local x,y = getElementPosition(localPlayer);
        x = ( x ) / 6000;
        y = ( y ) / -6000;
        dxSetShaderValue(radarShader, 'gUVPosition', x,y);
        
        local zoom = 20;
        if (not isPedInVehicle(localPlayer)) then
            local zoom = 20;
        end;
        --zoom = zoom + math.sin( getTickCount() / 500 ) * 3;
        dxSetShaderValue(radarShader, 'gUVScale', 1/zoom, 1/zoom);

        local camX, camY, camZ = getElementRotation(getCamera());
        dxSetShaderValue(radarShader, 'gUVRotAngle', math.rad(-camZ));
        --dxSetShaderTransform(radarShader, 0, -65, camZ);
    
        local _, _, pROT = getElementRotation(localPlayer);
        dxDrawImage(screenW * 0.8516, screenH * 0.0250, screenW * 0.1320, screenH * 0.2264, radarShader, 0,0,0, tocolor(255,255,255,230));
        dxDrawImage(screenW * 0.9117, screenH * 0.1236, screenW * 0.0125, screenH * 0.0236, fileDirs.player, 0, 0, math.rad(-pROT), tocolor(255, 255, 255, 255), false);

        for i,b in pairs(getElementsByType('blip')) do
            local bX, bY, bZ = getElementPosition(b);
            local pX, pY, pZ = getElementPosition(localPlayer);
            local _, _, crZ = getElementRotation(getCamera());
            local dist = getDistanceBetweenPoints3D(bX, bY, bZ, pX, pY, pZ);
            local maxdist = getBlipVisibleDistance(b);

            if (dist <= maxdist and getElementDimension(localPlayer) == getElementDimension(b) and getElementInterior(b) == getElementInterior(getCamera())) then
                local radius = dist/zoom;
                local direction = math.atan2(bX - pX, bY - pY) + math.rad(crZ);

                local blipX = w + math.sin(direction) * radius;
                local blipY = h + math.sin(direction) * radius;

                blipX = math.max(0, math.min(blipX, w));
                blipY = math.max(0, math.min(blipY, h));

                local path = ':radar/files/map_blips/radarBlip_'..getBlipIcon(b)..'.png';
                if (path) then
                    local color = tocolor(getBlipColor(b));
                    local size = tonumber(getBlipSize(b));

                    dxDrawImage(x + blipX - size/2, y + blipY - size/2, size, size, path, 0, 0, 0, color);
                else return
                end;
            end;
        end;
    end;
end);


Za pomoc daje zimniutkie piwko :-> :piwo:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-28, 16:24


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

B??dy /debugscript 3?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-28, 16:25


CytrusekLUA







Wiek: 22
Na forum: 2752 dni
Posty: 5
Nick w MP: MichaleQ



Respekt: 50

nic nie ma w?a?nie wilq'u. Po prostu si? nie pojawiaj? bo pod db3 sam bym doszed? do rozwi?zania...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-07-31, 01:49


Ketyso







Wiek: 23
Na forum: 2287 dni
Posty: 30
Nick w MP: Ketyso

Piwa: 2

Respekt: 50

W kodzie masz wsz?dzie powpisywany znak ' zmie? go na "

je?eli b??d wyst?puje dalej sprawdz czy nazwa blipu jest identyczna ( wielko?? liter ma znaczenie ) :)

Postaw piwo autorowi tego posta
 

 
Tagi: blipy :: nie :: tworzą :: się
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA 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