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

Wysłany: 2020-05-19, 23:26


HEATEX







Wiek: 25
Na forum: 2391 dni
Posty: 109
Nick w MP: HEATEX

Piwa: 1341

Respekt: 50

Ostrzeżeń: 20%
Witam mam prace busow lecz nie wiem czemu ale za jeden punkt nie dostaje sie rp
c.lua

sx, sy = guiGetScreenSize(  )

text = createElement( "text" )
setElementPosition( text, 1154.06, -1772.67, 16.60 )
setElementData( text, "name", "Kierowca autobusu\nZarobki:\nWymagania\n 600RP Prawo Jazdy Kat C." )

praca = createMarker( 1154.06, -1772.67, 15.6, "cylinder", 1 )
createBlipAttachedTo( praca, 46, 2, 255, 255, 255, 255, 0, 250 )

addEventHandler( "onClientRender", root, function()
    if isElementWithinMarker( localPlayer, praca ) then
        dxDrawImage( sx / 2 - 350 / 2, sy / 2 - 200 / 2, 350, 200, "panel.png" )
        if isMouseInPosition( sx / 2 - 112 / 2 - 60, sy / 2 - 64 / 2, 112, 64 ) then
            dxDrawImage( sx / 2 - 112 / 2 - 60, sy / 2 - 64 / 2, 112, 64, "miejska.png" )
        end
        if isMouseInPosition( sx / 2 - 112 / 2 + 60, sy / 2 - 64 / 2, 112, 64 ) then
            dxDrawImage( sx / 2 - 112 / 2 + 60, sy / 2 - 64 / 2, 112, 64, "pozamiejska.png" )
        end
        showCursor( true, false )
    else
        showCursor( false, false )
    end
end )

addEventHandler( "onClientClick", root, function( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement )
    if button == "left" and state == "down" then
        if isElementWithinMarker( localPlayer, praca ) then
            if isMouseInPosition( sx / 2 - 112 / 2 - 60, sy / 2 - 64 / 2, 112, 64 ) then
                if getElementData( localPlayer, "player:srp" ) < 600 then
                    exports["pystories-notifications"]:createAlert( "Nie posiadasz wymaganej reputacji. (0 RP)" )
                else
                    if getElementData( localPlayer, "player:license:pjC" ) ~= 1 and getElementData( localPlayer, "player:license:pjC" ) ~= true then
                        exports["pystories-notifications"]:createAlert( "Nie posiadasz prawajazdy kategorii C." )
                    else
                        triggerServerEvent ( "startujPrace", resourceRoot, localPlayer, "miejska" )
                    end
                end
            end
            if isMouseInPosition( sx / 2 - 112 / 2 + 60, sy / 2 - 64 / 2, 112, 64 ) then
                if getElementData( localPlayer, "player:srp" ) < 600  then
                    exports["pystories-notifications"]:createAlert( "Nie posiadasz wymaganej reputacji. (25 RP)" )
                else
                    triggerServerEvent ( "startujPrace", resourceRoot, localPlayer, "pozamiejska" )
                end
            end
        end
    end
end )

setTimer( function()
    for k,v in pairs( getElementsByType( "vehicle" ) ) do
        if getElementData( v, "disabledCols" ) then
            newalpha = 255
            lastAlpha = 255
            for _,v2 in pairs( getElementsByType( "vehicle" ) ) do
                if v ~= v2 then
                    x, y, z = getElementPosition( v )
                    x2, y2, z2 = getElementPosition( v2 )
                    dist = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 )
                    alpha = 255
                    if dist < 4 then
                        alpha = 100
                    elseif dist < 3 then
                        alpha = 40
                    elseif dist < 2 then
                        alpha = 10
                    end
                    if lastAlpha > alpha then newalpha = alpha end
                    setElementCollidableWith( v2, v, false )
                    setElementCollidableWith( v, v2, false )
                end
            end
            setElementAlpha( v, newalpha )
        end
    end
end, 1000, 0 )

addEvent( "wylaczKolizje", true )
addEventHandler( "wylaczKolizje", localPlayer, function( veh )
    for k,v in pairs( getElementsByType( "vehicle" ) ) do
        setElementCollidableWith( veh, v, false )
        setElementCollidableWith( v, veh, false )
    end
end )

function zakonczPrace()
    destroyElement( blip )
    destroyElement( markerPracy )
    triggerServerEvent( "koniecPracusi", resourceRoot, localPlayer )
    zadowolenie = 100
end

addEvent( "stopPracy", true )
addEventHandler( "stopPracy", localPlayer, zakonczPrace )

