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

Wysłany: 2015-09-25, 22:32


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
Siema. Mam problem z usuwaniem autobusu, poniewa? jak kto? z niego wyjdzie (i chyba jak uko?czy prac?), to pojazd si? nie usuwa i taki ?mietnik si? robi. B??d w db3 jest taki, i? nie mo?e znale?? eventu "destroyVeh" po stronie serwera :-? . Jak przecie? jesy dodany.. Wie kto? o co chodzi? Stawiam :piwo:

S-side

--[[
Praca rybaka

@copyright 2013-2014 Split <split@go-life.pl>
@author Split <split@go-life.pl>

Nie masz prawa u?ywac tego kodu bez mojej zgody.
Napisz do mnie by? mo?e si? zgodz? na u?ycie kodu.
]]--
createBlip(-1755.05, 951.73, 23.74,52, 2, 255,0,0,255,0,400)
local m1 = createMarker(-1755.05, 951.73, 23.74, "cylinder", 4.0, 255, 0, 0)
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

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(437, x,y,z,0.0, 360.0, 269.9)
    
    setElementData(bus, "zrespilGracz", el)
    setElementData(bus, "pojazd_paliwo", 50)
    setElementData(bus, "pojazd_przebieg", 100)
    
    warpPedIntoVehicle(el, bus)
    removePreviousVehicles(el)
    triggerClientEvent(el, "STARTJobBus", resourceRoot, bus)

    vehs[el] = bus
end)

addEvent("STOPJobBus", true)
addEventHandler("STOPJobBus", resourceRoot, function()
    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)



C-side:

--[[
Praca busa

@copyright 2013-2014 Split <split@go-life.pl>
@author Split <split@go-life.pl>
@version 1.0 beta
@changelog:
* Poprawiono prac?.

Nie masz prawa u?ywac tego kodu bez mojej zgody.
Napisz do mnie by? mo?e si? zgodz? na u?ycie kodu.
]]--
local districtsBus = {
    {-1735.86, 935.60, 24.74},
    {-1856.70, 934.15, 35.02},
    {-1976.56, 929.94, 45.30},
    {-2010.05, 889.21, 45.30},
    {-2007.90, 687.83, 45.49},
    {-2009.29, 164.41, 27.73},
    {-2008.72, -47.67, 35.36},
    {-2024.01, -311.14, 35.52},
    {-2181.06, -314.15, 35.43},
    {-2205.83, -200.09, 35.47},
    {-2338.28, -188.65, 35.36},
    {-2371.03, -75.48, 35.44},
    {-2017.15, -72.04, 35.36},
    {-2005.12, 48.98, 31.51},
    {-1991.66, 138.80, 27.73},
    {-2001.05, 313.72, 35.21},
    {-2000.35, 594.87, 35.22},
    {-2000.49, 844.61, 45.49},
    {-1902.01, 842.09, 35.21},
    {-1897.27, 916.37, 35.21},
    {-1795.58, 921.17, 24.93},
    {-1766.85, 950.46, 24.93},

}

local jobTarget
local jobMarker
local jobVehicle
local maxTarget = #districtsBus

function finishJob()
    if jobMarker and isElement(jobMarker) then
        destroyElement(jobMarker)
        jobMarker = nil
    end
    
    if jobTarget and isElement(jobTarget) then
        destroyElement(jobTarget)
        jobTarget = nil
        jobTarget = 0
        
    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
    
    if jobTarget == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        outputChatBox("* Zako?czy?e?/a? prac?.")
    else
        showMarker()
        playSoundFrontEnd(12)
        triggerServerEvent("givePlayerMoney", localPlayer, 2, 0)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarker) then
        destroyElement(jobMarker)
        jobMarker = nil
    end
    
    jobTarget = jobTarget + 1
    jobMarker = createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint", 4, 0, 0, 255)
    
    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)
    outputChatBox("* Rozpocz??e?/a? prac?.")
    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()
            outputChatBox("* Zako?czy?e? prac?")
        end
    end
end)


Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-25, 23:32


Terr9909

Skrypter LUA






Wiek: 27
Na forum: 4375 dni
Posty: 346
Nick w MP: Split

Piwa: 1043

Respekt: 182,8
Respekt: 182,8Respekt: 182,8

TO:
triggerServerEvent("destroyVeh", localPlayer)


ZAMIE? NA:
triggerServerEvent("destroyVeh",resourceRoot,jobVehicle)


POTEM TO:

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


ZAMIE? NA:

addEvent("destroyVeh", true)
addEventHandler("destroyVeh",resourceRoot,function(veh)
if veh and isElement(veh) then
destroyElement(veh)
end
end)


_____________________
Pozdrawiam
Terr9909

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-25, 23:33


PolskiSebek12

Programista






Wiek: 28
Na forum: 4488 dni
Posty: 343
Nick w MP: CrosRoad95

Piwa: 3887

Respekt: 288,8
Respekt: 288,8Respekt: 288,8Respekt: 288,8

Ostrzeżeń: 100%
nadaj ka?demu pojazdowi warto?? np "Praca" i co 30s sprawdzaj wszystkie pojazdy i je?eli s? puste usuwaj :)

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-27, 15:13


jg2aviva1

Rusek :D






Wiek: 25
Na forum: 4275 dni
Posty: 446
Nick w MP: _Wolfenstei[N]^.^

Piwa: 1034

Respekt: 240
Respekt: 240Respekt: 240

Ostrzeżeń: 60%
Do zamkni?cia

Podpis



GTAO Member: 2015-08-23, 14:26

Postaw piwo autorowi tego posta
 

 
Tagi: usuwanie :: pojazdu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » usuwanie pojazdu 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