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

Wysłany: 2016-06-20, 00:03


OskarYT

Mapper MTA






Wiek: 26
Na forum: 4245 dni
Posty: 267
Nick w MP: Kaczorek2306

Piwa: 1230

Respekt: 85,3

local districtsBus = {
    {-2019.83032,462.40048,35.17229},
    {-2006.79102,408.72031,34.79565},
    {-2008.52344,265.10687,31.36655},
    {-2008.97949,116.47514,27.31794},
    {-2120.60767,112.31438,34.95283},
    {-2169.56055,44.05518,34.95201},
    {-2169.59644,-56.73763,34.94774},
    {-2393.76270,-68.54819,34.94443},
    {-2635.83081,-68.07608,3.95697},
    {-2785.24292,-68.43432,6.81854},
    {-2807.52734,5.93914,6.80931}, -- prosta lewa strona mapy
    {-2807.09766,181.73575,6.80850},
    {-2809.35742,307.21472,5.62611},
    {-2851.80933,399.29401,4.13669},
    {-2825.35376,464.60773,4.33841},
    {-2642.53076,466.28339,13.48236},
    {-2604.78149,547.02252,14.23979},
    {-2520.24170,562.22870,14.24022},
    {-2367.01318,562.93127,24.51938},
    {-2273.58472,562.84485,35.01563},
    {-2107.74243,562.57837,35.01563},
    {-2009.17590,558.70898,35.01563},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},

}
local districtsBus = {
    {-2039.78931,461.50751,35.17188},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},
}

addEvent("givePlayerMoney"true)
addEventHandler("givePlayerMoney"resourceRoot, function()
    givePlayerMoney (localPlayer2)
end)

local jobTarget
local jobMarker
local jobVehicle
local maxTarget #districtsBus