stacjeMiejskie = {
    {1171.75, -1776.29, 13.40, 359.929, 359.791, 270.153}, -- 431 - Bus
    {1171.63, -1842.31, 13.41, 359.787, 0.035, 179.761}, -- 431 - Bus
    {1107.45, -1848.31, 13.38, 359.795, 359.992, 90.625}, -- 431 - Bus
    {967.59, -1777.51, 14.10, 359.72, 359.991, 270.364}, -- 431 - Bus
    {921.53, -1708.64, 13.38, 359.785, 359.993, 270.046}, -- 431 - Bus
    {919.98, -1604.21, 13.38, 359.826, 359.995, 359.427}, -- 431 - Bus
    {945.44, -1576.13, 13.38, 359.839, 0.1, 269.616}, -- 431 - Bus
    {1042.62, -1543.01, 13.36, 359.697, 0.079, 84.082}, -- 431 - Bus
    {1064.12, -1441.36, 13.36, 359.794, 359.994, 89.668}, -- 431 - Bus
    {1095.27, -1408.79, 13.47, 359.779, 359.994, 75.487}, -- 431 - Bus
    {1217.72, -1408.50, 13.18, 359.557, 358.969, 90.556}, -- 431 - Bus
    {1328.30, -1408.44, 13.33, 359.557, 358.969, 90.556},
    {1337.58, -1441.03, 13.38, 359.557, 358.969, 90.556},
    {1294.83, -1613.01, 13.38, 359.557, 358.969, 90.556},
    {1284.79, -1708.92, 13.38, 359.557, 358.969, 90.556},
    {1211.14, -1725.36, 13.57, 359.557, 358.969, 90.556},
}

stacjePozaMiejskie = {
    {966.98, -1778.84, 14.10, 0.521, 358.938, 90.339}, -- 431 - Bus
    {903.01, -1769.80, 14.10, 358.818, 358.765, 90.083}, -- 431 - Bus
    {832.91, -1766.82, 13.40, 0.027, 355.101, 90.094}, -- 431 - Bus
    {769.54, -1763.35, 12.86, 359.984, 359.61, 89.362}, -- 431 - Bus
    {758.78, -1741.54, 11.69, 5.358, 0.19, 35.071}, -- 431 - Bus
    {755.11, -1606.44, 13.12, 359.149, 0.771, 148.639}, -- 431 - Bus
    {775.79, -1567.28, 13.38, 359.903, 0.002, 30.489}, -- 431 - Bus
    {799.59, -1462.85, 13.38, 359.818, 359.992, 350.89}, -- 431 - Bus
    {800.83, -1365.76, 13.38, 358.825, 0.011, 334.724}, -- 431 - Bus
    {800.60, -1252.14, 13.51, 356.962, 359.988, 334.236}, -- 431 - Bus
    {800.29, -1159.71, 23.74, 359.637, 0.054, 50}, -- 431 - Bus
    {798.91, -1075.90, 24.23, 359.791, 359.996, 29.244}, -- 431 - Bus
    {815.29, -1054.51, 24.92, 359.958, 359.959, 267.973}, -- 431 - Bus
    {863.45, -1016.47, 30.34, 1.603, 359.941, 269.974}, -- 431 - Bus
    {907.96, -987.89, 37.63, 0.178, 0.075, 269.783}, -- 431 - Bus
    {976.90, -973.45, 39.38, 1.803, 3.625, 358.809}, -- 431 - Bus
    {961.48, -945.59, 40.31, 359.884, 359.991, 90.059}, -- 431 - Bus
    {863.56, -889.31, 64.88, 359.791, 359.982, 90.274}, -- 431 - Bus
    {829.25, -872.35, 68.79, 359.78, 359.996, 179.87}, -- 431 - Bus
    {778.87, -904.81, 56.52, 359.974, 0.827, 181.154}, -- 431 - Bus
    {735.45, -956.61, 54.27, 359.934, 0.245, 180.276}, -- 431 - Bus
    {714.47, -984.72, 52.60, 359.62, 359.3, 180.132}, -- 431 - Bus
    {699.89, -993.69, 52.60, 359.81, 359.996, 268.786}, -- 431 - Bus
    {661.34, -924.38, 44.11, 359.142, 359.977, 180.044}, -- 431 - Bus
    {624.07, -809.37, 21.56, 357.495, 359.995, 183.594}, -- 431 - Bus
    {610.13, -721.83, 13.02, 357.325, 359.564, 178.75}, -- 431 - Bus
    {624.55, -700.84, 12.23, 359.917, 359.989, 268.255}, -- 431 - Bus
    {661.15, -699.44, 15.29, 0, 0, 269.266}, -- 431 - Bus
    {690.12, -838.83, 43.22, 0, 0, 0.775}, -- 431 - Bus
    {721.52, -881.17, 43.32, 0, 0, 0.775},
    {790.19, -938.55, 41.97, 0, 0, 0.775},
    {792.74, -1028.91, 25.39, 0, 0, 0.775},
    {792.28, -1069.50, 24.47, 0, 0, 0.775},
    {794.59, -1168.66, 22.92, 0, 0, 0.775},
    {794.87, -1344.12, 13.38, 0, 0, 0.775},
    {793.04, -1444.43, 13.38, 0, 0, 0.775},
    {774.89, -1539.77, 13.38, 0, 0, 0.775},
    {747.46, -1598.04, 13.84, 0, 0, 0.775},
    {752.85, -1751.14, 12.70, 0, 0, 0.775},
    {755.01, -1783.87, 12.84, 0, 0, 0.775},
}

