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

Wysłany: 2014-08-25, 12:53


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
Witam, jak mog? wykona? respawn nieu?ywanych pojazd?w co 50 sekund?
Prosz? o przyk?ady.

Za pomoc dzi?kuje

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-25, 13:04


kubak14







Wiek: 24
Na forum: 5205 dni
Posty: 119
Nick w MP: Heavy

Piwa: 149

Respekt: 45,8

Ostrzeżeń: 20%
Nie wiem czy dzia?a (m?j starty skrypt) ale masz
function respawnVehiclevehicle )
    spawnVehicle vehiclegetElementDatavehicle"posX" ), getElementDatavehicle"posY" ), getElementDatavehicle"posZ" ), getElementDatavehicle"rotX" ), getElementDatavehicle"rotY" ), getElementDatavehicle"rotZ" ) )
end

function onVehicleSpawn ()
    local x,y,getElementPosition (source)
    local xr,yr,zr getElementRotation source )
        setElementData source"r1"tonumber(xr) )
        setElementData source"r2"tonumber(yr) )
        setElementData source"r3"tonumber(zr) )
    setElementData source,"posX",)
    setElementData source,"posY",)
    setElementData source,"posZ",)
end
addEventHandler ("onVehicleExplode",getRootElement(),onVehicleSpawn)

function onVehicleExplode ()
    setTimerrespawnVehicle50001source )
end
addEventHandler("onVehicleExplode"getRootElement(), onVehicleExplode)

addCommandHandler("respawn"respawnaut)
function respawnaut()
    setTimerrespawnVehicle100001source )
    outputChatBox("Za 10 sekund nast?pi respawn nie u?ywanych aut!")
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-25, 13:10


KukiX







Wiek: 34
Na forum: 6718 dni
Posty: 567

Piwa: 17560

Respekt: 160
Respekt: 160Respekt: 160


for i,theVehicle in pairs(getElementsByType("vehicle")) do
toggleVehicleRespawn(theVehicle,true)
setVehicleIdleRespawnDelay(theVehicle,50000)
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-25, 13:14


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
"kubak14" napisał/a:

Nie wiem czy dzia?a (m?j starty skrypt) ale masz
function respawnVehiclevehicle )
    spawnVehicle vehiclegetElementDatavehicle"posX" ), getElementDatavehicle"posY" ), getElementDatavehicle"posZ" ), getElementDatavehicle"rotX" ), getElementDatavehicle"rotY" ), getElementDatavehicle"rotZ" ) )
end

function onVehicleSpawn ()
    local x,y,getElementPosition (source)
    local xr,yr,zr getElementRotation source )
        setElementData source"r1"tonumber(xr) )
        setElementData source"r2"tonumber(yr) )
        setElementData source"r3"tonumber(zr) )
    setElementData source,"posX",)
    setElementData source,"posY",)
    setElementData source,"posZ",)
end
addEventHandler ("onVehicleExplode",getRootElement(),onVehicleSpawn)

function onVehicleExplode ()
    setTimerrespawnVehicle50001source )
end
addEventHandler("onVehicleExplode"getRootElement(), onVehicleExplode)

addCommandHandler("respawn"respawnaut)
function respawnaut()
    setTimerrespawnVehicle100001source )
    outputChatBox("Za 10 sekund nast?pi respawn nie u?ywanych aut!")
end


niestety nie dzia?a, b??dy bad argument z addcommand i z setelementdata i z getelementdata

Ostatnio zmieniony przez maxerxxl 2014-08-25, 13:21, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-25, 13:20


kubak14







Wiek: 24
Na forum: 5205 dni
Posty: 119
Nick w MP: Heavy

Piwa: 149

Respekt: 45,8

Ostrzeżeń: 20%
Poczekaj zaraz napisze

[ Dodano: 2014-08-25, 13:35 ]
Masz
function respawnVehicle(vehicle)
    if vehicle == nil then return end
    if getElementType(vehicle) ~= "vehicle" then return end

    sx getElementData(vehicle,"posX");
    sy getElementData(vehicle,"posY");
    sz getElementData(vehicle,"posZ");
    rx getElementData(vehicle,"rotX");
    ry getElementData(vehicle,"rotY");
    rz getElementData(vehicle,"rotZ");
    
    spawnVehicle vehicle,sxsyszrxryrz )

