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

Wysłany: 2019-08-02, 00:01


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot?? chcia?bym gdy wje?dzamy w marker, to zalicza nam go wtedy gdy mamy poczepion? naczep?.
Pr?bowa?em z
getVehicleTowedByVehicle

lecz niestety nie dzia?a?o :(
kod c_side

--[[
Praca busa

]]--
local code "MoveTrans"
local districtsTir = {
            {-2490.231387.227.19},
            {-2441.331367.347.19},
}

local jobTarget
local jobMarker
local jobVehicle
local maxTarget #districtsTir
function odleglosc()
    local x,y,getElementPosition(localPlayer)
    local mx,my,mz getElementPosition(jobMarker)
    local distance getDistanceBetweenPoints3D(x,y,z,mx,my,mz)
    if distance 9000000 then
            triggerEvent('onClientAddNotification'localPlayer'Odjecha?e? zadaleko od punktu.''error')
        finishJob()
    end
end
function finishJob()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    if jobBlip and isElement(jobBlipthen
        destroyElement(jobBlip)
        jobBlip nil
    end
    if jobTarget and isElement(jobTargetthen
        destroyElement(jobTarget)
        jobTarget nil
        jobTarget 0

    end
if getElementData(localPlayer,"player:job") == code then
setElementData(localPlayer,"player:job",false)
end
triggerServerEvent("destroyVeh"localPlayer)
removeEventHandler("onClientRender",root,odleglosc)
end
addEventHandler "onClientPlayerWasted"getLocalPlayer(),finishJob)
addEvent("finishJob",true)
addEventHandler("finishJob",root,function(plr)
if plr ~= localPlayer then return end
finishJob()
end)


function TirDriver(elmd)
    if el ~= localPlayer or not md then return end
    if jobTarget maxTarget and getPedOccupiedVehicle(elthen return end
    if jobTarget == maxTarget and not getPedOccupiedVehicle(elthen return end
    if jobTarget == #districtsTir then
        triggerServerEvent("daj:punkty:sv"localPlayerlocalPlayer)
        finishJob()
        playSoundFrontEnd(5)
            triggerEvent('onClientAddNotification'localPlayer'Pomy?lnie zako?czono prac?.''info')
    else
        local kasa math.random(20000,25500)
        local premka math.random(20000*1.5,25500*1.5)
        showMarker()    
        playSoundFrontEnd(12)
        if getElementData(localPlayer"player:premium"then
        triggerServerEvent("givePlayerMoney"localPlayerpremka)
        triggerEvent('onClientAddNotification'localPlayer'Za Dostawe Towaru otrzymujesz wynagrodzenie w postaci: #00c005'..premka..' $#FFFFFF''success')
        setElementData(el,"player:reputation"getElementData(el,"player:reputation")+math.random(0,2))
        else
        triggerServerEvent("givePlayerMoney"localPlayerkasa)
        triggerEvent('onClientAddNotification'localPlayer'Za Dostawe Towaru otrzymujesz wynagrodzenie w postaci: #00c005'..kasa..' $#FFFFFF''success')
        setElementData(el,"player:reputation"getElementData(el,"player:reputation")+math.random(0,1))
            end
        end
    end
end
function showMarker()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    if jobBlip and isElement(jobBlipthen
        destroyElement(jobBlip)
        jobBlip nil
    end


    jobTarget jobTarget 1
    jobMarker createMarker(districtsTir[jobTarget][1], districtsTir[jobTarget][2], districtsTir[jobTarget][3]-1"corona"40122255,200)
    jobBlip createBlip(districtsTir[jobTarget][1], districtsTir[jobTarget][2], districtsTir[jobTarget][3], 41)
    if districtsTir[jobTarget+1then
        ile districtsTir[jobTarget+1]
        ile2 ile[1]
        ile3 ile[2]
        ile4 ile[3]
        setMarkerTarget(jobMarkerile[1], ile[2], ile[3])
    end

    addEventHandler("onClientMarkerHit"jobMarkerTirDriver)
end

addEvent("STARTJobTir"true)
addEventHandler("STARTJobTir"resourceRoot, function(veh)
    triggerEvent"onClientAddNotification"localPlayer"Pomy?lnie przyjoles/as zlecenie !""success" )
    jobVehicle veh
    jobTarget 0
    showMarker()
    addEventHandler("onClientRender",root,odleglosc)
end)

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




Prosi?bym o pomoc. Za pomoc daje zimne :piwo:

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-02, 08:38


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Jak ma to dzia?a? jak tego nigdzie w kodzie nie ma.
Sprawdzasz czy ta funkcja zwraca Ci co? innego ni? 'false.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-02, 11:56


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

w kodzie pr?bowa?em tak:

function TirDriver(elmd)
    if el ~= localPlayer or not md then return end
local town getVehicleTowedByVehicle(el) 

    if jobTarget maxTarget and getPedOccupiedVehicle(elthen return end
    if jobTarget == maxTarget and not getPedOccupiedVehicle(elthen return end
    if town then 
    if jobTarget == #districtsTir then
        triggerServerEvent("daj:punkty:sv"localPlayerlocalPlayer)
        finishJob()
        playSoundFrontEnd(5)
            triggerEvent('onClientAddNotification'localPlayer'Pomy?lnie zako?czono prac?.''info')
    else
        local kasa math.random(20000,25500)
        local premka math.random(20000*1.5,25500*1.5)
        showMarker()    
        playSoundFrontEnd(12)
        if getElementData(localPlayer"player:premium"then
        triggerServerEvent("givePlayerMoney"localPlayerpremka)
        triggerEvent('onClientAddNotification'localPlayer'Za Dostawe Towaru otrzymujesz wynagrodzenie w postaci: #00c005'..premka..' $#FFFFFF''success')
        setElementData(el,"player:reputation"getElementData(el,"player:reputation")+math.random(0,2))
        else
        triggerServerEvent("givePlayerMoney"localPlayerkasa)
        triggerEvent('onClientAddNotification'localPlayer'Za Dostawe Towaru otrzymujesz wynagrodzenie w postaci: #00c005'..kasa..' $#FFFFFF''success')
        setElementData(el,"player:reputation"getElementData(el,"player:reputation")+math.random(0,1))
            end
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-02, 18:44


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W tym evencie zmienna el okre?la gracza, kt?ry wjecha? w marker.
Musisz najpierw pobra? pojazd gracza i wtedy dopiero sprawdza? czy ma naczepe.

local?town?=?getVehicleTowedByVehicle(getPedOccupiedVehicle(el))? 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-03, 14:56


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Okey, ale w?a?nie jak pobra? pojazd gracza ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-03, 16:42


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8


Więcej informacji znajdziesz w Wikipedii MTA:

getPedOccupiedVehicle


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-03, 23:25


Eitho







Wiek: 24
Na forum: 3489 dni
Posty: 330
Nick w MP: Eitho

Piwa: 746

Respekt: 256,5
Respekt: 256,5Respekt: 256,5Respekt: 256,5

Je?li chodzi o wjazd naczep? w marker, a nie pojazdem, to proponuj? za element wje?d?aj?cy w marker uzna? w?a?nie ow? naczep? (w twojej funkcji town), a gracza (w twojej funkcji el) pobiera? za pomoc? innej funkcji.


Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleTowingVehicle


Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleController


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-04, 18:51


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Jak pobra? warto?? pojazdu ? Jak pojazdem prywatnym podczepiane s? naczepy,a nie respionym przez skrypt.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-05, 22:38


Eitho







Wiek: 24
Na forum: 3489 dni
Posty: 330
Nick w MP: Eitho

Piwa: 746

Respekt: 256,5
Respekt: 256,5Respekt: 256,5Respekt: 256,5

Funkcj? kt?r? poda?em powy?ej.
Napisa?em przyk?ad u?ycia, dzi?ki kt?remu b?dziesz mia? 3 potrzebne ci zmienne: naczepy (element), pojazdu (vehicle) i gracza (player).


local marker createMarker(-2423.51, -603.13132.67'cylinder'5)

local matchingTrailers = {
-- [id naczepy ktora ma byc akceptowana] = true,
    [435] = true, -- naczepa ci?gnika siod?owego
}

addEventHandler('onMarkerHit'marker, function(elementmatchingDimension)
    if not matchingDimension then return end
    if not getElementType(element) == 'vehicle' then return end
    if not matchingTrailers[getElementModel(element)] then return end
    local vehicle getVehicleTowingVehicle(element) -- pojazd kt?ry "ci?gnie" naczep?
    if not vehicle then return end
    local player getVehicleController(vehicle) -- kierowca pojazdu kt?ry "ci?gnie" naczep?
    if not player then return end
    
    
    outputChatBox('Wjechano naczep? w marker'player)
    outputChatBox('INFO: Naczepa: '..inspect(element)..'; Pojazd: '..inspect(vehicle)..'; Kierowca: '..inspect(player), player)
end)



[ Dodano: 2019-08-05, 22:44 ]
Teraz zobaczy?em, ?e po stronie klienta nie da si? w ten spos?b tego zrobi?, jedynie po stronie serwera. M?j b??d.

[ Dodano: 2019-08-05, 22:57 ]
W takim razie spr?buj po prostu tak:
local matchingTrailers = {
-- [id naczepy ktora ma byc akceptowana] = true,
    [435] = true, -- naczepa ci?gnika siod?owego
}

function TirDriver(elmd)
    if el ~= localPlayer or not md then return end
    local vehicle getPedOccupiedVehicle(el) -- pojazd gracza
    if jobTarget maxTarget and vehicle then return end
    if jobTarget == maxTarget and not vehicle then return end
    local trailer getVehicleTowedByVehicle(vehicle) -- naczepa
    if not trailer or not matchingTrailers[getElementModel(trailer)] then return end -- je?li brak naczepy lub naczepa nie jest jednym z modeli zawartych w matchingTrailers to nic sidalej nie dzieje
    if jobTarget == #districtsTir then
        triggerServerEvent("daj:punkty:sv"localPlayerlocalPlayer)
        finishJob()
        playSoundFrontEnd(5)
            triggerEvent('onClientAddNotification'localPlayer'Pomy?lnie zako?czono prac?.''info')
    else
        local kasa math.random(20000,25500)
        local premka math.random(20000*1.5,25500*1.5)
        showMarker()    
        playSoundFrontEnd(12)
        if getElementData(localPlayer"player:premium"then
        triggerServerEvent("givePlayerMoney"localPlayerpremka)
        triggerEvent('onClientAddNotification'localPlayer'Za Dostawe Towaru otrzymujesz wynagrodzenie w postaci: #00c005'..premka..' $#FFFFFF''success')
        setElementData(el,"player:reputation"getElementData(el,"player:reputation")+math.random(0,2))
        else
        triggerServerEvent("givePlayerMoney"localPlayerkasa)
        triggerEvent('onClientAddNotification'localPlayer'Za Dostawe Towaru otrzymujesz wynagrodzenie w postaci: #00c005'..kasa..' $#FFFFFF''success')
        setElementData(el,"player:reputation"getElementData(el,"player:reputation")+math.random(0,1))
            end
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Pyrek24
Tagi: wjazd :: naczepą :: marker
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