function nastepnyMarkerMiejska( idMarkeru )
    p = stacjeMiejskie[idMarkeru]
        if p then
        markerPracy = createMarker( p[1], p[2], p[3], "cylinder", 3 )
        blip = createBlipAttachedTo( markerPracy, 41 )
    else
        zakonczPrace()
    end
end

function nastepnyMarkerPozamiejska( idMarkeru )
    p = stacjePozaMiejskie[idMarkeru]
        if p then
        markerPracy = createMarker( p[1], p[2], p[3], "cylinder", 3 )
        blip = createBlipAttachedTo( markerPracy, 41 )
    else
        zakonczPrace()
    end
end

function sprawdzBilet( liczba )
    if bilet == liczba then
        jeszczeJeden = math.random( 1, 4 )
        if jeszczeJeden == 1 then
            exports["pystories-notifications"]:createAlert( "Podajesz bilet." )
            bx, by, bx2, by2 = sx / 2 - 235, sy / 2 - 85, sx / 2 - 235, sy / 2 + 10
            bilet = math.random( 1, 2 )
        else
            exports["pystories-notifications"]:createAlert( "Podajesz bilet." )
            removeEventHandler( "onClientRender", root, bilety )
        end
        if typPracy == "miejska" then
            zadowoleniee = zadowolenie + 30
            if zadowoleniee > 100 then zadowoleniee = 100 end
            triggerServerEvent( "givePlayerMoney", localPlayer, 50000 * (zadowoleniee / 100) )
        else
            triggerServerEvent( "givePlayerMoney", localPlayer, 50000 * (zadowoleniee / 100) )
        end
    else
        exports["pystories-notifications"]:createAlert( "Podano z?y bilet." )
        zadowolenie = zadowolenie - 10
        bx, by, bx2, by2 = sx / 2 - 235, sy / 2 - 85, sx / 2 - 235, sy / 2 + 10
    end
end

function bilety(  )
    if pracuje then
        showCursor( true )

        dxDrawRectangle( sx / 2 - 250, sy / 2 - 100, 500, 200, tocolor( 0, 0, 0, 155 ) )
        dxDrawRectangle( sx / 2 + 50, sy / 2 - 100, 200, 200, tocolor( 0, 0, 0, 155 ) )

        dxDrawImage( bx, by, 165, 75, "normalny.jpg" )
        dxDrawImage( bx2, by2, 165, 75, "ulgowy.jpg" )

        if bilet == 1 then
            dxDrawText( "Klient prosi o Bilet normalny", 0, 520, sx, sy, white, 1.5, "default-bold", "center" )
        else
            dxDrawText( "Klient prosi o Bilet ulgowy", 0, 520, sx, sy, white, 1.5, "default-bold", "center" )
        end

        if isMouseInPosition( bx, by, 165, 75 ) and getKeyState( "mouse1" ) then
            cx, cy = getCursorPosition(  )
            cx, cy = cx * sx, cy * sy
            bx, by = cx - 165 / 2, cy - 75 / 2
            if bx > sx / 2 + 50 and bx < sx / 2 + 100 and by > sy / 2 - 100 and by < sy / 2 + 100 then
                sprawdzBilet( 1 )
            end
        elseif isMouseInPosition( bx2, by2, 165, 75 ) and getKeyState( "mouse1" ) then
            cx, cy = getCursorPosition(  )
            cx, cy = cx * sx, cy * sy
            bx2, by2 = cx - 165 / 2, cy - 75 / 2
            if bx2 > sx / 2 + 50 and bx2 < sx / 2 + 100 and by2 > sy / 2 - 100 and by2 < sy / 2 + 100 then
                sprawdzBilet( 2 )
            end
        end
    end
end

function biletF(  )
    addEventHandler( "onClientRender", root, bilety )
    bilet = math.random( 1, 2 )
    setElementVelocity( getPedOccupiedVehicle( localPlayer ), 0, 0, 0 )
    bx, by, bx2, by2 = sx / 2 - 235, sy / 2 - 85, sx / 2 - 235, sy / 2 + 10
end

