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

Wysłany: 2017-03-19, 10:17


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

Jak zrobi? by po ?mierci gracza praca by si? k?czy?a??? Bo teraz po ?mierci praca si? nie k?czy si?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-03-19, 10:32


2002kondzior







Wiek: 27
Na forum: 3976 dni
Posty: 36

Piwa: 6

Respekt: 70

Musisz to zrobi? przy u?yciu onPlayerWasted, przyk?ad:

addEventHandler("onPlayerWasted", getRootElement(), function()
--Tutaj dajesz setElementDate kt?ra usunie Ci prace (je?eli masz inna to sobie zmie?)
if not getElementData(source, "praca") then return end
 setElementData(source, "praca",false)
end
)

Nie testowane, oraz pisane z telefonu wi?c mog? by? b??dy.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-03-19, 10:58


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

strona s

local m1 = createMarker(-1754.22,964.12,23.89, "cylinder", 2.0, 17, 131, 237)
vehs = {}

function removePreviousVehicles(plr)
    for i,v in ipairs(getElementsByType("vehicle", resourceRoot)) do
        local sby = getElementData(v, "zrespilGracz")
        if sby and sby == plr and getPedOccupiedVehicle(plr) ~= v then
            destroyElement(v)
        end
    end
end

addEvent("givePlayerMoney", true) 
addEventHandler("givePlayerMoney", resourceRoot, function(ile) 
givePlayerMoney (client, ile)
end)

addEventHandler("onMarkerHit", m1, function(el, md)
    if getElementData(el, "zrespilGracz") then
        outputChatBox("praca w trakcie poprawek", el)
        return
    end
    
    if not md or getElementType(el) ~= "player" or getPedOccupiedVehicle(el) then return end
    
    local x,y,z = getElementPosition(el)
    local bus = createVehicle(431,-1757.49,954.45,24.85,0,0,90)
    
    setElementData(bus, "zrespilGracz", el)
    setVehicleColor(bus, 255, 0, 0, 255, 0, 0 )
    setElementData(bus, "pojazd_paliwo", 50)
    setElementData(bus, "pojazd_przebieg", 100)
    setVehicleHandling(bus, "maxVelocity", 60 )
    setElementData(bus, "vopis", "Praca kierowcy autobusu")
    setVehiclePlateText(bus,"Autobus")
    
    
    
    
    warpPedIntoVehicle(el, bus)
    removePreviousVehicles(el)
    triggerClientEvent(el, "STARTJobBus", resourceRoot, bus)

    vehs[el] = bus
end)

addEvent("STOPJobBus", true)
addEventHandler("STOPJobBus", resourceRoot, function()
    setElementData(el, "praca")
    local pojazd = getPedOccupiedVehicle(localPlayer)
    if pojazd then
        destroyElement(pojazd)
    end
end)

addEvent("destroyVeh", true)
addEventHandler("destroyVeh", getRootElement(),
function()
     if vehs[source] then
          if isElement(vehs[source]) then destroyElement(vehs[source]) end
     end
end)



local districtsBus = {}

local districtsBus1 = {
    {2106.68,2467.57,10.92},
    {2043.26,2455.32,10.77},
    {2025.24,2384.74,10.82},
    {2097.76,2290.12,10.77},
    {2125.61,2169.93,10.77},
    {2125.50,1983.68,10.78},
    {2107.15,1827.24,10.78},
    {2045.58,1648.45,10.77},
    {2045.91,1547.20,10.77},
    {2210.57,1530.78,10.77},
    {2350.16,1531.12,10.78},
    {2365.45,1392.41,10.78},
    {2491.02,1371.06,10.86},
    {2607.29,1371.00,10.77},
    {2625.53,1273.58,10.77},
    {2506.33,1255.30,10.78},
    {2443.88,1255.58,10.78},
    {2424.74,1210.81,10.77},
    {2424.98,1091.13,10.77},
    {2363.82,1075.05,10.77},
    {2349.38,1175.19,10.78},
    {2240.09,1195.53,10.79},
    {2091.55,1195.79,10.77},
    {2069.31,1248.71,10.77},
    {2069.55,1398.83,10.77},
    {2069.73,1513.50,10.78},
    {2069.89,1618.59,10.78},
    {2107.62,1779.53,10.78},
    {2149.34,1970.12,10.77},
    {2149.77,2156.43,10.77},
    {2203.02,2338.41,10.76},
    {2230.07,2432.58,10.77},
    {2186.17,2455.72,10.77},
    {2138.77,2516.29,10.92},
    
}

