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

Wysłany: 2022-02-10, 19:58


Norbert1234

Nie umiem w LUA






Wiek: 22
Na forum: 4128 dni
Posty: 319
Nick w MP: Gusterowskyy

Piwa: 244

Respekt: 60

Witam.
Robi? prawo jazdy i chcia?bym ustawi? tras? kt?ra b?dzie inna dla ka?dej kategorii..
Niestety nie wychodzi mi.
Mo?e kto? wskaza? co robie ?le?




local PUNKTB =[kordy]
local PUNKTC =[kordy]
local PUNKTA =[kordy] itp..
 
function startPJA()
    punkty_a = 0
    destroyMarkersS()
    local x,y,z = punkty[punkt][1],punkty[punkt][2],punkty[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
    triggerServerEvent("kurs:prawko", localPlayer, "A", 500)
    kurs = "A"
end

function startPJB()
    punkty_b = 0
    destroyMarkersS()
    local x,y,z = punkty[punkt][1],punkty[punkt][2],punkty[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
    triggerServerEvent("kurs:prawko", localPlayer, "B")
    kurs = "B"
end

function startPJC()
    punkty_c = 0
    destroyMarkersS()
    local x,y,z = punkty[punkt][1],punkty[punkt][2],punkty[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
    triggerServerEvent("kurs:prawko", localPlayer, "C", 750)
    kurs = "C"
end

function endKurs()
    if kurs == "A" then
        setElementData(localPlayer, "user:pjA", 1)
        exports.rpg_noti:createNotification("x","Zda?‚e?› kurs na prawo jazdy kat. A")
    elseif kurs == "B" then
        setElementData(localPlayer, "user:pjB", 1)
        exports.rpg_noti:createNotification("x","Zda?‚e?› kurs na prawo jazdy kat. B")
    elseif kurs == "C" then
        setElementData(localPlayer, "user:pjC", 1)
        exports.rpg_noti:createNotification("x","Zda?‚e?› kurs na prawo jazdy kat. C")
    end
    triggerServerEvent("kurs:prawko", localPlayer)
end

local km = 0

addEventHandler("onClientMarkerHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if source ~= marker then return end
    if getElementDimension(source) ~= getElementDimension(hit) then return end
    if getElementInterior(source) ~= getElementInterior(hit) then return end
    destroyElement(marker)
    marker = false
    destroyElement(blip)
    blip = false
    if punkt == #punkty then
        if kurs == "A" then
            addEventHandler("onClientRender", root, gui_km)
            km = 2
        elseif kurs == "B" then
            addEventHandler("onClientRender", root, gui_km)
            km = 2
        elseif kurs == "C" then
            addEventHandler("onClientRender", root, gui_km)
            km = 2
        end
        return
    end
    punkt = punkt+1
    local x,y,z = punkty[punkt][1],punkty[punkt][2],punkty[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
end)

function gui_km()
    local veh = getPedOccupiedVehicle(localPlayer)
    local h = getVehicleHandling(veh)
    local sx,sy,sz = getElementVelocity(veh)
    local speed = math.floor(math.ceil(((sx^2+sy^2+sz^2)^(0.5))*180))
    if speed > 25 then
        km = km-0.01
    end
    if km <= 0 then
        removeEventHandler("onClientRender", root, gui_km)
        endKurs()
    end
    exports["buttons"]:createCustomWindow(true, screenW * 0.4234, screenH * 0.0250, screenW * 0.1531, screenH * 0.0750, tocolor(255, 255, 255, 255), false)
    exports["buttons"]:createCustomText("Pozosta?&#8218;o do przejechania: "..string.format("%.1f", km).."km", screenW * 0.4234, screenH * 0.0250, screenW * 0.1531+screenW * 0.4234, screenH * 0.0750+screenH * 0.0250, tocolor(255, 255, 255), 0)
end

addEventHandler("onClientClick", root, function(b,s)
    if b ~= "state" and s ~= "down" then return end
    if isMouseIn(screenW * 0.511, screenH * 0.68, screenW * 0.102, screenH * 0.044) and showed == true then
        guiSetVisible(gridlist, false)
        showCursor(false)
        showed = false
        removeEventHandler("onClientRender", root, gui)
    elseif isMouseIn(screenW * 0.386, screenH * 0.68, screenW * 0.102, screenH * 0.044) and showed == true and not isMarkersS() then
        local selected = guiGridListGetSelectedItem(gridlist)
        if selected < 0 then return end
        local id = guiGridListGetItemText(gridlist, selected, 1, false, false)
        id = tonumber(id)
        local kasa = getPlayerMoney(localPlayer)
        kasa = tonumber(kasa)
        local cena = id == 1 and 500 or id == 2 and 0 or id == 3 and 750
        if kasa >= cena then
            prawko = id == 1 and "A" or id == 2 and "B" or id == 3 and "C"
            if prawko == "A" and getElementData(localPlayer, "user:pjA") == 1 then
                exports["rpg_noti"]:createNotification("info", "Posiadasz juĹĽ prawo jazdy kategorii A.")
                return
            elseif prawko == "B" and getElementData(localPlayer, "user:pjB") == 1 then
                exports["rpg_noti"]:createNotification("info", "Posiadasz juĹĽ prawo jazdy kategorii B.")
                return
            elseif prawko == "C" and getElementData(localPlayer, "user:pjC") == 1 then
                exports["rpg_noti"]:createNotification("info", "Posiadasz juĹĽ prawo jazdy kategorii C.")
                return
            end
            createMarkersS()
            exports["rpg_noti"]:createNotification("info", "Udaj si?&#8482; do niebieskiego markera.")
            guiSetVisible(gridlist, false)
            showCursor(false)
            showed = false
            removeEventHandler("onClientRender", root, gui)
        else
            exports["rpg_noti"]:createNotification("info", "Brak wystarczaj?&#8230;cych funduszy.")
        end
    elseif isMouseIn(screenW * 0.511, screenH * 0.68, screenW * 0.102, screenH * 0.044) and showed_teoria == true then
        showCursor(false)
        showed_teoria = false
        removeEventHandler("onClientRender", root, gui_teoria_a)
        removeEventHandler("onClientRender", root, gui_teoria_b)
        removeEventHandler("onClientRender", root, gui_teoria_c)
        guiSetVisible(tak, false)
        guiSetVisible(nie, false)
        pytanie_a = 1
        punkty_a = 0
        pytanie_b = 1
        punkty_b = 0
        pytanie_c = 1
        punkty_c = 0
        setPedAnimation(localPlayer, "CARRY", "liftup", 0.0, false, false, false, false )
    end
end)

addEventHandler("onClientMarkerHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if not source or source and not isElement(source) then return end
    if getElementDimension(source) ~= getElementDimension(hit) then return end
    if getElementInterior(source) ~= getElementInterior(hit) then return end
    local data = getElementData(source, "stanowisko:prawko")
    local data2 = getElementData(source, "stanowisko:position")
    if data and data2 then
        local x,y,z,rz = data2[1],data2[2],data2[3],data2[4]
        setElementPosition(hit, x, y, z)
        setElementRotation(hit, 0, 0, rz)
        setPedAnimation(hit, "INT_OFFICE", "OFF_Sit_Idle_Loop", -1, true, false)
        guiSetVisible(tak, true)
        guiSetVisible(nie, true)
        if prawko == "A" then
            showed_teoria = true
            addEventHandler("onClientRender", root, gui_teoria_a)
            prawko = "A"
            showCursor(true)
        elseif prawko == "B" then
            showed_teoria = true
            showCursor(true)
            addEventHandler("onClientRender", root, gui_teoria_b)
            prawko = "B"
        elseif prawko == "C" then
            showed_teoria = true
            showCursor(true)
            addEventHandler("onClientRender", root, gui_teoria_c)
            prawko = "C"
        end
    end
end)



stawiam zimne piwo!

[ Dodano: 2022-02-10, 19:59 ]
@EDIT
Oczywi?cie daje punkt wyj?cia z jakiego zaczyna?em... ?eby po prostu z jednej trasy zrobi? 3.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2022-02-10, 20:18


P.Wiśnia

Programista LUA






Wiek: 25
Na forum: 4185 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

Respekt: 100
Respekt: 100

Przyk?ad:
local punkty = {
         {0,0,0},
         {0,0,0},
}

function startPJKATEGORIA()
    local x,y,z = punkty[punkt][1],punkty[punkt][2],punkty[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
end


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Norbert1234
Wysłany: 2022-02-10, 21:38


Norbert1234

Nie umiem w LUA






Wiek: 22
Na forum: 4128 dni
Posty: 319
Nick w MP: Gusterowskyy

Piwa: 244

Respekt: 60

Da?em rade sam. Ale gdy wjad? w punkt 1 z prawka C to kolejny si? pojawia jako punkt ustawiony do A i w B tak samo

[ Dodano: 2022-02-10, 21:50 ]

local PB = {

{-1514.4559326172, 2615.5627441406, 55.831321716309}, -- pocz?tek
{-1526.4699707031, 2615.8420410156, 55.8359375},
{-1531.857421875, 2620.2556152344, 55.8359375},
{-1531.8881835938, 2629.6401367188, 55.8359375},
{-1531.9147949219, 2622.6157226562, 55.8359375},
{-1530.4202880859, 2616.4455566406, 55.81213760376},
{-1520.3026123047, 2615.5693359375, 55.8359375},
{-1508.3521728516, 2616.3054199219, 55.780403137207},
{-1520.6734619141, 2655.0063476562, 55.8359375},
{-1533.1356201172, 2673.869140625, 55.6875}, -- koniec
}

local PA = {
{-1510.7550048828, 2620.8522949219, 55.8359375},
{-1513.8631591797, 2631.5295410156, 55.8359375},
{-1515.7645263672, 2645.884765625, 55.8359375},
{-1514.3792724609, 2655.5229492188, 55.8359375},
{-1532.0802001953, 2655.9748535156, 55.8359375},
{-1528.0238037109, 2646.6408691406, 55.8359375},
{-1520.3436279297, 2655.8151855469, 55.8359375},
{-1511.0594482422, 2668.6896972656, 55.6875},
}

local PC = (
{-1520.3463134766, 2647.5280761719, 55.8359375},
{-1520.9683837891, 2658.8413085938, 55.8359375},
{-1510.6650390625, 2668.7678222656, 55.8359375}, -- koniec
)





function startPJA()
    punkty_a = 0
    destroyMarkersS()
    local x,y,z = PA[punkt][1],PA[punkt][2],PA[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
    triggerServerEvent("kurs:prawko", localPlayer, "A", 500)
    kurs = "A"
end

function startPJB()
    punkty_b = 0
    destroyMarkersS()
    local x,y,z = PB[punkt][1],PB[punkt][2],PB[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
    triggerServerEvent("kurs:prawko", localPlayer, "B")
    kurs = "B"
end

function startPJC()
    punkty_c = 0
    destroyMarkersS()
    local x,y,z = PC[punkt][1],PC[punkt][2],PC[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
    triggerServerEvent("kurs:prawko", localPlayer, "C", 750)
    kurs = "C"
end

function endKurs()
    if kurs == "A" then
        setElementData(localPlayer, "user:pjA", 1)
        exports.rpg_noti:createNotification("x","Zda?&#8218;e?&#8250; kurs na prawo jazdy kat. A")
    elseif kurs == "B" then
        setElementData(localPlayer, "user:pjB", 1)
        exports.rpg_noti:createNotification("x","Zda?&#8218;e?&#8250; kurs na prawo jazdy kat. B")
    elseif kurs == "C" then
        setElementData(localPlayer, "user:pjC", 1)
        exports.rpg_noti:createNotification("x","Zda?&#8218;e?&#8250; kurs na prawo jazdy kat. C")
    end
    triggerServerEvent("kurs:prawko", localPlayer)
end

local km = 0

addEventHandler("onClientMarkerHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if source ~= marker then return end
    if getElementDimension(source) ~= getElementDimension(hit) then return end
    if getElementInterior(source) ~= getElementInterior(hit) then return end
    destroyElement(marker)
    marker = false
    destroyElement(blip)
    blip = false
    if punkt == #PA then
        if kurs == "A" then
            addEventHandler("onClientRender", root, gui_km)
            km = 60
        end
        return
    end
    punkt = punkt+1
    local x,y,z = PA[punkt][1],PA[punkt][2],PA[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
end)

addEventHandler("onClientMarkerHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if source ~= marker then return end
    if getElementDimension(source) ~= getElementDimension(hit) then return end
    if getElementInterior(source) ~= getElementInterior(hit) then return end
    destroyElement(marker)
    marker = false
    destroyElement(blip)
    blip = false
    if punkt == #PB then

        if kurs == "B" then
            addEventHandler("onClientRender", root, gui_km)
            km = 2
        end
        return
    end
    punkt = punkt+1
    local x,y,z = PB[punkt][1],PB[punkt][2],PB[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
end)

addEventHandler("onClientMarkerHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if source ~= marker then return end
    if getElementDimension(source) ~= getElementDimension(hit) then return end
    if getElementInterior(source) ~= getElementInterior(hit) then return end
    destroyElement(marker)
    marker = false
    destroyElement(blip)
    blip = false
    if punkt == #PC then
        if kurs == "C" then
            addEventHandler("onClientRender", root, gui_km)
            km = 2
        end
        return
    end
    punkt = punkt+1
    local x,y,z = PC[punkt][1],PC[punkt][2],PC[punkt][3]
    marker = createMarker(x,y,z-0.7,"cylinder",3,0,255,0,75)
    blip = createBlipAttachedTo(marker, 41)
end)

function gui_km()
    local veh = getPedOccupiedVehicle(localPlayer)
    local h = getVehicleHandling(veh)
    local sx,sy,sz = getElementVelocity(veh)
    local speed = math.floor(math.ceil(((sx^2+sy^2+sz^2)^(0.5))*180))
    if speed > 25 then
        km = km-0.01
    end
    if km <= 0 then
        removeEventHandler("onClientRender", root, gui_km)
        endKurs()
    end
    exports["buttons"]:createCustomWindow(true, screenW * 0.4234, screenH * 0.0250, screenW * 0.1531, screenH * 0.0750, tocolor(255, 255, 255, 255), false)
    exports["buttons"]:createCustomText("Pozosta?&#8218;o do przejechania: "..string.format("%.1f", km).."km", screenW * 0.4234, screenH * 0.0250, screenW * 0.1531+screenW * 0.4234, screenH * 0.0750+screenH * 0.0250, tocolor(255, 255, 255), 0)
end

addEventHandler("onClientClick", root, function(b,s)
    if b ~= "state" and s ~= "down" then return end
    if isMouseIn(screenW * 0.511, screenH * 0.68, screenW * 0.102, screenH * 0.044) and showed == true then
        guiSetVisible(gridlist, false)
        showCursor(false)
        showed = false
        removeEventHandler("onClientRender", root, gui)
    elseif isMouseIn(screenW * 0.386, screenH * 0.68, screenW * 0.102, screenH * 0.044) and showed == true and not isMarkersS() then
        local selected = guiGridListGetSelectedItem(gridlist)
        if selected < 0 then return end
        local id = guiGridListGetItemText(gridlist, selected, 1, false, false)
        id = tonumber(id)
        local kasa = getPlayerMoney(localPlayer)
        kasa = tonumber(kasa)
        local cena = id == 1 and 500 or id == 2 and 0 or id == 3 and 750
        if kasa >= cena then
            prawko = id == 1 and "A" or id == 2 and "B" or id == 3 and "C"
            if prawko == "A" and getElementData(localPlayer, "user:pjA") == 1 then
                exports["rpg_noti"]:createNotification("info", "Posiadasz juĹĽ prawo jazdy kategorii A.")
                return
            elseif prawko == "B" and getElementData(localPlayer, "user:pjB") == 1 then
                exports["rpg_noti"]:createNotification("info", "Posiadasz juĹĽ prawo jazdy kategorii B.")
                return
            elseif prawko == "C" and getElementData(localPlayer, "user:pjC") == 1 then
                exports["rpg_noti"]:createNotification("info", "Posiadasz juĹĽ prawo jazdy kategorii C.")
                return
            end
            createMarkersS()
            exports["rpg_noti"]:createNotification("info", "Udaj si?&#8482; do niebieskiego markera.")
            guiSetVisible(gridlist, false)
            showCursor(false)
            showed = false
            removeEventHandler("onClientRender", root, gui)
        else
            exports["rpg_noti"]:createNotification("info", "Brak wystarczaj?&#8230;cych funduszy.")
        end
    elseif isMouseIn(screenW * 0.511, screenH * 0.68, screenW * 0.102, screenH * 0.044) and showed_teoria == true then
        showCursor(false)
        showed_teoria = false
        removeEventHandler("onClientRender", root, gui_teoria_a)
        removeEventHandler("onClientRender", root, gui_teoria_b)
        removeEventHandler("onClientRender", root, gui_teoria_c)
        guiSetVisible(tak, false)
        guiSetVisible(nie, false)
        pytanie_a = 1
        punkty_a = 0
        pytanie_b = 1
        punkty_b = 0
        pytanie_c = 1
        punkty_c = 0
        setPedAnimation(localPlayer, "CARRY", "liftup", 0.0, false, false, false, false )
    end
end)

addEventHandler("onClientMarkerHit", resourceRoot, function(hit)
    if hit ~= localPlayer then return end
    if not source or source and not isElement(source) then return end
    if getElementDimension(source) ~= getElementDimension(hit) then return end
    if getElementInterior(source) ~= getElementInterior(hit) then return end
    local data = getElementData(source, "stanowisko:prawko")
    local data2 = getElementData(source, "stanowisko:position")
    if data and data2 then
        local x,y,z,rz = data2[1],data2[2],data2[3],data2[4]
        setElementPosition(hit, x, y, z)
        setElementRotation(hit, 0, 0, rz)
        setPedAnimation(hit, "INT_OFFICE", "OFF_Sit_Idle_Loop", -1, true, false)
        guiSetVisible(tak, true)
        guiSetVisible(nie, true)
        if prawko == "A" then
            showed_teoria = true
            addEventHandler("onClientRender", root, gui_teoria_a)
            prawko = "A"
            showCursor(true)
        elseif prawko == "B" then
            showed_teoria = true
            showCursor(true)
            addEventHandler("onClientRender", root, gui_teoria_b)
            prawko = "B"
        elseif prawko == "C" then
            showed_teoria = true
            showCursor(true)
            addEventHandler("onClientRender", root, gui_teoria_c)
            prawko = "C"
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Tagi: ustawienie :: trasy :: losowej.
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