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

Wysłany: 2019-02-20, 15:12


smigi







Wiek: 23
Na forum: 3508 dni
Posty: 60
Nick w MP: smigi

Piwa: 2

Respekt: 50

Witam chcia?bym zrobic w tym skrypcie tak aby by?o wymagane 500rp oraz zeby autobus respi? sie w dw?ch miejscach. Za pomoc daje piwko



local sw, sh=guiGetScreenSize()
local w, h=(sw/1680), (sh/1050)
local font=dxCreateFont("f.ttf", 12)
local font2=dxCreateFont("f.ttf", 10)
local font3=dxCreateFont("f.ttf", 15)
local font4=dxCreateFont("f.ttf", 14)
local menuJob=false
local potwierdzExit=false
local praca="Autobusy"
local bileciki=false
local bilecikii=false
local ileos=0
local jakibilet="?"
startTick=getTickCount()

function isMouseIn( x, y, width, height )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end


przystanki={
{-2122.41,112.63,35.17},
{-2169.59,-26.66,35.17},
{-2260.83,-96.63,35.17},
{-2334.27,-187.85,35.17},
{-2369.71,15.27,35.16},
{-2249.44,274.71,35.16},
{-2224.04,482.04,35.02},
{-2192.46,562.47,35.02},
{-2007.88,409.30,35.02},
{-2086.54,322.91,35.02},
{-2149.06,229.84,35.17},
{-2086.71,62.46,34.56},
}

local przystanek
local przystanekTarget
local blip


addEvent("autobusy:kolizja", true)
addEventHandler("autobusy:kolizja", getRootElement(), function(v)
    for i,bus in ipairs(getElementsByType("vehicle")) do
            setElementCollidableWith(bus, v, false)
    end
end)

jobMarker=createMarker(-2089.61, 84.02, 35.31-1, "cylinder", 0.8, 0, 255, 0, 0)
setElementData(jobMarker,"icon", "job")