local districtsBus2 = {
    {2088.10,2458.74,10.47},
    {2024.99,2406.51,10.41},
    {1921.68,2351.98,10.47},
    {1869.25,2276.25,10.40},
    {1723.56,2247.31,10.40},
    {1750.90,2047.64,10.58},
    {1825.85,2067.68,10.55},
    {1786.97,2170.80,10.50},
    {1921.94,2115.87,10.48},
    {2049.00,2019.49,10.40},
    {2194.27,2016.54,10.47},
    {2354.84,2039.23,10.39},
    {2360.87,2170.58,10.45},
    {2406.26,2230.47,10.41},
    {2430.04,2340.74,10.40},
    {2391.93,2418.98,10.47},
    {2293.81,2414.25,10.49},
    {2179.47,2455.94,10.40},
    {2106.64,2460.02,10.46},
    {2147.70,2487.17,10.55},
    
}

local districtsBus3 = {
{2082.79,2458.85,10.47},
{2024.77,2405.14,10.41},
{1921.79,2314.45,10.47},
{1912.49,2276.11,10.40},
{1660.49,2275.98,10.40},
{1570.50,2298.54,10.40},
{1488.55,2395.37,10.41},
{1480.21,2535.62,10.40},
{1439.91,2592.39,10.40},
{1250.20,2623.11,10.40},
{1469.58,2699.05,10.40},
{1530.68,2710.64,10.41},
{1592.49,2730.10,10.40},
{1757.06,2707.61,10.47},
{1904.31,2702.04,10.30},
{2014.62,2642.77,10.30},
{2024.79,2411.11,10.30},
{2119.78,2081.68,10.30},
{2102.66,1819.05,10.30},
{2003.83,1716.01,10.30},
{1876.03,1734.98,10.29},
{1798.88,1868.43,6.34},
{1791.28,1790.62,6.36},
{1791.15,1427.15,6.37},
{1791.22,1261.11,6.36},
{1790.99,867.22,10.16},
{1841.86,837.48,9.50},
{2100.77,837.42,6.37},
{2475.53,839.16,6.36},
{2701.55,1013.85,6.36},
{2729.61,1304.82,6.36},
{2766.05,1397.12,8.34},
{2782.40,1475.45,10.30},
{2585.38,1475.71,10.30},
{2441.19,1475.90,10.30},
{2424.47,1406.99,10.30},
{2425.11,1217.02,10.30},
{2459.92,1190.14,10.30},
{2523.96,1163.61,10.30},
{2574.65,1070.61,10.30},
{2579.76,1016.35,10.30},
{2544.54,976.76,10.30},
{2544.88,787.07,10.30},
{2597.99,770.13,10.30},
{2610.00,695.44,10.30},
{2510.53,713.50,10.30},
{2454.36,775.22,10.30},
{2356.44,715.72,10.30},
{2289.23,797.38,11.30},
{2289.69,960.13,10.30},
{2350.19,981.47,10.30},
{2350.27,1060.11,10.30},
{2323.56,1195.62,10.30},
{2229.30,1206.79,10.37},
{2229.58,1359.75,10.36},
{2249.41,1386.86,10.37},
{2266.83,1530.55,10.30},
{2330.28,1597.85,10.30},
{2304.78,1775.52,10.30},
{2111.87,1788.61,10.30},
{2149.84,2052.70,10.30},
{2176.22,2302.86,10.29},
{2229.43,2440.81,10.30},
{2140.40,2455.54,10.30},
{2106.71,2467.28,10.45},
{2147.11,2494.24,10.45},
}


