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

Wysłany: 2016-01-18, 20:41


Daisu

Programista Lua






Wiek: 26
Na forum: 4585 dni
Posty: 192
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Witam chcia?bym na spawnie zrobi? darmowe skutery kt?re resetuj? si? 5 minut od momentu zej?cia z niego + ?eby si? nie resetowa? gdy jest na spawnie.

Kod kt?ry mam jednak on nie jest optymalny bo jak np pojad? i zejd? to on mo?e od razu znikn??:


setTimer(function()
if not getVehicleController(spawn1) then
destroyElement(spawn1)

spawn1 = createVehicle ( 462, -1987.7, 902.79999, 44.9, 180, 174.50677490234, "Axel")
setVehicleColor( spawn1, 255, 255, 255, 255, 0, 0 )
end
end, 60*1000, 0)



Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-18, 20:53


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

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

Ostrzeżeń: 60%

skurety = {
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z}
}
cuboid = 

for k,v in ipairs (skutery) do
createVehicle(.....)

end

addEventHandler("onVehicleExit", resourceRoot, function()
setTimer(usun, 1000*60*5, 1, source)
end
)

function usun (pojazd)
if not pojazd then return end
if isElementWithinColShape(pojazd, cuboid) then return end
if isVehicleEmpty(pojazd) then
respawnElement(pojazd)
end
end


function isVehicleEmpty( vehicle )
    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then
        return true
    end
 
    local passengers = getVehicleMaxPassengers( vehicle )
    if type( passengers ) == 'number' then
        for seat = 0, passengers do
            if getVehicleOccupant( vehicle, seat ) then
                return false
            end
        end
    end
    return true
end


Co? takiego powinno dzia?a?.

Aa no i jeszcze do tego uzupe?nij niekt?re fragmenty.

Ostatnio zmieniony przez #404 2016-01-18, 21:05, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-18, 21:03


venzikk

LUA, MODELER






Wiek: 25
Na forum: 3964 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

Powinno dzia?a?



local pojazdyPub = {
    {462, x,y,z}, 
    {462, x,y,z},
    {462, x,y,z},
    {462, x,y,z},
    {462, x,y,z}
}

for i,v in ipairs(pojazdyPub) do
    local pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5])
    setElementData(pojazd, "opis", "Pojazd publiczny")
    setElementFrozen(pojazd, true)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        setElementFrozen(source, false)
        setElementData(source, "opis", "")
    end
end)


function respawnVehicles()
    for i,v in ipairs(getElementsByType("vehicle", resourceRoot)) do
        if not getVehicleOccupant(v) then
            respawnVehicle(v)
            setElementFrozen(v, true)
            setElementData(v, "opis", "Pojazd publiczny")
        end
    end
end
setTimer(respawnVehicles, 50000, 0)


Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 00:19


Daisu

Programista Lua






Wiek: 26
Na forum: 4585 dni
Posty: 192
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Mam kod :

local pojazdyPub = {
    {462, -1987.7, 902.79999, 44.9}, 
    {462, -1986.5, 902.79999, 44.9},
    {462, -1985.3, 902.70001, 44.9},
    {462, -1984.1, 902.79999, 44.9},
    {462, -1982.9, 902.59961, 44.9},
    {462, -1981.7002, 902.70001, 44.9},
    {462, -1987.5, 865.70001, 44.9},
    {462, -1986.4004, 865.7002, 44.9},
    {462, -1985.4, 865.59998, 44.9},
    {462, -1984.4, 865.59998, 44.9},
    {462, -1983.2998, 865.5, 44.9},
    {462, -1982.2, 865.5, 44.9}
}

for i,v in ipairs(pojazdyPub) do
    pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5])
    setElementData(pojazd, "message","Pojazd Publiczny")
    setVehicleColor(pojazd, 255, 255, 255, 0, 160, 255)
    setElementFrozen(pojazd, true)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        setElementFrozen(source, false)
    end
