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

Wysłany: 2016-04-26, 14:14


_Haze

Peace Yo!






Wiek: 24
Na forum: 4185 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

hej ostatnio robi?em system pojazd?w i p?tla mi nie dzia?a w onResourceStart
local conn dbConnect("sqlite","vehicles.db")




dbExec(conn"CREATE TABLE IF NOT EXISTS veh (model INTEGER, posx FLOAT, posy FLOAT, posz FLOAT, rotx FLOAT, roty  FLOAT, rotz FLOAT, red INTEGER, green INTEGER, blue INTEGER, player TEXT)")

function namePart(name)
    local name name and name:gsub("#%x%x%x%x%x%x"""):lower() or nil
    if name then
        for _player in ipairs(getElementsByType("player")) do
            local name_ getPlayerName(player):gsub("#%x%x%x%x%x%x"""):lower()
            if name_:find(name1truethen
                return player
            end
        end
    end
end

function resp()
outputChatBox("start1")
        local q dbQuery(conn"SELECT * FROM veh")
        outputChatBox("asd1")
        local res_rowid dbPoll(q, -1true)
        outputChatBox("asd2")
        outputChatBox("asd3")
            for kv in ipairs(res) do
        outputChatBox("asd4")
                local veh createVehicle(v["model"], v["posx"], v["posy"], v["posz"], v["rotx"], v["roty"], v["rotz"])
        outputChatBox("resp pojazduf")
        setVehicleColor(vehv["red"], v["green"], v["blue"])
        outputChatBox("asd5")
                setElementData(veh,"id",v["rowid"])
        outputChatBox("asd6")
                setElementData(veh,"own",v["player"])
        outputChatBox("asd7")
            end
        outputChatBox("asd7")
end
addEventHandler("onResourceStart",getRootElement(), resp)

addCommandHandler("veh",function(plr,cmd,id,plejer)
if tonumber(idthen
    if namePart(plejerthen
    local x,y,getElementPosition(namePart(plejer))
    local veh createVehicle(id,x,y,z)
        setElementData(veh"own"namePart(plejer))
        warpPedIntoVehicle(namePart(plejer), veh)
        local q dbQuery(conn"SELECT * FROM veh")
                   local result dbPoll(q, -1)
        for _,row in pairs(result) do
        setElementData(veh,"id",row["rowid"])
        end
            local id getElementData(veh,"id")
              local x,y,getElementPosition(veh)
             local rx,ry,rz getElementRotation(veh)
          local rgbcolor4 getVehicleColor(veh)
        outputChatBox("stworzyles pojazdd pedale")
              dbExec(conn,"UPDATE veh SET posx=?, posy=?, posz=?, rotx=?, roty=?, rotz=?, red='"..r.."', green='"..g.."', blue='"..b.."' WHERE rowid=?",x,y,z,rx,ry,rz,r,g,b,id) 
    end
end
end)


    function zapis(_,seat)
    for i,v in pairs(getElementsByType("vehicle")) do
        if seat == 0 then
            local id getElementData(v,"id")
            local x,y,getElementPosition(v)
            local rx,ry,rz getElementRotation(v)
        local rgbcolor4 getVehicleColor(v)
            dbExec(conn,"UPDATE veh SET posx=?, posy=?, posz=?, rotx=?, roty=?, rotz=?, red='"..r.."', green='"..g.."', blue='"..b.."' WHERE rowid=?",x,y,z,rx,ry,rz,r,g,b,id) 
    end
    end
    end
setTimer(zapis600000)


    function zapiscmd()
    for i,v in pairs(getElementsByType("vehicle")) do
            local id getElementData(v,"id")
            local x,y,getElementPosition(v)
            local rx,ry,rz getElementRotation(v)
        local rgbcolor4 getVehicleColor(v)
        if id then else end
        outputChatBox("save pojazduf")
            dbExec(conn,"UPDATE veh SET posx=?, posy=?, posz=?, rotx=?, roty=?, rotz=?, red='"..r.."', green='"..g.."', blue='"..b.."' WHERE rowid=?",x,y,z,rx,ry,rz,r,g,b,id) 
    end
    end
addCommandHandler("save"zapiscmd)


addEventHandler("onVehicleStartExit"root, 
    function(_,seat)
        if seat == 0 then
            local id getElementData(source,"id")
            local x,y,getElementPosition(source)
            local rx,ry,rz getElementRotation(source)
            local r,g,getVehicleColor(source)
            dbExec(conn,"UPDATE veh SET posx=?, posy=?, posz=?, rotx=?, roty=?, rotz=?, red=?, green=?, blue=? WHERE rowid=?",x,y,z,rx,ry,rz,r,g,b,id) 
        end
    end
)

outputuje
start1
asd1
asd2
asd3
asd7

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 14:20


#404







Wiek: 26
Na forum: 4772 dni
Posty: 1438

Piwa: 2512

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

Ostrzeżeń: 60%
Hazmudex, pr?bowa?e? podmieni? na pairs?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 14:42


_Haze

Peace Yo!






Wiek: 24
Na forum: 4185 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

ta nic sie nie dzialo nadal to samo

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 15:20


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Hazmudex, sprawd? :
function odczytaj_pojazdy()
local q dbQuery conn"SELECT * FROM veh" )
        local result dbPoll q, -)
        if result then
            for _,v in pairs result ) do
                local auto createVehicle v["model"], v["posx"], v["posy"], v["posz"], v["rotx"], v["roty"], v["rotz"] )
                setVehicleColor autov["red"], v["green"], v["blue"] )
                setElementData(auto"own"v["player"])
                setElementData(auto"id"v["rowid"])
            end
        end