local jobBlip
local jobTarget
local jobMarker
local jobVehicle
local maxTarget = #districtsBus

function finishJob()
    if isElement(jobBlip) then
        destroyElement(jobBlip)
        jobBlip=nil
    end
    if jobMarker and isElement(jobMarker) then
        destroyElement(jobMarker)
        jobMarker = nil
        triggerServerEvent("givePlayerMoney",resourceRoot,10)
    end
    
    if jobTarget and isElement(jobTarget) then
        destroyElement(jobTarget)
        jobTarget = nil
        jobTarget = 0
        jobBlip=nil
        
    end
    
triggerServerEvent("destroyVeh", localPlayer)

end


function busDriver(el, md)
    if el ~= localPlayer or not md then return end
    if jobTarget > maxTarget and getPedOccupiedVehicle(el) then return end
    if jobTarget == maxTarget and not getPedOccupiedVehicle(el) then return end
    triggerServerEvent("givePlayerMoney",resourceRoot,10)
    setElementData(el, "GP", getElementData(el, "GP") + math.random (0,1) )
    outputChatBox("[INFO] Otrzymujesz 10Z?.", 0, 155, 255)
    
    if jobTarget == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        destroyElement(blip)
        outputChatBox("[INFO] Koniec trasy ", 0, 155, 255)
    else
        showMarker()
        playSoundFrontEnd(12)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarker) then
        destroyElement(jobMarker)
        destroyElement(blip)
        jobMarker = nil
    end
    
    jobTarget = jobTarget + 1
    jobMarker = createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint", 2.5, 0, 155, 255)
    blip = createBlipAttachedTo(jobMarker, 12)
    
    if districtsBus[jobTarget+1] then
        ile = districtsBus[jobTarget+1]
        setMarkerTarget(jobMarker, ile[1], ile[2], ile[3])
    end
    
    addEventHandler("onClientMarkerHit", jobMarker,  busDriver)
end

addEvent("STARTJobBus", true)
addEventHandler("STARTJobBus", resourceRoot, function(veh)
        trasa = math.random(1,3)
    if trasa==1 then
       districtsBus = districtsBus1
    elseif trasa==2 then
        districtsBus = districtsBus2
    elseif trasa==3 then
        districtsBus = districtsBus3
    end
    maxTarget = #districtsBus
    outputChatBox("[Pracodawca] Rozpoczٳeܠpracꡋierowcy Autobusu.", 0, 155, 255)
    jobVehicle = veh
    jobTarget = 0
    showMarker()
end)

addEventHandler("onClientResourceStop", resourceRoot, function()
    if jobVehicle and getElementData(localPlayer, "gracz_praca") then
        setElementData(localPlayer, "gracz_praca", false)
    end
end)


addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
    if seat == 0 then
        if plr == localPlayer then
            finishJob()
            destroyElement(blip)
            outputChatBox("[Pracodawca] Wyszedԥܠz autobusu, praca zostaԡ zako񣺯na.", 0, 155, 255)
        end
    end
end)

jak to tu wstawi? bo nie moge co? mi nie wychodzi ??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-03-19, 20:28


2002kondzior







Wiek: 27
Na forum: 3976 dni
Posty: 36

Piwa: 6

Respekt: 70

Troch? si? pomyli?em co do tego. Tutaj kod, powinien dzia?a?:

local districtsBus = {}

