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

Wysłany: 2022-10-10, 16:44


AsaXx







Wiek: 21
Na forum: 2554 dni
Posty: 74
Nick w MP: AsaXx

Piwa: 413

Respekt: 50

Dzie? dobry. Nowy dzie?, nowy problem z .lua. Chcia?em doda? sobie gui do pracy, aby po naci?ni?ciu guzika "Rozpocznij prac?" praca si? rozpoczyna?a, a nie od razu po wej?ciu w marker. Doda?em gui po wej?ciu w marker po stronie clienta, po stronie servera go odpalam, wszystko ?adnie pi?knie dop?ki nie zaczn? pracy. Po wci?ni?ciu nic sie nie dzieje, opr?cz pojawienia si? notyfikacji o rozpocz?ciu pracy. Tak jakby triggerServerEvent nic tam nie robi?. Brak b??d?w w DB3.

SERVER
local code = "Autobusy"
        local zone = createColSphere( -1751.31,951.90,25.89, 6 )

addEventHandler("onMarkerHit", m1, function(el, md)
    triggerClientEvent(el, "pokaz", el)
end)

function start(el, md)
    if getElementData(root, "vehicle_job_owner") then
        return
    end
    
    if not md or getElementType(el) ~= "player" or getPedOccupiedVehicle(el) then return end
    if getElementData(el,"player:job") then return end
    if #getElementsWithinColShape(zone,"vehicle") >= 1 then outputChatBox("[#00ff00INFORMACJA#ffffff]Kto? ju? zajmuje to miejsce, poczekaj a? odjedzie.",el,255,255,255,true) return end
    local x,y,z = getElementPosition(el)
    local autbus = createVehicle(437, -1751.31,951.90,25.89, 0.00, 0, 270 )
    setElementFrozen(el,true)
    setElementData(autbus,"vehicle:desc","Praca dorywcza\n Kierowca autobusu")
    setElementData(autbus, "vehicle_job_owner", el)
    setElementData(autbus, "vehicle:fuel", 100000)
    setElementData(autbus, "vehicle:mileage", math.random(1000,1233))
    setVehicleHandling(autbus, "maxVelocity", 80.0)
    setElementData(el,"player:job",code)
    --warpPedIntoVehicle( el, autobus)
    setTimer(warpPedIntoVehicle,200,1,el,autbus)
    setTimer(setElementFrozen,1000,1,el, false)
    triggerClientEvent(el, "STARTJobBus", resourceRoot, autbus)

    vehs[el] = autbus
end
addEvent("pls", true)
addEventHandler("pls", root, start)


CLIENT
function render()
    dxDrawRectangle(625/scale, 325/scale, 700/scale, 300/scale, tocolor(15,15,15,240))

    dxDrawText("KIEROWCA AUTOBUSU", 1850/scale, 625/scale, 100/scale, 100/scale, tocolor(255, 255, 255, 255), 1, font412, "center", "center")
    dxDrawRectangle(640/scale, 400/scale, 320/scale, 170/scale, tocolor(10,10,10,255))
    dxDrawImage(650/scale, 410/scale, 300/scale, 150/scale, "bus.png")

    if not isMouseIn(705/scale, 590/scale, 150/scale, 20/scale) then
        dxDrawRectangle(705/scale, 590/scale, 150/scale, 20/scale, tocolor(10,10,10,255))
    else
        dxDrawRectangle(698/scale, 590/scale, 165/scale, 20/scale, tocolor(10,10,10,255))
    end
    if not isMouseIn(1100/scale, 590/scale, 150/scale, 20/scale) then
        dxDrawRectangle(1100/scale, 590/scale, 150/scale, 20/scale, tocolor(10,10,10,255))
    else
        dxDrawRectangle(1093/scale, 590/scale, 165/scale, 20/scale, tocolor(10,10,10,255))
    end

    dxDrawText("Praca kierowcy autobusu polega na przewo?eniu \npasa?er?w przez ca?e San Fierro w wyznaczonych punktach. \nZarabiaj i zwiedzaj miasto jednocze?nie.\n\n\nZarobek: 1-5PLN\nEXP: 0-1\n\nWymagany LVL 50\nWymagane prawo jazdy kat. C",2190/scale, 850/scale, 100/scale, 101/scale, tocolor(255, 255, 255, 255), 1, font4, "center", "center")
    dxDrawText("Rozpocznij prac?", 1465/scale, 1100/scale, 100/scale, 100/scale, tocolor(255, 255, 255, 255), 1, font4, "center", "center")  
    dxDrawText("Zamknij", 2250/scale, 1100/scale, 100/scale, 100/scale, tocolor(255, 255, 255, 255), 1, font4, "center", "center")  
end

function on()
    addEventHandler("onClientRender", root, render)
    panel = true
    showChat(false)
    showCursor(true)
    setElementData(localPlayer, "hud:pokazany", 0)
end

addEvent("pokaz",true)
addEventHandler("pokaz",root,on)

addEventHandler("onClientClick", root, function()
    if panel == true then 
        if isMouseIn(1100/scale, 590/scale, 150/scale, 20/scale) then
            removeEventHandler("onClientRender", root, render)
            panel = false
            showChat(true)
            showCursor(false)
            setElementData(localPlayer, "hud:pokazany", 1)
        elseif isMouseIn(705/scale, 590/scale, 150/scale, 20/scale) then
            if tonumber(getElementData(localPlayer,"player:lvl")) < 50 then
                triggerEvent("onClientAddNotification",localPlayer,"Aby rozpocz?? tu prac? potrzebujesz \nminimum LVL 50.","error")
            elseif getElementData(localPlayer, "player:license:pjC") == 0 then 
                triggerEvent("onClientAddNotification",localPlayer,"Aby rozpocz?? tu prac?, potrzebujesz\nprawa jazdy kat. C.","error")
            elseif tonumber(getElementData(localPlayer, "player:lvl")) >= 50 then 
                removeEventHandler("onClientRender", root, render)
                panel = false
                showChat(true)
                showCursor(false)
                setElementData(localPlayer, "hud:pokazany", 1)
                triggerEvent("onClientAddNotification",localPlayer,"Rozpocz??e? prac? jako kierowca autobusu.","info")
                triggerServerEvent("pls", root)
            end
        end
    end
end)


[ Dodano: 2022-10-10, 20:32 ]
Jednak omina??m b??d w DB3. WARNING: [skrypty]\[prace]\pystories-praca-busy\bus.lua:17: Bad argument @ 'getElementData' [Expected element at argument 1, got nil]

To jest ta linijka
        if getElementData(el, "vehicle_job_owner") then


Nie rozumiem co tu jest ?le?

[ Dodano: 2022-10-11, 18:54 ]
@c

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 3 piw(a):
fiXlly., lagerek, borsuk
Tagi: triggerserverevent
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