function finishJob()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    if jobTarget and isElement(jobTargetthen
        destroyElement(jobTarget)
        jobTarget nil
        jobTarget 0
        
    end
    
triggerServerEvent("destroyVeh",resourceRoot,jobVehicle)
end


function busDriver(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 == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        outputChatBox("* Zako?czy?e?/a? prac? StreetView.")
    else
        showMarker()
        playSoundFrontEnd(12)
        givePlayerMoney (10)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    jobTarget jobTarget 1
    jobMarker createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint"400255)
    
    if districtsBus[jobTarget+1then
        ile districtsBus[jobTarget+1]
        setMarkerTarget(jobMarkerile[1], ile[2], ile[3])
    end
    
    addEventHandler("onClientMarkerHit"jobMarkerbusDriver)
end

addEvent("STARTJobBus"true)
addEventHandler("STARTJobBus"resourceRoot, function(veh)
    outputChatBox("* Rozpocz??e?/a? prac? StreetView.")
    outputChatBox("* Je?dzij po punktach i uzupe?niaj map?.")
    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(plrseat)
    if seat == 0 then
        if plr == localPlayer then
            finishJob()
            outputChatBox("* Zako?czy?e? prac? StreetView")
        end
    end
end)


Mam owy skrypt i chcia? bym aby losowo si? zmienia?y te trasy raz ta pierwsza raz ta druga a nie ca?y czas tylko jedna kto pomo?e ?
Stawiam zimne mocne piwo , prosi? bym o gotowca bo za dobry w programowaniu nie jestem :/

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-20, 00:22


GabWas







Wiek: 24
Na forum: 3881 dni
Posty: 289
Nick w MP: GabWas

Piwa: 65

Respekt: 231,5
Respekt: 231,5Respekt: 231,5

"OskarYT" napisał/a:

prosi? bym o gotowca bo za dobry w programowaniu nie jestem :/


Mo?e czas si? nauczy?, a nie czeka? na te n?dzne gotowce, hm? :eye:
Mo?e jak do piwka dorzucisz R* , to pokusz? si? o jego zrobienie :roll:


1. Obie tabele maj? takie same nazwy, druga wi?c nadpisuje pierwsz?. Nazwij je districtsBus1 i districtsBus2.
2. Dodaj po tym:
addEvent("STARTJobBus"true)
addEventHandler("STARTJobBus"resourceRoot, function(veh)

...co? takiego:
trasa math.random(1,2)
if trasa==1 then
    districtsBus districtsBus1
elseif trasa==2 then
    districtsBus districtsBus2
end

3. Sprawd? czy dzia?a :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-20, 02:04


OskarYT

Mapper MTA






Wiek: 26
Na forum: 4245 dni
Posty: 267
Nick w MP: Kaczorek2306

Piwa: 1230

Respekt: 85,3

GabWas, czyli jak bym chcia? doda? trzeci? tras? to co? takiego :

 trasa math.random(1,2,3)
if trasa==1 then
    districtsBus districtsBus1
elseif trasa==2 then
    districtsBus districtsBus2
elseif trasa==3 then
    districtsBus districtsBus3
end


Podpis
Postaw piwo autorowi tego posta
 

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


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 | .
Tak, tylko w math.random zamiast 1,2,3 to daj 1,3

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-06-20, 12:20


GabWas







Wiek: 24
Na forum: 3881 dni
Posty: 289
Nick w MP: GabWas

Piwa: 65

Respekt: 231,5
Respekt: 231,5Respekt: 231,5

Tak jak obieca?em, tu masz gotowiec:
local districtsBus1 = {
    {-2019.83032,462.40048,35.17229},
    {-2006.79102,408.72031,34.79565},
    {-2008.52344,265.10687,31.36655},
    {-2008.97949,116.47514,27.31794},
    {-2120.60767,112.31438,34.95283},
    {-2169.56055,44.05518,34.95201},
    {-2169.59644,-56.73763,34.94774},
    {-2393.76270,-68.54819,34.94443},
    {-2635.83081,-68.07608,3.95697},
    {-2785.24292,-68.43432,6.81854},
    {-2807.52734,5.93914,6.80931}, -- prosta lewa strona mapy
    {-2807.09766,181.73575,6.80850},
    {-2809.35742,307.21472,5.62611},
    {-2851.80933,399.29401,4.13669},
    {-2825.35376,464.60773,4.33841},
    {-2642.53076,466.28339,13.48236},
    {-2604.78149,547.02252,14.23979},
    {-2520.24170,562.22870,14.24022},
    {-2367.01318,562.93127,24.51938},
    {-2273.58472,562.84485,35.01563},
    {-2107.74243,562.57837,35.01563},
    {-2009.17590,558.70898,35.01563},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},

}
local districtsBus2 = {
    {-2039.78931,461.50751,35.17188},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},
}

local districtsBus3 = {
    {-2039.78931,461.50751,35.17188},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},
}

addEvent("givePlayerMoney"true)
addEventHandler("givePlayerMoney"resourceRoot, function()
    givePlayerMoney (localPlayer2)
end)

local jobTarget
local jobMarker
local jobVehicle
local maxTarget #districtsBus

function finishJob()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    if jobTarget and isElement(jobTargetthen
        destroyElement(jobTarget)
        jobTarget nil
        jobTarget 0
        
    end
    
triggerServerEvent("destroyVeh",resourceRoot,jobVehicle)
end


function busDriver(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 == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        outputChatBox("* Zako?czy?e?/a? prac? StreetView.")
    else
        showMarker()
        playSoundFrontEnd(12)
        givePlayerMoney (10)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    jobTarget jobTarget 1
    jobMarker createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint"400255)
    
    if districtsBus[jobTarget+1then
        ile districtsBus[jobTarget+1]
        setMarkerTarget(jobMarkerile[1], ile[2], ile[3])
    end
    
    addEventHandler("onClientMarkerHit"jobMarkerbusDriver)
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
    outputChatBox("* Rozpocz??e?/a? prac? StreetView.")
    outputChatBox("* Je?dzij po punktach i uzupe?niaj map?.")
    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(plrseat)
    if seat == 0 then
        if plr == localPlayer then
            finishJob()
            outputChatBox("* Zako?czy?e? prac? StreetView")
        end
    end
end)


Uwzgl?dni?em w nim 3 trasy, tylko tam sobie koordynaty pozmieniaj. Co do pewno?ci czy dzia?a to nie mam, bo nie otrzyma?em ca?ego skryptu. Tak czy siak, powodzenia :P

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-20, 13:30


OskarYT

Mapper MTA






Wiek: 26
Na forum: 4245 dni
Posty: 267
Nick w MP: Kaczorek2306

Piwa: 1230

Respekt: 85,3

GabWas, teraz nie dzia?a :/


Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-20, 14:15


GabWas







Wiek: 24
Na forum: 3881 dni
Posty: 289
Nick w MP: GabWas

Piwa: 65

Respekt: 231,5
Respekt: 231,5Respekt: 231,5

"OskarYT" napisał/a:

GabWas, teraz nie dzia?a :/
Obrazek


Tak jak m?wi?em, bez ca?ego skryptu nie jestem w stanie Ci pom?c.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-21, 13:08


OskarYT

Mapper MTA






Wiek: 26
Na forum: 4245 dni
Posty: 267
Nick w MP: Kaczorek2306

Piwa: 1230

Respekt: 85,3

GabWas, Tu masz po stronie clienta all
local districtsBus1 = {
    {-2019.83032,462.40048,35.17229},
    {-2006.79102,408.72031,34.79565},
    {-2008.52344,265.10687,31.36655},
    {-2008.97949,116.47514,27.31794},
    {-2120.60767,112.31438,34.95283},
    {-2169.56055,44.05518,34.95201},
    {-2169.59644,-56.73763,34.94774},
    {-2393.76270,-68.54819,34.94443},
    {-2635.83081,-68.07608,3.95697},
    {-2785.24292,-68.43432,6.81854},
    {-2807.52734,5.93914,6.80931}, -- prosta lewa strona mapy
    {-2807.09766,181.73575,6.80850},
    {-2809.35742,307.21472,5.62611},
    {-2851.80933,399.29401,4.13669},
    {-2825.35376,464.60773,4.33841},
    {-2642.53076,466.28339,13.48236},
    {-2604.78149,547.02252,14.23979},
    {-2520.24170,562.22870,14.24022},
    {-2367.01318,562.93127,24.51938},
    {-2273.58472,562.84485,35.01563},
    {-2107.74243,562.57837,35.01563},
    {-2009.17590,558.70898,35.01563},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},

}
local districtsBus2 = {
    {-2039.78931,461.50751,35.17188},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},
}

local districtsBus3 = {
    {-2039.78931,461.50751,35.17188},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},
}