end)


addEventHandler("onVehicleExit", resourceRoot, function()
setTimer(usun, 1000*60*5, 1, source)
end
)

function usun (pojazd)
if not pojazd then return end
--if isElementWithinColShape(pojazd, cuboid) then return end
if isVehicleEmpty(pojazd) then
respawnElement(pojazd)
setElementFrozen(pojazd, true)
end
end


Tak wiem to s? 2 w 1 ale teraz np wywali?o mi b??d:

38: attempt to call global 'isVehicleEmpty' (a nil value)


Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 01:52


Novovix

xNinja powraca






Wiek: 26
Na forum: 5011 dni
Posty: 240
Nick w MP: xNinja

Piwa: 453

Respekt: 80,5

Nie wklei?e? funkcji "isVehicleEmpty":
function isVehicleEmpty( vehicle )
    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then
        return true
    end
 
    local passengers = getVehicleMaxPassengers( vehicle )
    if type( passengers ) == 'number' then
        for seat = 0, passengers do
            if getVehicleOccupant( vehicle, seat ) then
                return false
            end
        end
    end
    return true
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 13:08


Daisu

Programista Lua






Wiek: 26
Na forum: 4585 dni
Posty: 192
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Dobra mam tak.

cuboid = createColCuboid(-1995.8308, 859.56134, 31.296875, 88.5, 49.5, 22.25)
local pojazdyPub = {
    {462, -1987.7, 902.79999, 44.9}, 
    {462, -1986.5, 902.79999, 44.9},
    {462, -1985.3, 902.70001, 44.9},
    {462, -1984.1, 902.79999, 44.9},
    {462, -1982.9, 902.59961, 44.9},
    {462, -1981.7002, 902.70001, 44.9},
    {462, -1987.5, 865.70001, 44.9},
    {462, -1986.4004, 865.7002, 44.9},
    {462, -1985.4, 865.59998, 44.9},
    {462, -1984.4, 865.59998, 44.9},
    {462, -1983.2998, 865.5, 44.9},
    {462, -1982.2, 865.5, 44.9}
}

for i,v in ipairs(pojazdyPub) do
    pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5])
    setElementData(pojazd, "message","Pojazd Publiczny")
    setVehicleColor(pojazd, 255, 255, 255, 0, 160, 255)
    setElementFrozen(pojazd, true)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        setElementFrozen(source, false)
    end
end)


addEventHandler("onVehicleExit", resourceRoot, function()
setTimer(usun, 1000*60*5, 1, source)
end
)

function usun (pojazd)
if not pojazd then return end
if isElementWithinColShape(pojazd, cuboid) then return end
if isVehicleEmpty(pojazd) then
respawnElement(pojazd)
setElementFrozen(pojazd, true)
end
end

function isVehicleEmpty( vehicle )
    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then
        return true
    end
 
    local passengers = getVehicleMaxPassengers( vehicle )
    if type( passengers ) == 'number' then
        for seat = 0, passengers do
            if getVehicleOccupant( vehicle, seat ) then
                return false
            end
        end
    end
    return true
end


Jest b??d:

s.lua:40: attempt to call global 'respawnElement' (a nil value)


I chcia?bym doda? aby pierwsze 6 aut by?o odwr?cone o 180stopni :



 {462, -1987.7, 902.79999, 44.9}, 
    {462, -1986.5, 902.79999, 44.9},
    {462, -1985.3, 902.70001, 44.9},
    {462, -1984.1, 902.79999, 44.9},
    {462, -1982.9, 902.59961, 44.9},
    {462, -1981.7002, 902.70001, 44.9},



Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 14:08


venzikk

LUA, MODELER






Wiek: 25
Na forum: 3964 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

je?eli chcesz aby by?y obr?cone o 180 to dodaj do tych pierwszy sze?ciu
I tak w ka?dym te ostatnie 0, 0, 180 ;)

np.

 {462, -1987.7, 902.79999, 44.9, 0, 0, 180},