addEventHandler( "onClientMarkerHit", root, function( plr, dim )
    if plr == localPlayer then
        if source == markerPracy then
            aktualnyMarker = aktualnyMarker + 1
            destroyElement( markerPracy )
            destroyElement( blip )
            zadowolenie = zadowolenie + 30
            biletF()
            if typPracy == "miejska" then
                nastepnyMarkerMiejska( aktualnyMarker )
            else
                nastepnyMarkerPozamiejska( aktualnyMarker )
            end
        end
    end
end )

addEventHandler( "onClientVehicleDamage", root, function(t, te, loss)
    if pracuje then
        zadowolenie = zadowolenie - loss / 10
    end
end )

pracuje = false
zadowolenie = 100

addEvent( "startPracy", true )
addEventHandler( "startPracy", localPlayer, function( veh, typ )
    if typ == "miejska" then
        aktualnyMarker = 1
        nastepnyMarkerMiejska( aktualnyMarker )
        pracuje = true
        zadowolenie = 100
    end
    if typ == "pozamiejska" then
        aktualnyMarker = 1
        nastepnyMarkerPozamiejska( aktualnyMarker )
        pracuje = true
        zadowolenie = 100
    end
    typPracy = typ
end )

addEventHandler( "onClientRender", root, function()
    if pracuje then
        dxDrawRectangle( sx / 2 - 125, 10, 250, 50, tocolor( 0, 0, 0, 155 ) )
        if zadowolenie > 70 then
            ztt = "Pasa?erowie s? zadowoleni!"
        elseif zadowolenie <= 70 and zadowolenie > 40 then
            ztt = "Pasa?erowie s? neutralni."
        else
            ztt = "Pasa?erowie s? ?li!" 
        end
        if zadowolenie < 0 then zadowolenie = 0 end
        if zadowolenie > 100 then zadowolenie = 100 end
        dxDrawText( ztt .. "\n" .. math.floor(zadowolenie) .. "%", sx / 2 - 16, 35 - 16, sx / 2 + 16, 35 + 16, white, 1, "default-bold", "center", "center" )
    end
end )

setTimer( function()
    zadowolenie = zadowolenie - 1
end, 1000, 0 )

function isMouseInPosition ( 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

s.lua

veh = {}

miejscaSpawnu = {
    {1075.73, -1714.92, 13.45, 359.4, 0.0, 269.6}, -- 431 - Bus
}

function deleteColisionsWithVehicles( veh )
    setElementData( veh, "disabledCols", true )
    for k,p in pairs( getElementsByType( "player" ) ) do
        triggerClientEvent( p, "wylaczKolizje", p, veh )
    end
end

addEvent( "koniecPracusi", true )
addEventHandler( "koniecPracusi", resourceRoot, function( plr )
    if veh[plr] then
        destroyElement( veh[plr] )
        veh[plr] = nil
    end
end )

addEvent( "startujPrace", true )
addEventHandler( "startujPrace", resourceRoot, function( plr, typ )
    if not veh[plr] then
        L = math.random( 1, #miejscaSpawnu )
        m = miejscaSpawnu[L]
        if typ == "miejska" then
            veh[plr] = createVehicle( 431, m[1], m[2], m[3], m[4], m[5], m[6] )
        else
            veh[plr] = createVehicle( 437, m[1], m[2], m[3], m[4], m[5], m[6] )
        end
        setVehicleColor( veh[plr], 79, 11, 0, 155, 94, 2 )
        setElementData( veh[plr], "plr", plr )
        setElementFrozen( veh[plr], true )
        warpPedIntoVehicle( plr, veh[plr], 0 )
        setVehicleHandling( veh[plr], "maxVelocity", 50 )
        deleteColisionsWithVehicles( veh[plr] )
        triggerClientEvent( plr, "startPracy", plr, veh, typ )
    end
end )

addEventHandler( "onPlayerVehicleExit", root, function( vehH )
    if getElementData( vehH, "plr" ) == source then
        destroyElement( vehH )
        veh[source] = nil
        triggerClientEvent( source, "stopPracy", source )
    end
end )


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-05-20, 01:29


PatryKK.

Emeryt LUA






Wiek: 27
Na forum: 3202 dni
Posty: 1059
Nick w MP: PatryKK.

Piwa: 2331

Respekt: 331,5
Respekt: 331,5Respekt: 331,5Respekt: 331,5

addEventHandler( "onClientMarkerHit", root, function( plr, dim )
    if plr == localPlayer then
        if source == markerPracy then
            aktualnyMarker = aktualnyMarker + 1
            destroyElement( markerPracy )
            destroyElement( blip )
            getElementData(source, "player:srp"+1) 
            zadowolenie = zadowolenie + 30
            biletF()
            if typPracy == "miejska" then
                nastepnyMarkerMiejska( aktualnyMarker )
            else
                nastepnyMarkerPozamiejska( aktualnyMarker )
            end
        end
    end
end )


Postaw piwo autorowi tego posta
 

 
Tagi: busy :: nie :: daje
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