local districtsBus1 = {
    {2106.68,2467.57,10.92},
    {2043.26,2455.32,10.77},
    {2025.24,2384.74,10.82},
    {2097.76,2290.12,10.77},
    {2125.61,2169.93,10.77},
    {2125.50,1983.68,10.78},
    {2107.15,1827.24,10.78},
    {2045.58,1648.45,10.77},
    {2045.91,1547.20,10.77},
    {2210.57,1530.78,10.77},
    {2350.16,1531.12,10.78},
    {2365.45,1392.41,10.78},
    {2491.02,1371.06,10.86},
    {2607.29,1371.00,10.77},
    {2625.53,1273.58,10.77},
    {2506.33,1255.30,10.78},
    {2443.88,1255.58,10.78},
    {2424.74,1210.81,10.77},
    {2424.98,1091.13,10.77},
    {2363.82,1075.05,10.77},
    {2349.38,1175.19,10.78},
    {2240.09,1195.53,10.79},
    {2091.55,1195.79,10.77},
    {2069.31,1248.71,10.77},
    {2069.55,1398.83,10.77},
    {2069.73,1513.50,10.78},
    {2069.89,1618.59,10.78},
    {2107.62,1779.53,10.78},
    {2149.34,1970.12,10.77},
    {2149.77,2156.43,10.77},
    {2203.02,2338.41,10.76},
    {2230.07,2432.58,10.77},
    {2186.17,2455.72,10.77},
    {2138.77,2516.29,10.92},
    
}

local districtsBus2 = {
    {2088.10,2458.74,10.47},
    {2024.99,2406.51,10.41},
    {1921.68,2351.98,10.47},
    {1869.25,2276.25,10.40},
    {1723.56,2247.31,10.40},
    {1750.90,2047.64,10.58},
    {1825.85,2067.68,10.55},
    {1786.97,2170.80,10.50},
    {1921.94,2115.87,10.48},
    {2049.00,2019.49,10.40},
    {2194.27,2016.54,10.47},
    {2354.84,2039.23,10.39},
    {2360.87,2170.58,10.45},
    {2406.26,2230.47,10.41},
    {2430.04,2340.74,10.40},
    {2391.93,2418.98,10.47},
    {2293.81,2414.25,10.49},
    {2179.47,2455.94,10.40},
    {2106.64,2460.02,10.46},
    {2147.70,2487.17,10.55},
    
}

local districtsBus3 = {
{2082.79,2458.85,10.47},
{2024.77,2405.14,10.41},
{1921.79,2314.45,10.47},
{1912.49,2276.11,10.40},
{1660.49,2275.98,10.40},
{1570.50,2298.54,10.40},
{1488.55,2395.37,10.41},
{1480.21,2535.62,10.40},
{1439.91,2592.39,10.40},
{1250.20,2623.11,10.40},
{1469.58,2699.05,10.40},
{1530.68,2710.64,10.41},
{1592.49,2730.10,10.40},
{1757.06,2707.61,10.47},
{1904.31,2702.04,10.30},
{2014.62,2642.77,10.30},
{2024.79,2411.11,10.30},
{2119.78,2081.68,10.30},
{2102.66,1819.05,10.30},
{2003.83,1716.01,10.30},
{1876.03,1734.98,10.29},
{1798.88,1868.43,6.34},
{1791.28,1790.62,6.36},
{1791.15,1427.15,6.37},
{1791.22,1261.11,6.36},
{1790.99,867.22,10.16},
{1841.86,837.48,9.50},
{2100.77,837.42,6.37},
{2475.53,839.16,6.36},
{2701.55,1013.85,6.36},
{2729.61,1304.82,6.36},
{2766.05,1397.12,8.34},
{2782.40,1475.45,10.30},
{2585.38,1475.71,10.30},
{2441.19,1475.90,10.30},
{2424.47,1406.99,10.30},
{2425.11,1217.02,10.30},
{2459.92,1190.14,10.30},
{2523.96,1163.61,10.30},
{2574.65,1070.61,10.30},
{2579.76,1016.35,10.30},
{2544.54,976.76,10.30},
{2544.88,787.07,10.30},
{2597.99,770.13,10.30},
{2610.00,695.44,10.30},
{2510.53,713.50,10.30},
{2454.36,775.22,10.30},
{2356.44,715.72,10.30},
{2289.23,797.38,11.30},
{2289.69,960.13,10.30},
{2350.19,981.47,10.30},
{2350.27,1060.11,10.30},
{2323.56,1195.62,10.30},
{2229.30,1206.79,10.37},
{2229.58,1359.75,10.36},
{2249.41,1386.86,10.37},
{2266.83,1530.55,10.30},
{2330.28,1597.85,10.30},
{2304.78,1775.52,10.30},
{2111.87,1788.61,10.30},
{2149.84,2052.70,10.30},
{2176.22,2302.86,10.29},
{2229.43,2440.81,10.30},
{2140.40,2455.54,10.30},
{2106.71,2467.28,10.45},
{2147.11,2494.24,10.45},
}