end


function vehicleExplode()

    setTimer respawnVehicle1000001source )

end 
addEventHandler "onVehicleExplode"getRootElement(), vehicleExplode );



[ Dodano: 2014-08-25, 13:37 ]
A komende chyba ?atwo dorobi?...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-25, 13:46


KukiX







Wiek: 34
Na forum: 6718 dni
Posty: 567

Piwa: 17560

Respekt: 160
Respekt: 160Respekt: 160

kubak14, po co piszesz na nowo funkcje respawnVehicle skoro ju? jest taka funkcja w MTA https://wiki.multitheftauto.com/wiki/RespawnVehicle ? Dodatkowo on chcia? kod na respawn nieu?ywanych pojazd?w co 50 sekund, a nie respawn zniszczonych pojazd?w.

Podpis
Moje skrypty MTA:
¤PlayDM
¤Mini-Games v0.2
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-25, 13:48


maxerxxl







Wiek: 30
Na forum: 5067 dni
Posty: 285
Nick w MP: MaXI

Piwa: 38

Respekt: 45,3

Ostrzeżeń: 100%
niestety nie dzia?a
m?j kod:
function respawnVehicle(vehicle)
    if vehicle == nil then return end
    if getElementType(vehicle) ~= "vehicle" then return end
    
    sx getElementData(vehicle,"posX");
    sy getElementData(vehicle,"posY");
    sz getElementData(vehicle,"posZ");
    rx getElementData(vehicle,"rotX");
    ry getElementData(vehicle,"rotY");
    rz getElementData(vehicle,"rotZ");
    
    spawnVehicle (vehiclesxsyszrxryrz)
end


function vehicleExplode()
    setTimer (respawnVehicle20001source)
end 
addEventHandler ("onVehicleExplode"getRootElement(), vehicleExplode)

function respawnaut()
    setTimer(respawnVehicle20001source )
    outputChatBox("Za 2 sekund nast?pi respawn nie u?ywanych aut!")
end
addCommandHandler("respawn"respawnaut)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-25, 20:41


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Kod sprawdz czy pojazd jest pusty, je?li jest to wykonuje kod dalej :


local respawn 30
local r
addCommandHandler("unspawn",function(player)
local accName getAccountName getPlayerAccount player ) )
     if not isObjectInACLGroup ("user."..accNameaclGetGroup "Admin" ) ) then return end
    if isTimer(rthen
        resetTimer(r)
        outputDebugString("Srut")
        return
    end
    outputChatBox"Respawn pojazd?w nast?pi za 30 sekund !",root255255255 )   
        outputDebugString("Srut")
    setTimer(function()
        for _vehicle in ipairs getElementsByType "vehicle" ) ) do 
        if getElementData vehicle"zapisany" then
        if isEmpty vehicle then
        local x getElementData vehicle"x" )
        local y getElementData vehicle"y" )
        local z getElementData vehicle"z" )
        local r1 getElementData vehicle"r1" )
        local r2 getElementData vehicle"r2" )
        local r3 getElementData vehicle"r3" )
        setElementPosition vehicletonumber(x), tonumber(y), tonumber(z) )
        setElementRotation vehicletonumber (r1), tonumber(r2), tonumber(r3) )
        end
            else 
            if isEmptyvehicle then
                destroyElement vehicle )
            end
        end
        end
        --end
        outputDebugString("Jeeeb unspawn")
        outputChatBox("Respawn pojazd?w gotowy"root255255255)
    end,respawn*1000,1)
end)

function isEmptyvehicle )
    local passengers getVehicleMaxPassengersvehicle )
    if typepassengers ) == 'number' then
        for seat 0passengers do
            if getVehicleOccupantvehicleseat then
                return false
            end
        end
    end
    return true
end


Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Tagi: respawn :: sekund
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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