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

Wysłany: 2016-02-01, 21:05


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
Witam potrzebuj? pomocy w skrypcie,
ot?? mam skrypt na prace :D i w ka?dej z nich po wyj?ciu z np auta ono znika problem pojawia si? wtedy gdy kto? zrobi /quit albo /reconnect lub /disconnect
wtedy auto nie znika i stoi ... dop?ki nie zrestartuje si? skryptu prosz? pom??cie daj? wam kawa?ek skryptu :D
Chodzi mi o to ?e jak gracz wpisze np /quit to usunie sie pojazd


client:
Cytat:

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",resourceRoot,jobVehicle)

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, 20, 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)


server:
Cytat:

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(449, x,y,z, 180, 0.0, 0.4)
setVehicleHandling(bus, "maxVelocity", 100.0)
setElementData(bus, "zrespilGracz", el)
setElementData(bus, "pojazd_paliwo", 50)
setElementData(bus, "pojazd_przebieg", 100)


setVehicleHandling(bus, "maxVelocity", 0.1)
setVehicleHandling(bus, "engineAcceleration", 2 )
setVehicleHandling(bus, "ABS", true )


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",resourceRoot,function(veh)
if veh and isElement(veh) then
destroyElement(veh)
end
end)

Daj? niepe?ne kody :D
Prosz? o pomoc :D za pomoc :piwo: i R*

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-01, 21:10


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157


function onQuitGamereason )
if seat == 0 then 
if plr == localPlayer then 
finishJob() 
outputChatBox("* Zako?czy?e? prac?"end 
end 
end
addEventHandler"onClientPlayerQuit"getRootElement(), onQuitGame )

Dodaj to pod onClientVehicleExit

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-01, 21:11


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
Client czy serwer ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-01, 21:12


#404







Wiek: 26
Na forum: 4771 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%

addEventHandler("onPlayerQuit"root, function()
if isPedInVehicle(sourcethen
    auto getPedOccupiedVehicle(source)
    if not getElementData(auto"zrespilGracz"then return end
    destroyElement(auto)
end


Strona serwera i powinno dzia?a?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-01, 21:12


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Je?eli przeczytasz event to b?dziesz wiedzia?. :) a event brzmi:

"onClientPlayerQuit" odpowiedz w drugim wyrazie ;) z wielkiej litery ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-01, 21:14


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
BlackTen, No tak nie pomy?la?em :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-01, 21:48


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
BlackTen,
Niestety nie dzia?a pr?bowa?em...
Cytat:

addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )
function onQuitGame( reason )
if seat == 0 then
if plr == localPlayer then
finishJob()
outputChatBox("* Zako?czy?e? prac?")
end
end
end
end)




lub

Cytat:


function onQuitGame( reason )
if seat == 0 then
if plr == localPlayer then
finishJob()
outputChatBox("* Zako?czy?e? prac?")
end
end
end
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )
end)

lecz nadal jak wychodze z serwera to pojazd zostaje :(

[ Dodano: 2016-02-01, 21:49 ]
DestroY,
A twoje wog?le nie dzia?a :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 14:40


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

triggerServerEvent("destroyVeh",resourceRoot,jobVehicle


Dodaj to pod finishJob w moim kodzie

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 16:06


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
BlackTen,
Nadal nie dzia?a :D
jak wyjde z pojazdu to si? uwuwa ale jak zrobie reconnect to nic :D

sprawd? czy dobry kod :D

Cytat:


addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
function onQuitGame( reason )
if seat == 0 then
if plr == localPlayer then
finishJob()
triggerServerEvent("destroyVeh",resourceRoot,jobVehicle)
outputChatBox("* Zako?czy?e? prac?")
end
end
end
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 20:46


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Wyrzuc event onclientplayerquit z onclientvehicleexit...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 21:31


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
BlackTen,
Zrobi?em i nadal nie znika po wyj?ciu

Podaj Skype to na Skype Ci? zaprosze i popiszemy :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 21:37


Emm

***** ***






Wiek: 32
Na forum: 3880 dni
Posty: 3191
Nick w MP: Emm

Piwa: 6162

Respekt: 1580
Respekt: 1580Respekt: 1580


   Administrator: Admin ma zawsze rację | REGULAMIN FORUM | REKLAMA/VIP | .
"amama12345" napisał/a:

BlackTen,
Zrobi?em i nadal nie znika po wyj?ciu

Podaj Skype to na Skype Ci? zaprosze i popiszemy :D

Pomagamy TYLKO na forum.
Pr?bowa?e?

Więcej informacji znajdziesz w Wikipedii MTA:

destroyElement
?

Podpis

Użytkownik: 20.10.2015r
GTAO Member: 06.03.2016r
Support-Team: 20.01.2016r
Moderator: 30.03.2016r
Mod-Team: 08.10.2016r
Vice Admin: 04.05.2018r
Administrator: 03.05.2022r


! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 21:40


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
Emm,
Tak :D po wyj?ciu z gry

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 21:46


BlackTen

LUA Dev.






Wiek: 28
Na forum: 4329 dni
Posty: 698

Piwa: 2080

Respekt: 157
Respekt: 157Respekt: 157

Walnij mi tu tym kodem.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-02, 21:47


amama12345







Wiek: 25
Na forum: 4422 dni
Posty: 50
Nick w MP: AmaMa

Piwa: 3

Respekt: 50

Ostrzeżeń: 100%
BlackTen,
Ca?y client
Cytat:


local districtsBus = {
{-2267.09, 513.41, 35.21},
{-2361.05, 508.25, 29.70},
{-2334.35, 446.11, 33.93},
{-2251.87, 324.60, 35.32},
{-2252.09, 137.86, 35.32},
{-2255.90, -53.92, 35.32},
{-2179.74, -70.35, 35.32},
{-2157.58, 29.73, 35.32},
{-2008.12, 32.28, 32.92},
{-2006.04, 152.42, 27.70},
{-2003.16, 327.24, 35.20},
{-2000.66, 582.50, 35.20},
{-1866.77, 602.79, 35.20},
{-1711.04, 640.27, 24.82},
{-1658.49, 728.29, 17.35},
{-1542.51, 753.95, 7.20},
{-1554.45, 849.46, 7.20},
{-1737.17, 849.34, 24.89},
{-1941.91, 849.34, 40.29},
{-1906.05, 920.55, 35.20},
{-1671.73, 920.66, 24.82},
{-1568.30, 1005.91, 7.20},
{-1619.79, 1233.35, 7.20},
{-1880.92, 1348.59, 7.20},
{-2094.87, 1274.71, 15.28},
{-2265.25, 1182.31, 55.78},
{-2265.34, 928.57, 66.66},
{-2265.42, 724.64, 49.49},
{-2265.30, 548.17, 35.22},
}

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",resourceRoot,jobVehicle)

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, 20, 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)

addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
if seat == 0 then
if plr == localPlayer then
finishJob()
outputChatBox("* Zako?czy?e? prac?")
end
end
end)

function onQuitGame( reason )
if seat == 0 then
if plr == localPlayer then
finishJob()
triggerServerEvent("destroyVeh",resourceRoot,jobVehicle)
outputChatBox("* Zako?czy?e? prac?")
end
end
end
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )


Postaw piwo autorowi tego posta
 

 
Tagi: destroyvehicle :: skrypcie
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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