addEvent("givePlayerMoney"true)
addEventHandler("givePlayerMoney"resourceRoot, function()
    givePlayerMoney (localPlayer2)
end)

local jobTarget
local jobMarker
local jobVehicle
local maxTarget #districtsBus

function finishJob()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    if jobTarget and isElement(jobTargetthen
        destroyElement(jobTarget)
        jobTarget nil
        jobTarget 0
        
    end
    
triggerServerEvent("destroyVeh",resourceRoot,jobVehicle)
end


function busDriver(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 == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        outputChatBox("* Zako?czy?e?/a? prac? StreetView.")
    else
        showMarker()
        playSoundFrontEnd(12)
        givePlayerMoney (10)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    jobTarget jobTarget 1
    jobMarker createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint"400255)
    
    if districtsBus[jobTarget+1then
        ile districtsBus[jobTarget+1]
        setMarkerTarget(jobMarkerile[1], ile[2], ile[3])
    end
    
    addEventHandler("onClientMarkerHit"jobMarkerbusDriver)
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
    outputChatBox("* Rozpocz??e?/a? prac? StreetView.")
    outputChatBox("* Je?dzij po punktach i uzupe?niaj map?.")
    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(plrseat)
    if seat == 0 then
        if plr == localPlayer then
            finishJob()
            outputChatBox("* Zako?czy?e? prac? StreetView")
        end
    end
end)


Podpis
Ostatnio zmieniony przez OskarYT 2016-06-22, 22:09, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-21, 20:07


GabWas







Wiek: 24
Na forum: 3881 dni
Posty: 289
Nick w MP: GabWas

Piwa: 65

Respekt: 231,5
Respekt: 231,5Respekt: 231,5

Pozmienia?em kolejno?? zmiennych (tak wiem, mas?o ma?lane), przetestowa?em - no i dzia?a :) Licz? na :piwo: i/lub R* :D
Kod zmieni? si? tylko po stronie clienta, oto on:
local districtsBus = {}

local districtsBus1 = {
    {-2019.83032,462.40048,35.17229},
    {-2006.79102,408.72031,34.79565},
    {-2008.52344,265.10687,31.36655},
    {-2008.97949,116.47514,27.31794},
    {-2120.60767,112.31438,34.95283},
    {-2169.56055,44.05518,34.95201},
    {-2169.59644,-56.73763,34.94774},
    {-2393.76270,-68.54819,34.94443},
    {-2635.83081,-68.07608,3.95697},
    {-2785.24292,-68.43432,6.81854},
    {-2807.52734,5.93914,6.80931}, -- prosta lewa strona mapy
    {-2807.09766,181.73575,6.80850},
    {-2809.35742,307.21472,5.62611},
    {-2851.80933,399.29401,4.13669},
    {-2825.35376,464.60773,4.33841},
    {-2642.53076,466.28339,13.48236},
    {-2604.78149,547.02252,14.23979},
    {-2520.24170,562.22870,14.24022},
    {-2367.01318,562.93127,24.51938},
    {-2273.58472,562.84485,35.01563},
    {-2107.74243,562.57837,35.01563},
    {-2009.17590,558.70898,35.01563},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},

}
local districtsBus2 = {
    {-2039.78931,461.50751,35.17188},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},
}

