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

Wysłany: 2022-03-29, 19:33


lego15







Wiek: 26
Na forum: 2238 dni
Posty: 21
Nick w MP: popoq

Piwa: 10

Respekt: 50

Witam, napisa?em skrypt na dyspozytora dla frakcji SAFD ( dost?pno?? dla frakcji safd dopisze potem oraz zmieni? stacje radiow? na odglos syreny). Chodzi o to ?e d?wi?k si? normalnie uruchamia oraz wy??cza jednak nie da si? powt?rzy? tej czynno?ci gdy j? wy??cz? nie da si? jej w??czy?

local screenW, screenH = guiGetScreenSize()
local marker=createMarker(-2544.27661, -34.97003, 15.46506, "cylinder", 2, 255,255,255,20)
local sx,sy=guiGetScreenSize()
local w, h = (sx/1280),(sy/720)
local scalaczcionki = (w+h)*0.5
local sx, sy = guiGetScreenSize()
local dxfont0_bold = dxCreateFont(":vectory-f1/files/fonts/bold.ttf", (14/1920) * sx)
local dxfont1_light = dxCreateFont(":vectory-f1/files/fonts/light.ttf", (10/1920) * sx)
local screenW, screenH = guiGetScreenSize()
local nazwa = guiGetText(podanaNazwa)

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end



function gui()
    dxDrawImage(785, 404, 351, 274, ":nrpg_interface/img/white123.png", 0, 0, 0, tocolor(10, 10, 10, 165), false)
    dxDrawText("Dyspozytor - SAFD", 888, 411, 1024, 435, tocolor(255, 255, 255, 255), 1.30, "default", "left", "top", false, false, false, false, false)
    dxDrawImage(786, 448, 346, 1, ":nrpg_interface/img/1.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawText("W tym panelu uruchomisz syrene jako cz?onek\n frakcji S.A Fire Departament!", 801, 467, 1016, 600, tocolor(255, 255, 255, 255), 1.20, "default", "left", "top", false, false, false, false, false)
    dxDrawImage(846, 576, 228, 81, ":nrpg_interface/img/white123.png", 0, 0, 0, tocolor(14, 14, 14, 254), false)
    if mysz(847, 576, 225, 80) then
        dxDrawImage(846, 576, 228, 81, ":nrpg_interface/img/white123.png", 0, 0, 0, tocolor(0, 0, 0, 20), false)
    end
    dxDrawText("Uruchom Syrene", 861, 600, 1049, 662, tocolor(255, 255, 255, 255), 1.70, "default", "left", "top", false, false, false, false, false)
    dxDrawImage(1026, 600, 33, 32, ":nrpg_interface/img/siren.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end

function wyl()
    dxDrawImage(785, 404, 351, 274, ":nrpg_interface/img/white123.png", 0, 0, 0, tocolor(10, 10, 10, 165), false)
    dxDrawText("Dyspozytor - SAFD", 888, 411, 1024, 435, tocolor(255, 255, 255, 255), 1.30, "default", "left", "top", false, false, false, false, false)
    dxDrawImage(786, 448, 346, 1, ":nrpg_interface/img/1.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawText("W tym panelu uruchomisz syrene jako cz?onek\n frakcji S.A Fire Departament!", 801, 467, 1016, 600, tocolor(255, 255, 255, 255), 1.20, "default", "left", "top", false, false, false, false, false)
    dxDrawImage(846, 576, 228, 81, ":nrpg_interface/img/white123.png", 0, 0, 0, tocolor(14, 14, 14, 254), false)
    if mysz(847, 576, 225, 80) then
        dxDrawImage(846, 576, 228, 81, ":nrpg_interface/img/white123.png", 0, 0, 0, tocolor(0, 0, 0, 20), false)
    end
    dxDrawText("Wy??cz Syrene", 861, 600, 1049, 662, tocolor(255, 255, 255, 255), 1.70, "default", "left", "top", false, false, false, false, false)
    dxDrawImage(1026, 600, 33, 32, ":nrpg_interface/img/siren.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end



addEventHandler("onClientMarkerHit", marker, function(el)
    gui1 = true
    guiSetVisible(podanaNazwa, true)
    addEventHandler("onClientRender", root, gui)
    showCursor(true, false)
    guiSetVisible(podanaNazwa, true)
end)

addEventHandler("onClientMarkerLeave", resourceRoot, function(el)
    gui1 = false
    if el ~= localPlayer then return end
    guiSetVisible(podanaNazwa, false)
    removeEventHandler("onClientRender", getRootElement(), gui)
    removeEventHandler("onClientRender", getRootElement(), wyl)
    showCursor(false)
    guiSetVisible(podanaNazwa, false)
    end)



function mysz(psx,psy,pssx,pssy,abx,aby)
        if not isCursorShowing() then return end
        cx,cy=getCursorPosition()
        cx,cy=cx*sx,cy*sy
        if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
            return true,cx,cy
        else
            return false
        end
    end

addEventHandler("onClientClick", root, function(btn, state)
        if btn == "left" and state == "down" then
        if isMouseIn(screenW * 0.4365, screenH * 0.5296, screenW * 0.1271, screenH * 0.0833) and gui1 then
           siren = playSound3D( 'http://s2.radioparty.pl:8005/stream', -2544.20117, -35.08395, 16.46683, true )
            removeEventHandler("onClientRender", getRootElement(), gui)
            gui1 = false
            addEventHandler("onClientRender", root, wyl)
            gui2 = true
            addEventHandler("onClientClick", root, function(btnn, state)
                if btnn == "left" and state == "down" then
                    if isMouseIn(screenW * 0.4365, screenH * 0.5296, screenW * 0.1271, screenH * 0.0833) and gui2 then
                        stopSound(siren)
                        removeEventHandler("onClientRender", getRootElement(), wyl)
                        gui2 = false
                        addEventHandler("onClientRender", root, gui)
                    end
                end
            end)
        end
    end
end


Komentarz Nexisten dodany 30 Marzec 2022, 13:18Następnym razem skorzystaj ze znaczników [lua], tym razem uzupełniłem to za Ciebie :]
Ostatnio zmieniony przez Nexisten 2022-03-30, 13:17, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2022-03-29, 22:38


kamison

Przyszły programista .lua






Wiek: 25
Na forum: 3443 dni
Posty: 391
Nick w MP: kamison

Piwa: 599

Respekt: 205,3
Respekt: 205,3Respekt: 205,3

Zobacz czy jak wstawisz te eventy "onClientClick" osobno, nie jeden w drugim czy zadzia?a jak nie to mo?e zdefiniuj zmienn? "siren" przed tymi eventami

Postaw piwo autorowi tego posta
 

 
Tagi: kłopoty :: dyspozytorem
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