tam zamiast

    pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5])


    pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[7], v[8], v[9], v[10], v[11])


[ Dodano: 2016-01-19, 14:14 ]
cuboid = createColCuboid(-1995.8308, 859.56134, 31.296875, 88.5, 49.5, 22.25)
local pojazdyPub = {
    {462, -1987.7, 902.79999, 44.9, 0, 0, 180}, 
    {462, -1986.5, 902.79999, 44.9, 0, 0, 180},
    {462, -1985.3, 902.70001, 44.9, 0, 0, 180},
    {462, -1984.1, 902.79999, 44.9, 0, 0, 180},
    {462, -1982.9, 902.59961, 44.9, 0, 0, 180},
    {462, -1981.7002, 902.70001, 44.9, 0, 0, 180},
    {462, -1987.5, 865.70001, 44.9},
    {462, -1986.4004, 865.7002, 44.9},
    {462, -1985.4, 865.59998, 44.9},
    {462, -1984.4, 865.59998, 44.9},
    {462, -1983.2998, 865.5, 44.9},
    {462, -1982.2, 865.5, 44.9}
}


for i,v in ipairs(pojazdyPub) do
    pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[7], v[8], v[9], v[10], v[11])
    setElementData(pojazd, "message","Pojazd Publiczny")
    setVehicleColor(pojazd, 255, 255, 255, 0, 160, 255)
    setElementFrozen(pojazd, true)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        setElementFrozen(source, false)
    end
end)


addEventHandler("onVehicleExit", resourceRoot, function()
setTimer(usun, 1000*60*5, 1, source)
end
)

function usun (pojazd)
if not pojazd then return end
if isElementWithinColShape(pojazd, cuboid) then return end
if isVehicleEmpty(pojazd) then
respawnElement(pojazd)
setElementFrozen(pojazd, true)
end
end

function isVehicleEmpty( vehicle )
    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then
        return true
    end
 
    local passengers = getVehicleMaxPassengers( vehicle )
    if type( passengers ) == 'number' then
        for seat = 0, passengers do
            if getVehicleOccupant( vehicle, seat ) then
                return false
            end
        end
    end
    return true
end



powinno dzia?a? :D

Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 14:16


Daisu

Programista Lua






Wiek: 26
Na forum: 4585 dni
Posty: 192
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

Okej Rotacja dzia?a teraz tylko nie respi auta :


cuboid = createColCuboid(-1995.8308, 859.56134, 31.296875, 88.5, 49.5, 22.25)
local pojazdyPub = {
    {462, -1987.7, 902.79999, 44.9, 0, 0, 180}, 
    {462, -1986.5, 902.79999, 44.9, 0, 0, 180},
    {462, -1985.3, 902.70001, 44.9, 0, 0, 180},
    {462, -1984.1, 902.79999, 44.9, 0, 0, 180},
    {462, -1982.9, 902.59961, 44.9, 0, 0, 180},
    {462, -1981.7002, 902.70001, 44.9, 0, 0, 180},
    {462, -1987.5, 865.70001, 44.9},
    {462, -1986.4004, 865.7002, 44.9},
    {462, -1985.4, 865.59998, 44.9},
    {462, -1984.4, 865.59998, 44.9},
    {462, -1983.2998, 865.5, 44.9},
    {462, -1982.2, 865.5, 44.9}
}

for i,v in ipairs(pojazdyPub) do
    pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[7], v[8], v[9], v[10], v[11], v[12])
    setElementData(pojazd, "message","Pojazd Publiczny")
    setVehicleColor(pojazd, 255, 255, 255, 0, 160, 255)
    setElementFrozen(pojazd, true)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        setElementFrozen(source, false)
    end
end)


addEventHandler("onVehicleExit", resourceRoot, function()
setTimer(usun, 1000*60*5, 1, source)
end
)