addEventHandler("onClientRender", getRootElement(), function()
    
    if bilecikii == true then
        dxDrawRectangle(0*w, 0*h, 1680*w, 1050*h, tocolor(8, 7, 7, 148), false)

        if isMouseIn(186*w, 443*h, 316*w, 138*h) then
            dxDrawImage(186*w, 443*h, 316*w, 138*h, "i/hovernormalny.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        else
            dxDrawImage(186*w, 443*h, 316*w, 138*h, "i/normalny.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end

        if isMouseIn(1208*w, 443*h, 316*w, 138*h) then
            dxDrawImage(1208*w, 443*h, 316*w, 138*h, "i/hoverulgowy.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        else
            dxDrawImage(1208*w, 443*h, 316*w, 138*h, "i/ulgowy.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end


        dxDrawText("Klient prosi o bilet "..jakibilet, 664*w, 396*h, 1043*w, 739*h, tocolor(255, 255, 255, 255), 1.00*w, font3, "center", "center", false, false, false, false, false)
    end
    
    if potwierdzExit == true then
        dxDrawImage(667*w, 427*h, 349*w, 181*h, "i/bg_potwierdz.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        if isMouseIn(677*w, 558*h, 88*w, 40*h) then
            dxDrawImage(677*w, 558*h, 88*w, 40*h, "i/tak.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(677*w, 558*h, 88*w, 40*h, "i/tak.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
        
        if isMouseIn(918*w, 558*h, 88*w, 40*h) then
            dxDrawImage(918*w, 558*h, 88*w, 40*h, "i/nie.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(918*w, 558*h, 88*w, 40*h, "i/nie.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
        
        dxDrawText("Jeste? pewny/a ?e chcesz zako?czy? prace?", 694*w, 451*h, 989*w, 543*h, tocolor(255, 255, 255, 255), 1.00*w, font, "center", "center", false, false, false, false, false)
    end
    
    if menuJob == true then
        dxDrawImage(549*w, 345*h, 578*w, 362*h, "i/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        
        dxDrawImage(865*w, 378*h, 229*w, 132*h, "i/jobimg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- zdj pracy
    
        
        if isMouseIn(574*w, 643*h, 101*w, 38*h) then
            dxDrawImage(574*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(574*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
        
        if isMouseIn(737*w, 643*h, 101*w, 38*h) then
            dxDrawImage(737*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(737*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
    
        
        dxDrawText("Twoje statystyki", 916*w, 528*h, 1047*w, 554*h, tocolor(255, 255, 255, 255), 1.00*w, font3, "center", "center", false, false, true, false, false)
        dxDrawText("Zaliczonych przystank?w: #70DB93"..getElementData(localPlayer,"player:topautobusy"), 873*w, 564*h, 1091*w, 681*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "top", false, false, true, true, false)
        dxDrawText(praca.."\n\nOpis\nCelem tej pracy jest przewo?enie os?b\nz przystanku na przystanek, oraz sprzedawanie im\nbilet?w.\n\nZarobki: Gracz: 1600-4600|Premium: 2500-6000", 564*w, 396*h, 847*w, 558*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "center", false, true, false, false, false)
        dxDrawText("Rozpocznij", 573*w, 643*h, 675*w, 681*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "center", false, false, false, false, false)
        dxDrawText("Zamknij", 736*w, 643*h, 838*w, 681*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "center", false, false, false, false, false)
    end
end)


function endJobExitVeh()
    setElementData(localPlayer, "player:job", false)
    triggerServerEvent("autobus:delete", localPlayer)
    unbindKey("F")
    unbindKey("enter")
    setTimer(function()
    setElementPosition(localPlayer, -2089.64, 87.49, 35.32)
    end, 200, 1)
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek = nil
    end
    if przystanekTarget and isElement(przystanekTarget) then
        destroyElement(przystanekTarget)
        przystanekTarget = nil
        przystanekTarget = 0

    end
    if blip and isElement(blip) then
        destroyElement(blip)
        blip=nil
    end
end

function endJob()
    setElementData(localPlayer, "player:job", false)
    triggerServerEvent("autobus:delete", localPlayer)
    unbindKey("F")
    unbindKey("enter")
    setTimer(function()
    end, 200, 1)
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek = nil
    end
    if przystanekTarget and isElement(przystanekTarget) then
        destroyElement(przystanekTarget)
        przystanekTarget = nil
        przystanekTarget = 0

    end
        if blip and isElement(blip) then
        destroyElement(blip)
        blip=nil
    end
end


function hitPrzystanek(el, md)
    if el ~= localPlayer or not md then return end
    local maxTarget = #przystanki
    if przystanekTarget > maxTarget and getPedOccupiedVehicle(el) then return end
    if przystanekTarget == maxTarget and not getPedOccupiedVehicle(el) then return end
    local sx,sy,sz=getElementVelocity(getPedOccupiedVehicle(el))
    local km = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
    if km > 20 then return end
    
    if przystanekTarget == #przystanki then
        endJob()
        triggerEvent("createAlert", el, "info", "Zako?czy?e?/a? prace.")
    else
        setElementFrozen(getPedOccupiedVehicle(el), true)
        ileos=math.random(1,4)
        randomBilet()
        bilecikii=true
        bileciki=true
        showCursor(true)
    end
end


function showPrzystanek()
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek=nil
    end
    if blip and isElement(blip) then 
        destroyElement(blip)
        blip=nil
    end
    
    przystanekTarget=przystanekTarget+1
    przystanek=createMarker(przystanki[przystanekTarget][1], przystanki[przystanekTarget][2], przystanki[przystanekTarget][3]-0.95, "cylinder", 2, 255, 255, 255, 0)
    blip=createBlip(przystanki[przystanekTarget][1], przystanki[przystanekTarget][2], przystanki[przystanekTarget][3], 41)
    setElementData(przystanek,"icon","busprzystanek")
    addEventHandler("onClientMarkerHit", przystanek, hitPrzystanek)
end

addEvent("transport:unbindKeys", true)
addEventHandler("transport:unbindKeys", getRootElement(), function()
    unbindKey("f")
    unbindKey("enter")
end)

addEvent("autobusy:endJob", true)
addEventHandler("autobusy:endJob", getRootElement(), function()
    setElementData(localPlayer, "player:job", false)
    triggerServerEvent("autobus:delete", localPlayer)
    unbindKey("F")
    unbindKey("enter")
    setTimer(function()
    end, 200, 1)
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek = nil
    end
    if przystanekTarget and isElement(przystanekTarget) then
        destroyElement(przystanekTarget)
        przystanekTarget = nil
        przystanekTarget = 0

    end
        if blip and isElement(blip) then
        destroyElement(blip)
        blip=nil
    end
end)

function startEndJob()
    triggerServerEvent("autobusy:sprawdzPrawko", localPlayer)
    if getElementData(localPlayer,"player:license:pjC") ~= 1 then triggerEvent("createAlert",localPlayer,"error","Nie posiadasz prawa jazdy kat.C!") return end
    if getElementData(localPlayer,"player:block:prawko") then triggerEvent("createAlert", localPlayer, "error", "Posiadasz zawieszone prawa jazdy kat. A /B /C.") return end
        if not getElementData(localPlayer,"player:job") then
            setElementData(localPlayer,"player:job", praca)
            triggerServerEvent("autobusy:start", localPlayer)
            triggerEvent("createAlert",localPlayer,"success","Rozpocz??e?/a? prac?.")
            przystanekTarget=0
            showPrzystanek()
            bindKey("F", "down", exitGUI)
            bindKey("enter", "down", exitGUI)
        else
            exports["srpg-noti"]:createAlert("error", "Jeste? ju? gdzie? zatrudniony!")
        end
end

function exitGUI()
    if potwierdzExit==false then
    potwierdzExit=true
    showCursor(true,false)
    end
end

addEventHandler("onClientMarkerHit", jobMarker, function(el)
    if el ~= localPlayer then return end
    if isPedInVehicle(el) then return end
    if getElementData(el,"admin:devmode") == true then return end
    if menuJob == false then
        menuJob=true
        clickJob=true
        showCursor(true)
    end
end)

function randomBilet()
        bilet=math.random(1,2)
        if bilet == 1 then
            jakibilet="normalny"
        elseif bilet == 2 then
            jakibilet="ulgowy"
        end
end


addEventHandler("onClientClick", getRootElement(), function(btn,state)
    if clickJob and btn == "left" and state == "down" then
        if isMouseIn(574*w, 643*h, 101*w, 38*h) then
            startEndJob()
            if menuJob == true then
                menuJob=false
                clickJob=false
                showCursor(false)
            end
        elseif isMouseIn(737*w, 643*h, 101*w, 38*h) then
            if menuJob == true then
                menuJob=false
                clickJob=false
                showCursor(false)
            end
        end
    end
    if potwierdzExit and btn == "left" and state == "down" then
        if isMouseIn(677*w, 558*h, 88*w, 40*h) then
            endJobExitVeh()
            showCursor(false)
            if bileciki == true then
                bileciki=false
            end
            potwierdzExit=false
            exports["srpg-noti"]:createAlert("info", "Zako?czy?e?/a? prace.")
        elseif isMouseIn(918*w, 558*h, 88*w, 40*h) then
            showCursor(false)
            potwierdzExit=false
        end
    end
    if bileciki and btn == "left" and state == "down" then
        if isMouseIn(186*w, 443*h, 316*w, 138*h) then
            if jakibilet ~= "normalny" then 
                triggerEvent("createAlert", localPlayer, "error", "Poda?e? z?y bilet klientowi!")
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
                return
            end
                triggerServerEvent("job:wyplata", localPlayer, "Autobusy")
                if getElementData(localPlayer,"player:premium") then
                    repkalos=math.random(3,8)
                else
                    repkalos=math.random(2,8)
                end
                if repkalos == 6 then
                if getElementData(localPlayer,"player:premium") then
                    ilerepki=math.random(2,6)
                else
                    ilerepki=math.random(1,3)
                end
                    setElementData(localPlayer,"player:reputation",getElementData(localPlayer,"player:reputation")+ilerepki)
                    triggerEvent("createAlert", localPlayer,"success","Otrzyma?e? "..ilerepki.." RP, za godn? podziwu prace.")
                end
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false 
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
        elseif isMouseIn(1208*w, 443*h, 316*w, 138*h) then
            if jakibilet ~= "ulgowy" then 
                triggerEvent("createAlert", localPlayer, "error", "Poda?e? z?y bilet klientowi!") 
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
                return
            end
                triggerServerEvent("job:wyplata", localPlayer, "Autobusy")
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-20, 15:53


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4147 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2178

Respekt: 110
Respekt: 110

Podaj stron? serwera.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-20, 16:03


smigi







Wiek: 23
Na forum: 3508 dni
Posty: 60
Nick w MP: smigi

Piwa: 2

Respekt: 50

muciu2404,
blipJob=createBlip(-2089.48, 84.21, 35.31, 46, 2, 255, 0, 0, 255, 0, 400)

autobus={}

addEvent("autobusy:topkazapis", true)
addEventHandler("autobusy:topkazapis", getRootElement(), function(topi)
    exports["srpg-db"]:dbSet("UPDATE srpg_konta SET topautobusy=? WHERE id=?", getElementData(source,"player:topautobusy")+topi, getElementData(source,"player:uid"))
    local topm=getElementData(source,"player:topautobusy")
    setElementData(source,"player:topautobusy", topm+topi)
end)

addEvent("autobusy:start", true)
addEventHandler("autobusy:start", getRootElement(), function()
    autobus[source]=createVehicle(431, -2095.30,94.81,35.43,359.5,0.0,90)
    setVehicleColor(autobus[source], 255, 255, 255, 5, 93, 31)
    setVehiclePlateText(autobus[source], "BUSY")
    setElementData(autobus[source], "autobus:veh", true)
    warpPedIntoVehicle(source, autobus[source])
    setVehicleLocked(autobus[source], true)
    triggerClientEvent("autobusy:kolizja", source, autobus[source])
end)

addEvent("autobus:delete", true)
addEventHandler("autobus:delete", getRootElement(), function()
    if isElement(autobus[source]) then
        destroyElement(autobus[source])
    end
end)

setTimer(function()
    for k,v in ipairs(getElementsByType("player")) do
        local veh=getPedOccupiedVehicle(v)
        if not veh and getElementData(v,"player:job") == "Autobusy" then
            setElementData(v,"player:job",false)
            if isElement(autobus[v]) then
                destroyElement(autobus[v])
            end
            triggerClientEvent(v,"createAlert",v,"info","Zako?czy?e?/a? prace.")
                        triggerClientEvent(v,"transport:unbindKeys",v)
        end
    end
end, 500, 0)

addEventHandler("onVehicleStartExit", resourceRoot, function()
    cancelEvent()
end)

addEventHandler("onVehicleExit", resourceRoot, function()
        triggerClientEvent(source, "autobusy:endJob", source)
end)

addEventHandler("onPlayerQuit", root, function()
    if isElement(autobus[source]) then
        destroyElement(autobus[source])
    end
end)

addEvent("autobusy:sprawdzPrawko", true)
addEventHandler("autobusy:sprawdzPrawko", root, function()
        local sprprawko = exports["srpg-db"]:dbGet("SELECT * FROM srpg_kary WHERE type=? AND active=1 and serial=? AND time>NOW() LIMIT 1","prawko", getPlayerSerial(source))
        if #sprprawko > 0 then
            setElementData(source,"player:block:prawko", true)
        else
            exports["srpg-db"]:dbSet("DELETE FROM srpg_kary WHERE type=? AND active=1 AND serial=?", "prawko", getPlayerSerial(source))
            setElementData(source,"player:block:prawko", false)
        end
end)

        
addEventHandler("onResourceStart", resourceRoot, function()
    for i,v in ipairs(getElementsByType("player")) do
        if getElementData(v,"player:job") == "Autobusy" then
            setElementData(v,"player:job", false)
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-20, 16:39


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4147 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2178

Respekt: 110
Respekt: 110

Strona klienta:
local sw, sh=guiGetScreenSize()
local w, h=(sw/1680), (sh/1050)
local font=dxCreateFont("f.ttf", 12)
local font2=dxCreateFont("f.ttf", 10)
local font3=dxCreateFont("f.ttf", 15)
local font4=dxCreateFont("f.ttf", 14)
local menuJob=false
local potwierdzExit=false
local praca="Autobusy"
local bileciki=false
local bilecikii=false
local ileos=0
local jakibilet="?"
startTick=getTickCount()

function isMouseIn( x, y, width, height )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end


przystanki={
{-2122.41,112.63,35.17},
{-2169.59,-26.66,35.17},
{-2260.83,-96.63,35.17},
{-2334.27,-187.85,35.17},
{-2369.71,15.27,35.16},
{-2249.44,274.71,35.16},
{-2224.04,482.04,35.02},
{-2192.46,562.47,35.02},
{-2007.88,409.30,35.02},
{-2086.54,322.91,35.02},
{-2149.06,229.84,35.17},
{-2086.71,62.46,34.56},
}

local przystanek
local przystanekTarget
local blip


addEvent("autobusy:kolizja", true)
addEventHandler("autobusy:kolizja", getRootElement(), function(v)
    for i,bus in ipairs(getElementsByType("vehicle")) do
            setElementCollidableWith(bus, v, false)
    end
end)

jobMarker=createMarker(-2089.61, 84.02, 35.31-1, "cylinder", 0.8, 0, 255, 0, 0)
setElementData(jobMarker,"icon", "job")

addEventHandler("onClientRender", getRootElement(), function()
    
    if bilecikii == true then
        dxDrawRectangle(0*w, 0*h, 1680*w, 1050*h, tocolor(8, 7, 7, 148), false)

        if isMouseIn(186*w, 443*h, 316*w, 138*h) then
            dxDrawImage(186*w, 443*h, 316*w, 138*h, "i/hovernormalny.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        else
            dxDrawImage(186*w, 443*h, 316*w, 138*h, "i/normalny.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end

        if isMouseIn(1208*w, 443*h, 316*w, 138*h) then
            dxDrawImage(1208*w, 443*h, 316*w, 138*h, "i/hoverulgowy.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        else
            dxDrawImage(1208*w, 443*h, 316*w, 138*h, "i/ulgowy.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end


        dxDrawText("Klient prosi o bilet "..jakibilet, 664*w, 396*h, 1043*w, 739*h, tocolor(255, 255, 255, 255), 1.00*w, font3, "center", "center", false, false, false, false, false)
    end
    
    if potwierdzExit == true then
        dxDrawImage(667*w, 427*h, 349*w, 181*h, "i/bg_potwierdz.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        if isMouseIn(677*w, 558*h, 88*w, 40*h) then
            dxDrawImage(677*w, 558*h, 88*w, 40*h, "i/tak.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(677*w, 558*h, 88*w, 40*h, "i/tak.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
        
        if isMouseIn(918*w, 558*h, 88*w, 40*h) then
            dxDrawImage(918*w, 558*h, 88*w, 40*h, "i/nie.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(918*w, 558*h, 88*w, 40*h, "i/nie.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
        
        dxDrawText("Jeste? pewny/a ?e chcesz zako?czy? prace?", 694*w, 451*h, 989*w, 543*h, tocolor(255, 255, 255, 255), 1.00*w, font, "center", "center", false, false, false, false, false)
    end
    
    if menuJob == true then
        dxDrawImage(549*w, 345*h, 578*w, 362*h, "i/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        
        dxDrawImage(865*w, 378*h, 229*w, 132*h, "i/jobimg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- zdj pracy
    
        
        if isMouseIn(574*w, 643*h, 101*w, 38*h) then
            dxDrawImage(574*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(574*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
        
        if isMouseIn(737*w, 643*h, 101*w, 38*h) then
            dxDrawImage(737*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
        else
            dxDrawImage(737*w, 643*h, 101*w, 38*h, "i/btn.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end
    
        
        dxDrawText("Twoje statystyki", 916*w, 528*h, 1047*w, 554*h, tocolor(255, 255, 255, 255), 1.00*w, font3, "center", "center", false, false, true, false, false)
        dxDrawText("Zaliczonych przystank?w: #70DB93"..getElementData(localPlayer,"player:topautobusy"), 873*w, 564*h, 1091*w, 681*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "top", false, false, true, true, false)
        dxDrawText(praca.."\n\nOpis\nCelem tej pracy jest przewo?enie os?b\nz przystanku na przystanek, oraz sprzedawanie im\nbilet?w.\n\nZarobki: Gracz: 1600-4600|Premium: 2500-6000", 564*w, 396*h, 847*w, 558*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "center", false, true, false, false, false)
        dxDrawText("Rozpocznij", 573*w, 643*h, 675*w, 681*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "center", false, false, false, false, false)
        dxDrawText("Zamknij", 736*w, 643*h, 838*w, 681*h, tocolor(255, 255, 255, 255), 1.00*w, font2, "center", "center", false, false, false, false, false)
    end
end)


function endJobExitVeh()
    setElementData(localPlayer, "player:job", false)
    triggerServerEvent("autobus:delete", localPlayer)
    unbindKey("F")
    unbindKey("enter")
    setTimer(function()
    setElementPosition(localPlayer, -2089.64, 87.49, 35.32)
    end, 200, 1)
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek = nil
    end
    if przystanekTarget and isElement(przystanekTarget) then
        destroyElement(przystanekTarget)
        przystanekTarget = nil
        przystanekTarget = 0

    end
    if blip and isElement(blip) then
        destroyElement(blip)
        blip=nil
    end
end

function endJob()
    setElementData(localPlayer, "player:job", false)
    triggerServerEvent("autobus:delete", localPlayer)
    unbindKey("F")
    unbindKey("enter")
    setTimer(function()
    end, 200, 1)
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek = nil
    end
    if przystanekTarget and isElement(przystanekTarget) then
        destroyElement(przystanekTarget)
        przystanekTarget = nil
        przystanekTarget = 0

    end
        if blip and isElement(blip) then
        destroyElement(blip)
        blip=nil
    end
end


function hitPrzystanek(el, md)
    if el ~= localPlayer or not md then return end
    local maxTarget = #przystanki
    if przystanekTarget > maxTarget and getPedOccupiedVehicle(el) then return end
    if przystanekTarget == maxTarget and not getPedOccupiedVehicle(el) then return end
    local sx,sy,sz=getElementVelocity(getPedOccupiedVehicle(el))
    local km = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
    if km > 20 then return end
    
    if przystanekTarget == #przystanki then
        endJob()
        triggerEvent("createAlert", el, "info", "Zako?czy?e?/a? prace.")
    else
        setElementFrozen(getPedOccupiedVehicle(el), true)
        ileos=math.random(1,4)
        randomBilet()
        bilecikii=true
        bileciki=true
        showCursor(true)
    end
end


function showPrzystanek()
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek=nil
    end
    if blip and isElement(blip) then 
        destroyElement(blip)
        blip=nil
    end
    
    przystanekTarget=przystanekTarget+1
    przystanek=createMarker(przystanki[przystanekTarget][1], przystanki[przystanekTarget][2], przystanki[przystanekTarget][3]-0.95, "cylinder", 2, 255, 255, 255, 0)
    blip=createBlip(przystanki[przystanekTarget][1], przystanki[przystanekTarget][2], przystanki[przystanekTarget][3], 41)
    setElementData(przystanek,"icon","busprzystanek")
    addEventHandler("onClientMarkerHit", przystanek, hitPrzystanek)
end

addEvent("transport:unbindKeys", true)
addEventHandler("transport:unbindKeys", getRootElement(), function()
    unbindKey("f")
    unbindKey("enter")
end)

addEvent("autobusy:endJob", true)
addEventHandler("autobusy:endJob", getRootElement(), function()
    setElementData(localPlayer, "player:job", false)
    triggerServerEvent("autobus:delete", localPlayer)
    unbindKey("F")
    unbindKey("enter")
    setTimer(function()
    end, 200, 1)
    if przystanek and isElement(przystanek) then
        destroyElement(przystanek)
        przystanek = nil
    end
    if przystanekTarget and isElement(przystanekTarget) then
        destroyElement(przystanekTarget)
        przystanekTarget = nil
        przystanekTarget = 0

    end
        if blip and isElement(blip) then
        destroyElement(blip)
        blip=nil
    end
end)

function startEndJob()
    triggerServerEvent("autobusy:sprawdzPrawko", localPlayer)
    if getElementData(localPlayer,"player:license:pjC") ~= 1 then triggerEvent("createAlert",localPlayer,"error","Nie posiadasz prawa jazdy kat.C!") return end
 if getElementData(localPlayer,"player:reputation") < 500 then triggerEvent("createAlert",localPlayer,"error","Nie posiadasz 500 RP") return end
    if getElementData(localPlayer,"player:block:prawko") then triggerEvent("createAlert", localPlayer, "error", "Posiadasz zawieszone prawa jazdy kat. A /B /C.") return end
        if not getElementData(localPlayer,"player:job") then
            setElementData(localPlayer,"player:job", praca)
            triggerServerEvent("autobusy:start", localPlayer)
            triggerEvent("createAlert",localPlayer,"success","Rozpocz??e?/a? prac?.")
            przystanekTarget=0
            showPrzystanek()
            bindKey("F", "down", exitGUI)
            bindKey("enter", "down", exitGUI)
        else
            exports["srpg-noti"]:createAlert("error", "Jeste? ju? gdzie? zatrudniony!")
        end
end

function exitGUI()
    if potwierdzExit==false then
    potwierdzExit=true
    showCursor(true,false)
    end
end

addEventHandler("onClientMarkerHit", jobMarker, function(el)
    if el ~= localPlayer then return end
    if isPedInVehicle(el) then return end
    if getElementData(el,"admin:devmode") == true then return end
    if menuJob == false then
        menuJob=true
        clickJob=true
        showCursor(true)
    end
end)

function randomBilet()
        bilet=math.random(1,2)
        if bilet == 1 then
            jakibilet="normalny"
        elseif bilet == 2 then
            jakibilet="ulgowy"
        end
end


addEventHandler("onClientClick", getRootElement(), function(btn,state)
    if clickJob and btn == "left" and state == "down" then
        if isMouseIn(574*w, 643*h, 101*w, 38*h) then
            startEndJob()
            if menuJob == true then
                menuJob=false
                clickJob=false
                showCursor(false)
            end
        elseif isMouseIn(737*w, 643*h, 101*w, 38*h) then
            if menuJob == true then
                menuJob=false
                clickJob=false
                showCursor(false)
            end
        end
    end
    if potwierdzExit and btn == "left" and state == "down" then
        if isMouseIn(677*w, 558*h, 88*w, 40*h) then
            endJobExitVeh()
            showCursor(false)
            if bileciki == true then
                bileciki=false
            end
            potwierdzExit=false
            exports["srpg-noti"]:createAlert("info", "Zako?czy?e?/a? prace.")
        elseif isMouseIn(918*w, 558*h, 88*w, 40*h) then
            showCursor(false)
            potwierdzExit=false
        end
    end
    if bileciki and btn == "left" and state == "down" then
        if isMouseIn(186*w, 443*h, 316*w, 138*h) then
            if jakibilet ~= "normalny" then 
                triggerEvent("createAlert", localPlayer, "error", "Poda?e? z?y bilet klientowi!")
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
                return
            end
                triggerServerEvent("job:wyplata", localPlayer, "Autobusy")
                if getElementData(localPlayer,"player:premium") then
                    repkalos=math.random(3,8)
                else
                    repkalos=math.random(2,8)
                end
                if repkalos == 6 then
                if getElementData(localPlayer,"player:premium") then
                    ilerepki=math.random(2,6)
                else
                    ilerepki=math.random(1,3)
                end
                    setElementData(localPlayer,"player:reputation",getElementData(localPlayer,"player:reputation")+ilerepki)
                    triggerEvent("createAlert", localPlayer,"success","Otrzyma?e? "..ilerepki.." RP, za godn? podziwu prace.")
                end
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false 
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
        elseif isMouseIn(1208*w, 443*h, 316*w, 138*h) then
            if jakibilet ~= "ulgowy" then 
                triggerEvent("createAlert", localPlayer, "error", "Poda?e? z?y bilet klientowi!") 
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
                return
            end
                triggerServerEvent("job:wyplata", localPlayer, "Autobusy")
                fadeCamera(false, 1.0, 0, 0, 0)
                bilecikii=false
                bileciki=false
                setTimer(function()
                    fadeCamera(true, 1.0, 0, 0, 0)
                    bilecikii=true
                    bileciki=true
                    randomBilet()
                    ileos=ileos-1
                    if ileos == 0 then bileciki=false  bilecikii=false showCursor(false) setElementFrozen(getPedOccupiedVehicle(localPlayer), false) showPrzystanek() triggerServerEvent("autobusy:topkazapis", localPlayer, 1) end
                end, 1000, 1)
        end
    end
end)

Strona serwera, b?dzie ci losowa?a w kt?rym miejscu ma spawnowa?:
blipJob=createBlip(-2089.48, 84.21, 35.31, 46, 2, 255, 0, 0, 255, 0, 400)

autobus={}

local spawn1 = {-2095.30,94.81,35.43}
local spawn2 = {-2097.30,94.81,35.43}

addEvent("autobusy:topkazapis", true)
addEventHandler("autobusy:topkazapis", getRootElement(), function(topi)
    exports["srpg-db"]:dbSet("UPDATE srpg_konta SET topautobusy=? WHERE id=?", getElementData(source,"player:topautobusy")+topi, getElementData(source,"player:uid"))
    local topm=getElementData(source,"player:topautobusy")
    setElementData(source,"player:topautobusy", topm+topi)
end)

addEvent("autobusy:start", true)
addEventHandler("autobusy:start", getRootElement(), function()
local rng = math.random(1,2)
if rng == 1 then
autobus[source] = createVehicle(431, spawn1[1],spawn1[2],spawn1[3],359.5,0.0,90)
elseif rng == 2 then 
autobus[source] = createVehicle(431, spawn2[1],spawn2[2],spawn2[3],359.5,0.0,90) end
    setVehicleColor(autobus[source], 255, 255, 255, 5, 93, 31)
    setVehiclePlateText(autobus[source], "BUSY")
    setElementData(autobus[source], "autobus:veh", true)
    warpPedIntoVehicle(source, autobus[source])
    setVehicleLocked(autobus[source], true)
    triggerClientEvent("autobusy:kolizja", source, autobus[source])
end)

addEvent("autobus:delete", true)
addEventHandler("autobus:delete", getRootElement(), function()
    if isElement(autobus[source]) then
        destroyElement(autobus[source])
    end
end)

setTimer(function()
    for k,v in ipairs(getElementsByType("player")) do
        local veh=getPedOccupiedVehicle(v)
        if not veh and getElementData(v,"player:job") == "Autobusy" then
            setElementData(v,"player:job",false)
            if isElement(autobus[v]) then
                destroyElement(autobus[v])
            end
            triggerClientEvent(v,"createAlert",v,"info","Zako?czy?e?/a? prace.")
                        triggerClientEvent(v,"transport:unbindKeys",v)
        end
    end
end, 500, 0)

addEventHandler("onVehicleStartExit", resourceRoot, function()
    cancelEvent()
end)

addEventHandler("onVehicleExit", resourceRoot, function()
        triggerClientEvent(source, "autobusy:endJob", source)
end)

addEventHandler("onPlayerQuit", root, function()
    if isElement(autobus[source]) then
        destroyElement(autobus[source])
    end
end)

addEvent("autobusy:sprawdzPrawko", true)
addEventHandler("autobusy:sprawdzPrawko", root, function()
        local sprprawko = exports["srpg-db"]:dbGet("SELECT * FROM srpg_kary WHERE type=? AND active=1 and serial=? AND time>NOW() LIMIT 1","prawko", getPlayerSerial(source))
        if #sprprawko > 0 then
            setElementData(source,"player:block:prawko", true)
        else
            exports["srpg-db"]:dbSet("DELETE FROM srpg_kary WHERE type=? AND active=1 AND serial=?", "prawko", getPlayerSerial(source))
            setElementData(source,"player:block:prawko", false)
        end
end)

        
addEventHandler("onResourceStart", resourceRoot, function()
    for i,v in ipairs(getElementsByType("player")) do
        if getElementData(v,"player:job") == "Autobusy" then
            setElementData(v,"player:job", false)
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-20, 17:19


smigi







Wiek: 23
Na forum: 3508 dni
Posty: 60
Nick w MP: smigi

Piwa: 2

Respekt: 50

muciu2404,
nie dzia?a nie moge rozpocz?? pracy

[ Dodano: 2019-02-20, 17:35 ]
resp pojazd?w dzia?a w dw?ch innych miejscach ale nie dzia?a rp jak zmieniam na to twoje to nie moge rozpocz??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-20, 17:58


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4147 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2178

Respekt: 110
Respekt: 110

"smigi" napisał/a:

muciu2404,
nie dzia?a nie moge rozpocz?? pracy

[ Dodano: 2019-02-20, 17:35 ]
resp pojazd?w dzia?a w dw?ch innych miejscach ale nie dzia?a rp jak zmieniam na to twoje to nie moge rozpocz??

Jak? masz element dat? od reputacji? Wy?wietla ci si? jaki? b??d w db3?

Postaw piwo autorowi tego posta
 

 
Tagi: praca :: autobusy
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