end
addEventHandler("onResourceStart",resourceRootodczytaj_pojazdy)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 15:29


_Haze

Peace Yo!






Wiek: 24
Na forum: 4185 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

nie dzia?a to samo

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 15:38


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Hazmudex, zobacz czy masz pojazdy w bazie danych.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 15:44


_Haze

Peace Yo!






Wiek: 24
Na forum: 4185 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

nie mam

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 15:48


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Hazmudex, no to ci jak ma zrespi? pojazdy jak ich nie masz ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 15:51


_Haze

Peace Yo!






Wiek: 24
Na forum: 4185 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

w?a?nie powinny sie respi? bo tworze je komend? /veh i outputuje mi wiadomosc tylko nwm dlaczego nie zapisuja sie do db

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 15:57


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Hazmudex, nie znasz nawet zapyta? jakie zapytanie co robi.
http://gtao.pl/tut-poradn...te-vt102403.htm
Tu masz wszystkie zapytanie oraz przyk?ady.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 16:13


_Haze

Peace Yo!






Wiek: 24
Na forum: 4185 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

ok zrobi?em i dzia?a tylko update nie dzia?a a ja bawi?em sie kiedys w sqlite lecz nikt z gtao mi wtedy nie pom?g? a nie by?o twojego poradnika ;/


addEventHandler("onVehicleStartExit"root, 
    function(_,seat)
        if seat == 0 then
            local id getElementData(source,"id")
            local x,y,getElementPosition(source)
            local rx,ry,rz getElementRotation(source)
            local r,g,getVehicleColor(source)
            local asd dbQuery(conn"UPDATE veh SET posx=?, posy=?, posz=?, rotx=?, roty=?, rotz=? WHERE rowid=?"x,y,z,rx,ry,rz,r,g,b,id)
        if asd then
        outputChatBox("uptade")
        end
        end
    end
)

outputuje uptade ale jak resetuje to nie respi tam tylko tam gdzie by?o stworzone auto

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-26, 18:32


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Hazmudex, do sprawdzanie b??d?w jest dbFree.

Postaw piwo autorowi tego posta
 

 
Tagi: system :: pojazdow
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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