function usun (pojazd)
if not pojazd then return end
if isElementWithinColShape(pojazd, cuboid) then return end
if isVehicleEmpty(pojazd) then
respawnElement(pojazd)
setElementFrozen(pojazd, true)
end
end

function isVehicleEmpty( vehicle )
    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then
        return true
    end
 
    local passengers = getVehicleMaxPassengers( vehicle )
    if type( passengers ) == 'number' then
        for seat = 0, passengers do
            if getVehicleOccupant( vehicle, seat ) then
                return false
            end
        end
    end
    return true
end




B??d:


s.lua:40: attempt to call global 'respawnElement' (a nil value)


Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 14:25


venzikk

LUA, MODELER






Wiek: 25
Na forum: 3964 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

Spr?buj teraz ;D


cuboid = createColCuboid(-1995.8308, 859.56134, 31.296875, 88.5, 49.5, 22.25)
local pojazd = {
    {462, -1987.7, 902.79999, 44.9, 0, 0, 180}, 
    {462, -1986.5, 902.79999, 44.9, 0, 0, 180},
    {462, -1985.3, 902.70001, 44.9, 0, 0, 180},
    {462, -1984.1, 902.79999, 44.9, 0, 0, 180},
    {462, -1982.9, 902.59961, 44.9, 0, 0, 180},
    {462, -1981.7002, 902.70001, 44.9, 0, 0, 180},
    {462, -1987.5, 865.70001, 44.9},
    {462, -1986.4004, 865.7002, 44.9},
    {462, -1985.4, 865.59998, 44.9},
    {462, -1984.4, 865.59998, 44.9},
    {462, -1983.2998, 865.5, 44.9},
    {462, -1982.2, 865.5, 44.9}
}

for i,v in ipairs(pojazd) do
    pojazd = createVehicle(v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[7], v[8], v[9], v[10], v[11], v[12])
    setElementData(pojazd, "message","Pojazd Publiczny")
    setVehicleColor(pojazd, 255, 255, 255, 0, 160, 255)
    setElementFrozen(pojazd, true)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        setElementFrozen(source, false)
    end
end)


addEventHandler("onVehicleExit", resourceRoot, function()
setTimer(usun, 1000*60*5, 1, source)
end
)

function usun (pojazd)
if not pojazd then return end
if isElementWithinColShape(pojazd, cuboid) then return end
if isVehicleEmpty(pojazd) then
respawnElement(pojazd)
setElementFrozen(pojazd, true)
end
end

function isVehicleEmpty( vehicle )
    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then
        return true
    end
 
    local passengers = getVehicleMaxPassengers( vehicle )
    if type( passengers ) == 'number' then
        for seat = 0, passengers do
            if getVehicleOccupant( vehicle, seat ) then
                return false
            end
        end
    end
    return true
end



Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 14:29


Fanciak

BOT






Wiek: 26
Na forum: 4587 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500

Zamiast createVehicle([1][2][3]) itd... Mo?esz zrobi? tak:


for i,v in ipairs(pojazd) do
    pojazd = createVehicle(unpack(v))


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 15:01


Daisu

Programista Lua






Wiek: 26
Na forum: 4585 dni
Posty: 192
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90


s.lua:40: attempt to call global 'respawnElement' (a nil value)


Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 15:07


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

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

Ostrzeżeń: 60%
Wybacz, to ja rozpocz??em t? fal? error?w, pisa?em na szybko i popapra?em funkcj?, prawid?owa to


Więcej informacji znajdziesz w Wikipedii MTA:

respawnVehicle
a nie element xD

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 15:22


Daisu

Programista Lua






Wiek: 26
Na forum: 4585 dni
Posty: 192
SPONSOR
Nick w MP: Daisu

Piwa: 24

Respekt: 90

DestroY Wygra? teleturniej error?w. Dzi?ki ka?demu za pomoc skrypt dzia?a w 100% :D

Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: darmowe :: auta :: (timer)
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Darmowe Auta (Timer) 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