local jobBlip
local jobTarget
local jobMarker
local jobVehicle
local maxTarget = #districtsBus

function finishJob()
    if isElement(jobBlip) then
        destroyElement(jobBlip)
        jobBlip=nil
    end
    if jobMarker and isElement(jobMarker) then
        destroyElement(jobMarker)
        jobMarker = nil
        triggerServerEvent("givePlayerMoney",resourceRoot,10)
    end
    
    if jobTarget and isElement(jobTarget) then
        destroyElement(jobTarget)
        jobTarget = nil
        jobTarget = 0
        jobBlip=nil
        
    end
    
triggerServerEvent("destroyVeh", localPlayer)

end


function busDriver(el, md)
    if el ~= localPlayer or not md then return end
    if jobTarget > maxTarget and getPedOccupiedVehicle(el) then return end
    if jobTarget == maxTarget and not getPedOccupiedVehicle(el) then return end
    triggerServerEvent("givePlayerMoney",resourceRoot,10)
    setElementData(el, "GP", getElementData(el, "GP") + math.random (0,1) )
    outputChatBox("[INFO] Otrzymujesz 10Z?.", 0, 155, 255)
    
    if jobTarget == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        destroyElement(blip)
        outputChatBox("[INFO] Koniec trasy ", 0, 155, 255)
    else
        showMarker()
        playSoundFrontEnd(12)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarker) then
        destroyElement(jobMarker)
        destroyElement(blip)
        jobMarker = nil
    end
    
    jobTarget = jobTarget + 1
    jobMarker = createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint", 2.5, 0, 155, 255)
    blip = createBlipAttachedTo(jobMarker, 12)
    
    if districtsBus[jobTarget+1] then
        ile = districtsBus[jobTarget+1]
        setMarkerTarget(jobMarker, ile[1], ile[2], ile[3])
    end
    
    addEventHandler("onClientMarkerHit", jobMarker,  busDriver)
end

addEvent("STARTJobBus", true)
addEventHandler("STARTJobBus", resourceRoot, function(veh)
        trasa = math.random(1,3)
    if trasa==1 then
       districtsBus = districtsBus1
    elseif trasa==2 then
        districtsBus = districtsBus2
    elseif trasa==3 then
        districtsBus = districtsBus3
    end
    maxTarget = #districtsBus
    outputChatBox("[Pracodawca] Rozpoczٳeܠpracꡋierowcy Autobusu.", 0, 155, 255)
    jobVehicle = veh
    jobTarget = 0
    showMarker()
end)

addEventHandler("onClientResourceStop", resourceRoot, function()
    if jobVehicle and getElementData(localPlayer, "gracz_praca") then
        setElementData(localPlayer, "gracz_praca", false)
    end
end)


addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
    if seat == 0 then
        if plr == localPlayer then
            finishJob()
            destroyElement(blip)
            outputChatBox("[Pracodawca] Wyszedԥܠz autobusu, praca zostaԡ zako񣺯na.", 0, 155, 255)
        end
    end
end)

addEventHandler("onClientPlayerWasted", getLocalPlayer(), function()
    finishJob()
    setElementData(localPlayer, "gracz_praca", false)
    destroyElement(blip)
end)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
polaczkos
Wysłany: 2017-03-20, 15:26


polaczkos







Wiek: 26
Na forum: 4226 dni
Posty: 168
Nick w MP: polaczkos

Piwa: 3

Respekt: 45,3

Dzi?ki dzia?a leci respekt i piwko :D

Postaw piwo autorowi tego posta
 

 
Tagi: zakączenie :: pracy :: śmierci
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