local districtsBus3 = {
    {-2039.78931,461.50751,35.17188},
    {-2008.12476,470.15121,35.01563},
    {-2039.78931,461.50751,35.17188},
}

addEvent("givePlayerMoney"true)
addEventHandler("givePlayerMoney"resourceRoot, function()
    givePlayerMoney (localPlayer2)
end)

local jobTarget
local jobMarker
local jobVehicle

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("* Rozpocz??e?/a? prac? StreetView.")
    outputChatBox("* Je?dzij po punktach i uzupe?niaj map?.")
    jobVehicle veh
    jobTarget 0
    showMarker()
end)

function finishJob()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    if jobTarget and isElement(jobTargetthen
        destroyElement(jobTarget)
        jobTarget nil
        jobTarget 0
        
    end
    
triggerServerEvent("destroyVeh",resourceRoot,jobVehicle)
end


function busDriver(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 == #districtsBus then
        finishJob()
        playSoundFrontEnd(5)
        outputChatBox("* Zako?czy?e?/a? prac? StreetView.")
    else
        showMarker()
        playSoundFrontEnd(12)
        givePlayerMoney (10)
    end
end

function showMarker()
    if jobMarker and isElement(jobMarkerthen
        destroyElement(jobMarker)
        jobMarker nil
    end
    
    jobTarget jobTarget 1
    jobMarker createMarker(districtsBus[jobTarget][1], districtsBus[jobTarget][2], districtsBus[jobTarget][3], "checkpoint"400255)
    
    if districtsBus[jobTarget+1then
        ile districtsBus[jobTarget+1]
        setMarkerTarget(jobMarkerile[1], ile[2], ile[3])
    end
    
    addEventHandler("onClientMarkerHit"jobMarkerbusDriver)
end



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

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


Nie jestem tylko pewien czy dzia?a to z wi?cej ni? jedn? osob?, b?dziesz musia? to z kim? sprawdzi?. Tak czy siak, mam nadziej? ?e pomog?em :roll:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-22, 22:44


OskarYT

Mapper MTA






Wiek: 26
Na forum: 4245 dni
Posty: 267
Nick w MP: Kaczorek2306

Piwa: 1230

Respekt: 85,3

GabWas, Dzi?ki wielkie temat do zamkni?cia :)

Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: losowo
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