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

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


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Witam, chcia?bym zrobi? zapis tuningu engineAcceleration. Jak to zrobi? ? :)


handler dbConnect("sqlite""pojazdy.db") 

--pojazdy
dbExec(handler"CREATE TABLE IF NOT EXISTS pojazdy (id INTEGER PRIMARY KEY AUTOINCREMENT, wlasciciel TEXT, model INTEGER, x FLOAT, y FLOAT, z FLOAT, rot FLOAT, ca INTEGER, cb INTEGER, cc INTEGER, przebieg FLOAT, paliwo FLOAT)")
dbExec(handler"CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on pojazdy(id)")

--tuning
dbExec(handler"CREATE TABLE IF NOT EXISTS tuning (id INTEGER, t0 INTEGER, t1 INTEGER, t2 INTEGER, t3 INTEGER, t4 INTEGER, t5 INTEGER, t6 INTEGER, t7 INTEGER, t8 INTEGER, t9 INTEGER, t10 INTEGER, t11 INTEGER, t12 INTEGER, t13 INTEGER, t14 INTEGER, t15 INTEGER, t16 INTEGER, paintjob INTEGER, hr INTEGER, hg INTEGER, hb INTEGER)")
dbExec(handler"CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on tuning(id)")


function onStartLoadVehicles()
local query dbQuery(handler"SELECT * FROM pojazdy")
local resultnum_rowserrormsg dbPoll (query, -1)
    for i,v in pairs(result) do
    local veh createVehicle(v["model"], v["x"], v["y"], v["z"])
    setElementRotation(veh00v["rot"])
    setVehicleColor(vehv["ca"], v["cb"], v["cc"])
    ustawDanePojazdu(vehv["id"], v["wlasciciel"])
    
    --ustawiam paliwo i przebieg
    setElementData(veh"pojazd_paliwo"v["paliwo"] or 50)
    setElementData(veh"pojazd_przebieg"v["przebieg"] or 0)
    --<< na koncu -->>
    local query dbQuery(handler"SELECT * FROM tuning WHERE id='"..v["id"].."'")
    local resultnum_rowserrormsg dbPoll (query, -1)
    setVehiclePaintjob(vehresult[1].paintjob)
    setVehicleHeadLightColor(vehresult[1].hrresult[1].hgresult[1].hb)
        for i,v in pairs(result) do
            for iivv in pairs(v) do
                if (ii ~= "id" and ii ~= "paintjob" and ii ~= "hr" and ii ~= "hg" and ii ~= "hb"then
                local vv tonumber(vv)
                    if vv ~= 0 then
                    addVehicleUpgrade(vehvv)
                    end
                end
            end
        end
    end
end
addEventHandler("onResourceStart"getResourceRootElement(getThisResource()), onStartLoadVehicles)

function ustawDanePojazdu(vehidwlasciciel) --id INTwlasciciel STRING
setElementData(veh"car_id"id)
setElementData(veh"car_owner"wlasciciel)
end

function onVehicleStartEnter(playerseatjacked)
  if seat == 0 then
  local car_owner getElementData(source"car_owner")
    if car_owner then
    local account getPlayerAccount(player)
        if account then
        local name getAccountName(account)
            if car_owner == name then
            --mamy prawo wejscia do auta
            prawo_ true
            end
        end
    
        if prawo_ then
        --wchodzim
        prawo_ false
        else
        --sio
        outputChatBox("Nie masz kluczyk?w do tego pojazdu."player255255255true)
        cancelEvent()
        end
    end
  end
end
addEventHandler ("onVehicleStartEnter"resourceRootonVehicleStartEnter)

--<<ZAPIS POJAZDU-->>

function zapiszPojazdy()
    for i,v in pairs(getElementsByType("vehicle")) do
    local id getElementData(v"car_id")
        if id then
        local owner getElementData(v"car_owner")
        local xygetElementPosition(v)
        local __rot getElementRotation(v)
        local color1color2color3color4 getVehicleColor(vtrue)
        local paliwo getElementData(v"pojazd_paliwo")
        local przebieg getElementData(v"pojazd_przebieg")
        dbExec(handler"UPDATE pojazdy SET x='"..x.."', y='"..y.."', z='"..z.."', rot='"..rot.."', ca='"..color1.."', cb='"..color2.."', cc='"..color3.."', przebieg='"..przebieg.."', paliwo='"..paliwo.."' WHERE id='"..id.."'")
        
        local paintjob getVehiclePaintjob(v)
        local rggetVehicleHeadLightColor(v)
        sav = {}
            for i=016 do
            local upgrade getVehicleUpgradeOnSlot(vi)
            sav[i] = upgrade or 0
            end
        dbExec(handler"UPDATE tuning SET t0='"..sav[0].."', t1='"..sav[1].."', t2='"..sav[2].."', t3='"..sav[3].."', t4='"..sav[4].."', t5='"..sav[5].."', t6='"..sav[6].."', t7='"..sav[7].."', t8='"..sav[8].."', t9='"..sav[9].."', t10='"..sav[10].."', t11='"..sav[11].."', t12='"..sav[12].."', t13='"..sav[13].."', t14='"..sav[14].."', t15='"..sav[15].."', t16='"..sav[16].."', paintjob='"..paintjob.."', hr='"..r.."', hg='"..g.."', hb='"..b.."' WHERE id="..id.."")
        sav nil
        end
    end
end
setTimer(zapiszPojazdy50000)

function zapiszKomenda(player)
local acc getAccountName (getPlayerAccount(player))
    if isObjectInACLGroup ("user."..accaclGetGroup ("Admin")) then
    zapiszPojazdy()
    outputChatBox("** Zapisano pojazdy."player255255255true)
    end
end
addCommandHandler("zapiszpojazdy"zapiszKomenda)

-- mapaf11
addEvent("pobierzPojazdyGracza"true)
addEventHandler("pobierzPojazdyGracza"getRootElement(),
function()
local account getPlayerAccount(source)
    if account then
    local name getAccountName(account)
    local vehs getVehiclesByOwner(name)
    triggerClientEvent(source"zwrocPojazdyGracza"rootvehs)
    end
end)

--
--zwraca pojazd o danym ID
function getVehicleByID(poszukiwane_id)
    for i,v in pairs(getElementsByType("vehicle")) do
    local id getElementData(v"car_id")
        if id then
        local id tonumber(id)
        local poszukiwane_id tonumber(poszukiwane_id)
            if id == poszukiwane_id then
            return v
            end
        end
    end
    return false
end

--zwraca pojazdy ktore posiada dany login
function getVehiclesByOwner(szukany)
tab = {}
    for i,v in pairs(getElementsByType("vehicle")) do
    local owner getElementData(v"car_owner")
        if owner then
            if owner == szukany then
            table.insert(tabv)
            end
        end
    end
    return tab
end

--zwraca liczbe pojazdow jaka ma dany login
function getYourVehicleCount(login)
local vehs getVehiclesByOwner(login)
return #vehs
end


Za pomoc daje :piwo: :piwo: :piwo:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-19, 23:24


Kronix.Cooder







Wiek: 36
Na forum: 4900 dni
Posty: 26

Piwa: 15

Respekt: 90


handler dbConnect("sqlite""pojazdy.db") 

--pojazdy
dbExec(handler"CREATE TABLE IF NOT EXISTS pojazdy (id INTEGER PRIMARY KEY AUTOINCREMENT, wlasciciel TEXT, model INTEGER, x FLOAT, y FLOAT, z FLOAT, rot FLOAT, ca INTEGER, cb INTEGER, cc INTEGER, przebieg FLOAT, paliwo FLOAT)")
dbExec(handler"CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on pojazdy(id)")

--tuning
dbExec(handler"CREATE TABLE IF NOT EXISTS tuning (id INTEGER, t0 INTEGER, t1 INTEGER, t2 INTEGER, t3 INTEGER, t4 INTEGER, t5 INTEGER, t6 INTEGER, t7 INTEGER, t8 INTEGER, t9 INTEGER, t10 INTEGER, t11 INTEGER, t12 INTEGER, t13 INTEGER, t14 INTEGER, t15 INTEGER, t16 INTEGER, paintjob INTEGER, hr INTEGER, hg INTEGER, hb INTEGER, ea FLOAT)")
dbExec(handler"CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on tuning(id)")


function onStartLoadVehicles()
local query dbQuery(handler"SELECT * FROM pojazdy")
local resultnum_rowserrormsg dbPoll (query, -1)
    for i,v in pairs(result) do
    local veh createVehicle(v["model"], v["x"], v["y"], v["z"])
    setElementRotation(veh00v["rot"])
    setVehicleColor(vehv["ca"], v["cb"], v["cc"])
    ustawDanePojazdu(vehv["id"], v["wlasciciel"])
    
    
    
    --ustawiam paliwo i przebieg
    setElementData(veh"pojazd_paliwo"v["paliwo"] or 50)
    setElementData(veh"pojazd_przebieg"v["przebieg"] or 0)
    --<< na koncu -->>
    local query dbQuery(handler"SELECT * FROM tuning WHERE id='"..v["id"].."'")
    local resultnum_rowserrormsg dbPoll (query, -1)
    setVehiclePaintjob(vehresult[1].paintjob)
    setVehicleHeadLightColor(vehresult[1].hrresult[1].hgresult[1].hb)
    
    --ustawienie eA
    setVehicleHandling(veh"engineAcceleration"result[1].ea )
    
        for i,v in pairs(result) do
            for iivv in pairs(v) do
                if (ii ~= "id" and ii ~= "paintjob" and ii ~= "hr" and ii ~= "hg" and ii ~= "hb"then
                local vv tonumber(vv)
                    if vv ~= 0 then
                    addVehicleUpgrade(vehvv)
                    end
                end
            end
        end
    end
end
addEventHandler("onResourceStart"getResourceRootElement(getThisResource()), onStartLoadVehicles)

function ustawDanePojazdu(vehidwlasciciel) --id INTwlasciciel STRING
setElementData(veh"car_id"id)
setElementData(veh"car_owner"wlasciciel)
end

function onVehicleStartEnter(playerseatjacked)
  if seat == 0 then
  local car_owner getElementData(source"car_owner")
    if car_owner then
    local account getPlayerAccount(player)
        if account then
        local name getAccountName(account)
            if car_owner == name then
            --mamy prawo wejscia do auta
            prawo_ true
            end
        end
    
        if prawo_ then
        --wchodzim
        prawo_ false
        else
        --sio
        outputChatBox("Nie masz kluczyk?w do tego pojazdu."player255255255true)
        cancelEvent()
        end
    end
  end
end
addEventHandler ("onVehicleStartEnter"resourceRootonVehicleStartEnter)

--<<ZAPIS POJAZDU-->>

function zapiszPojazdy()
    for i,v in pairs(getElementsByType("vehicle")) do
    local id getElementData(v"car_id")
        if id then
        local owner getElementData(v"car_owner")
        local xygetElementPosition(v)
        local __rot getElementRotation(v)
        local color1color2color3color4 getVehicleColor(vtrue)
        local paliwo getElementData(v"pojazd_paliwo")
        local przebieg getElementData(v"pojazd_przebieg")
        dbExec(handler"UPDATE pojazdy SET x='"..x.."', y='"..y.."', z='"..z.."', rot='"..rot.."', ca='"..color1.."', cb='"..color2.."', cc='"..color3.."', przebieg='"..przebieg.."', paliwo='"..paliwo.."' WHERE id='"..id.."'")
        
        local paintjob getVehiclePaintjob(v)
        local rggetVehicleHeadLightColor(v)
        sav = {}
            for i=016 do
            local upgrade getVehicleUpgradeOnSlot(vi)
            sav[i] = upgrade or 0
            end
        dbExec(handler"UPDATE tuning SET t0='"..sav[0].."', t1='"..sav[1].."', t2='"..sav[2].."', t3='"..sav[3].."', t4='"..sav[4].."', t5='"..sav[5].."', t6='"..sav[6].."', t7='"..sav[7].."', t8='"..sav[8].."', t9='"..sav[9].."', t10='"..sav[10].."', t11='"..sav[11].."', t12='"..sav[12].."', t13='"..sav[13].."', t14='"..sav[14].."', t15='"..sav[15].."', t16='"..sav[16].."', paintjob='"..paintjob.."', hr='"..r.."', hg='"..g.."', hb='"..b.."', ea='"..getVehicleHandling(v).engineAcceleration.."' WHERE id="..id.."")
        sav nil
        end
    end
end
setTimer(zapiszPojazdy50000)

function zapiszKomenda(player)
local acc getAccountName (getPlayerAccount(player))
    if isObjectInACLGroup ("user."..accaclGetGroup ("Admin")) then
    zapiszPojazdy()
    outputChatBox("** Zapisano pojazdy."player255255255true)
    end
end
addCommandHandler("zapiszpojazdy"zapiszKomenda)

-- mapaf11
addEvent("pobierzPojazdyGracza"true)
addEventHandler("pobierzPojazdyGracza"getRootElement(),
function()
local account getPlayerAccount(source)
    if account then
    local name getAccountName(account)
    local vehs getVehiclesByOwner(name)
    triggerClientEvent(source"zwrocPojazdyGracza"rootvehs)
    end
end)

--
--zwraca pojazd o danym ID
function getVehicleByID(poszukiwane_id)
    for i,v in pairs(getElementsByType("vehicle")) do
    local id getElementData(v"car_id")
        if id then
        local id tonumber(id)
        local poszukiwane_id tonumber(poszukiwane_id)
            if id == poszukiwane_id then
            return v
            end
        end
    end
    return false
end

--zwraca pojazdy ktore posiada dany login
function getVehiclesByOwner(szukany)
tab = {}
    for i,v in pairs(getElementsByType("vehicle")) do
    local owner getElementData(v"car_owner")
        if owner then
            if owner == szukany then
            table.insert(tabv)
            end
        end
    end
    return tab
end

--zwraca liczbe pojazdow jaka ma dany login
function getYourVehicleCount(login)
local vehs getVehiclesByOwner(login)
return #vehs
end


nie zapomnij doda? w tabeli tuning kolumny `ea` typu FLOAT albo usu? plik pojazdy.db aby si? utworzy?o na nowo. (uwaga: usuni?cie pliku spowoduje utrat? zapisanych danych)

Oraz dodaj sobie tam gdzie masz INSERT INTO ...
getVehicleHandling(vehicle).engineAcceleration

vehicle - to oczywi?cie pojazd

Postaw piwo autorowi tego posta
 

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


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Kronix.Cooder, W sensie pod INSERT INTO ? :) w SQL nie czaje ;)

Postaw piwo autorowi tego posta
 

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


Kronix.Cooder







Wiek: 36
Na forum: 4900 dni
Posty: 26

Piwa: 15

Respekt: 90

nie, do??cz jako argument,
podpatrz sobie co zmieni?em w twoim kodzie tam gdzie jest UPDATE tuning

albo pode?lij linie gdzie jest u ciebie INSERT INTO to ci zmienie

edit:
chyba ?e pojazdy do tabeli w sql dodajesz poza tym skryptem?
nie wiem jak to u ciebie jest

chodzi o fragment skryptu gdzie dodajesz nowy pojazd do sql

Ostatnio zmieniony przez Kronix.Cooder 2016-01-20, 00:22, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

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


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Kronix.Cooder, chodzi ci o:

dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 00:28


Kronix.Cooder







Wiek: 36
Na forum: 4900 dni
Posty: 26

Piwa: 15

Respekt: 90

tak, dok?adnie
prawdopodobnie nad tym masz INSERT INTO pojazdy , a nad tym zapewne u?ywasz twojazmienna = createVehicle(...blabla

wi?c podmie? sobie vehicle na nazw? twojej zmiennej.

dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb,ea) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb,getVehicleHandling(vehicle).engineAcceleration)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 00:32


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Kronix.Cooder, wi?c m?j kod :

local salon createMarker(-1948.5272.1000061035234.6"cylinder"125500100)

function onSalonHit(hitElementdim)
    if getElementType(hitElement) == "player" then
    triggerClientEvent(hitElement"pokazGUISalonu"rootsalonowePojazdy)
    end
end
addEventHandler("onMarkerHit"salononSalonHit)

addEvent("kupPojazdSalon"true)
addEventHandler("kupPojazdSalon"getRootElement(),
function(id)
local cena salonowePojazdy[id]
    if cena then
        if getPlayerMoney(source) >= cena then
        local account getPlayerAccount(source)
          if account then
          local wlasciciel getAccountName(account)
            if 10000 >= getYourVehicleCount(wlascicielthen
            takePlayerMoney(sourcecena)
            triggerClientEvent(source"potwierdzKupnoPojazduPrywatnego"root)
            fadeCamera(sourcefalse)
                setTimer(function(source)
                local xyzrot = -1987.46276.1834.86270
                local veh createVehicle(idxyz)
                setElementData(veh"pojazd_paliwo"50) --na specjalna prosbe ;)
                setElementData(veh"pojazd_przebieg"0)
                local rggetVehicleColor(vehtrue)
                fadeCamera(sourcetrue)
                --<<-->>
                local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)"wlascicielidxyzrotrgb500)
                local resultnum_affected_rowslast_insert_id dbPoll(query, -1)
                local rggetVehicleHeadLightColor(veh)
                dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb)
                --<<-->>
                setElementRotation(veh00rot)
                ustawDanePojazdu(vehlast_insert_idwlasciciel)
                warpPedIntoVehicle(sourceveh)
                end15001source)
            else
            outputChatBox("Mo?esz posiada? maksymalnie . pojazd?w."source255255255true)
            end
          end
        else
        outputChatBox("Potrzebujesz "..cena.."Euro by kupi? ten pojazd."source255255255true)
        end
    end
end)

--komenda tworzaca
function stworzPojazdCMD(playercmdidwlasciciel)
local acc getAccountName (getPlayerAccount(player))
    if acc then
    if isObjectInACLGroup ("user."..accaclGetGroup ("RCON")) then
        if id and wlasciciel then
        local id tonumber(id)
            if id then
                if getVehicleNameFromModel(idthen
                local xygetElementPosition(player)
                local __rot getElementRotation(player)
                
                local veh createVehicle(idxyz)
                    if veh then
                    setElementData(veh"pojazd_paliwo"50) --na specjalna prosbe ;)
                    setElementData(veh"pojazd_przebieg"0)
                    local rggetVehicleColor(vehtrue)
                    --<<-->>
                    local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)"wlascicielidxyzrotrgb500)
                    local resultnum_affected_rowslast_insert_id dbPoll(query, -1)
                    local rggetVehicleHeadLightColor(veh)
                    dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb)
                    --<<-->>
                    setElementRotation(veh00rot)
                    ustawDanePojazdu(vehlast_insert_idwlasciciel)
                    else
                    outputChatBox("Podane ID jest niepoprawne."player255255255true)
                    end
                else
                outputChatBox("Podane ID jest niepoprawne."player255255255true)
                end
            end
        else
        outputChatBox("Wpisz /stworz [id-pojazdu] [wlasciciel]"player255255255true)
        end
    end
    end
end
addCommandHandler("stworz"stworzPojazdCMD)

i do ka?dego ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 00:38


Kronix.Cooder







Wiek: 36
Na forum: 4900 dni
Posty: 26

Piwa: 15

Respekt: 90

local salon createMarker(-1948.5272.1000061035234.6"cylinder"125500100)

function onSalonHit(hitElementdim)
    if getElementType(hitElement) == "player" then
    triggerClientEvent(hitElement"pokazGUISalonu"rootsalonowePojazdy)
    end
end
addEventHandler("onMarkerHit"salononSalonHit)

addEvent("kupPojazdSalon"true)
addEventHandler("kupPojazdSalon"getRootElement(),
function(id)
local cena salonowePojazdy[id]
    if cena then
        if getPlayerMoney(source) >= cena then
        local account getPlayerAccount(source)
          if account then
          local wlasciciel getAccountName(account)
            if 10000 >= getYourVehicleCount(wlascicielthen
            takePlayerMoney(sourcecena)
            triggerClientEvent(source"potwierdzKupnoPojazduPrywatnego"root)
            fadeCamera(sourcefalse)
                setTimer(function(source)
                local xyzrot = -1987.46276.1834.86270
                local veh createVehicle(idxyz)
                setElementData(veh"pojazd_paliwo"50) --na specjalna prosbe ;)
                setElementData(veh"pojazd_przebieg"0)
                local rggetVehicleColor(vehtrue)
                fadeCamera(sourcetrue)
                --<<-->>
                local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)"wlascicielidxyzrotrgb500)
                local resultnum_affected_rowslast_insert_id dbPoll(query, -1)
                local rggetVehicleHeadLightColor(veh)
                dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb,ae) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb,getVehicleHandling(veh).engineAcceleration)
                --<<-->>
                setElementRotation(veh00rot)
                ustawDanePojazdu(vehlast_insert_idwlasciciel)
                warpPedIntoVehicle(sourceveh)
                end15001source)
            else
            outputChatBox("Mo?esz posiada? maksymalnie . pojazd?w."source255255255true)
            end
          end
        else
        outputChatBox("Potrzebujesz "..cena.."Euro by kupi? ten pojazd."source255255255true)
        end
    end
end)

--komenda tworzaca
function stworzPojazdCMD(playercmdidwlasciciel)
local acc getAccountName (getPlayerAccount(player))
    if acc then
    if isObjectInACLGroup ("user."..accaclGetGroup ("RCON")) then
        if id and wlasciciel then
        local id tonumber(id)
            if id then
                if getVehicleNameFromModel(idthen
                local xygetElementPosition(player)
                local __rot getElementRotation(player)
                
                local veh createVehicle(idxyz)
                    if veh then
                    setElementData(veh"pojazd_paliwo"50) --na specjalna prosbe ;)
                    setElementData(veh"pojazd_przebieg"0)
                    local rggetVehicleColor(vehtrue)
                    --<<-->>
                    local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)"wlascicielidxyzrotrgb500)
                    local resultnum_affected_rowslast_insert_id dbPoll(query, -1)
                    local rggetVehicleHeadLightColor(veh)
                    dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb,ea) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb,getVehicleHandling(veh).engineAcceleration)
                    --<<-->>
                    setElementRotation(veh00rot)
                    ustawDanePojazdu(vehlast_insert_idwlasciciel)
                    else
                    outputChatBox("Podane ID jest niepoprawne."player255255255true)
                    end
                else
                outputChatBox("Podane ID jest niepoprawne."player255255255true)
                end
            end
        else
        outputChatBox("Wpisz /stworz [id-pojazdu] [wlasciciel]"player255255255true)
        end
    end
    end
end
addCommandHandler("stworz"stworzPojazdCMD)


mam nadzieje si? nie pomyli?em

pamieta?e? o dodaniu kolumny w sql?
albo usun?? plik je?li jest tylko kilka pojazd?w zapisanych aby sie baza utworzy?a na nowo?

Ostatnio zmieniony przez Kronix.Cooder 2016-01-20, 00:42, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 00:40


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Kronix.Cooder, tak :)

[ Dodano: 2016-01-20, 00:42 ]
DB mam

[ Dodano: 2016-01-20, 00:42 ]
Ta linijka :

dbExec(handler"UPDATE tuning SET t0='"..sav[0].."', t1='"..sav[1].."', t2='"..sav[2].."', t3='"..sav[3].."', t4='"..sav[4].."', t5='"..sav[5].."', t6='"..sav[6].."', t7='"..sav[7].."', t8='"..sav[8].."', t9='"..sav[9].."', t10='"..sav[10].."', t11='"..sav[11].."', t12='"..sav[12].."', t13='"..sav[13].."', t14='"..sav[14].."', t15='"..sav[15].."', t16='"..sav[16].."', paintjob='"..paintjob.."', hr='"..r.."', hg='"..g.."', hb='"..b.."', ea='"..getVehicleHandling(v).engineAcceleration.."' WHERE id="..id.."")


Nowa baza danych jest

[ Dodano: 2016-01-20, 00:45 ]
oraz przy tworzeniu pojazdu :


linijka :
dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb,ea) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb,getVehicleHandling(vehicle).engineAcceleration)


155

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 00:54


Kronix.Cooder







Wiek: 36
Na forum: 4900 dni
Posty: 26

Piwa: 15

Respekt: 90

linijka 155 masz ?le, sprawdz

sprawd? czy masz tak samo
przetestowa?em ten kod u siebie i jest ok :
--komenda tworzaca
function stworzPojazdCMD(playercmdidwlasciciel)
local acc getAccountName (getPlayerAccount(player))
    if acc then
    if isObjectInACLGroup ("user."..accaclGetGroup ("RCON")) then
        if id and wlasciciel then
        local id tonumber(id)
            if id then
                if getVehicleNameFromModel(idthen
                local xygetElementPosition(player)
                local __rot getElementRotation(player)
                
                local veh createVehicle(idxyz)
                    if veh then
                    setElementData(veh"pojazd_paliwo"50) --na specjalna prosbe ;)
                    setElementData(veh"pojazd_przebieg"0)
                    local rggetVehicleColor(vehtrue)
                    --<<-->>
                    local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)"wlascicielidxyzrotrgb500)
                    local resultnum_affected_rowslast_insert_id dbPoll(query, -1)
                    local rggetVehicleHeadLightColor(veh)
                    dbExec(handler"INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb,ea) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"last_insert_id"0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""0""3"rgb,getVehicleHandling(veh).engineAcceleration)
                    --<<-->>
                    setElementRotation(veh00rot)
                    ustawDanePojazdu(vehlast_insert_idwlasciciel)
                    else
                    outputChatBox("Podane ID jest niepoprawne."player255255255true)
                    end
                else
                outputChatBox("Podane ID jest niepoprawne."player255255255true)
                end
            end
        else
        outputChatBox("Wpisz /stworz [id-pojazdu] [wlasciciel]"player255255255true)
        end
    end
    end
end
addCommandHandler("stworz"stworzPojazdCMD)


handler dbConnect("sqlite""pojazdy.db") 

--pojazdy
dbExec(handler"CREATE TABLE IF NOT EXISTS pojazdy (id INTEGER PRIMARY KEY AUTOINCREMENT, wlasciciel TEXT, model INTEGER, x FLOAT, y FLOAT, z FLOAT, rot FLOAT, ca INTEGER, cb INTEGER, cc INTEGER, przebieg FLOAT, paliwo FLOAT)")
dbExec(handler"CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on pojazdy(id)")

--tuning
dbExec(handler"CREATE TABLE IF NOT EXISTS tuning (id INTEGER, t0 INTEGER, t1 INTEGER, t2 INTEGER, t3 INTEGER, t4 INTEGER, t5 INTEGER, t6 INTEGER, t7 INTEGER, t8 INTEGER, t9 INTEGER, t10 INTEGER, t11 INTEGER, t12 INTEGER, t13 INTEGER, t14 INTEGER, t15 INTEGER, t16 INTEGER, paintjob INTEGER, hr INTEGER, hg INTEGER, hb INTEGER, ea FLOAT)")
dbExec(handler"CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on tuning(id)")


function onStartLoadVehicles()
local query dbQuery(handler"SELECT * FROM pojazdy")
local resultnum_rowserrormsg dbPoll (query, -1)
    for i,v in pairs(result) do
    local veh createVehicle(v["model"], v["x"], v["y"], v["z"])
    setElementRotation(veh00v["rot"])
    setVehicleColor(vehv["ca"], v["cb"], v["cc"])
    ustawDanePojazdu(vehv["id"], v["wlasciciel"])
    
    
    
    --ustawiam paliwo i przebieg
    setElementData(veh"pojazd_paliwo"v["paliwo"] or 50)
    setElementData(veh"pojazd_przebieg"v["przebieg"] or 0)
    --<< na koncu -->>
    local query dbQuery(handler"SELECT * FROM tuning WHERE id='"..v["id"].."'")
    local resultnum_rowserrormsg dbPoll (query, -1)
    setVehiclePaintjob(vehresult[1].paintjob)
    setVehicleHeadLightColor(vehresult[1].hrresult[1].hgresult[1].hb)
    
    --ustawienie eA
    setVehicleHandling(veh"engineAcceleration"result[1].ea )
    
        for i,v in pairs(result) do
            for iivv in pairs(v) do
                if (ii ~= "id" and ii ~= "paintjob" and ii ~= "hr" and ii ~= "hg" and ii ~= "hb"then
                local vv tonumber(vv)
                    if vv ~= 0 then
                    addVehicleUpgrade(vehvv)
                    end
                end
            end
        end
    end
end
addEventHandler("onResourceStart"getResourceRootElement(getThisResource()), onStartLoadVehicles)

function ustawDanePojazdu(vehidwlasciciel) --id INTwlasciciel STRING
setElementData(veh"car_id"id)
setElementData(veh"car_owner"wlasciciel)
end

function onVehicleStartEnter(playerseatjacked)
  if seat == 0 then
  local car_owner getElementData(source"car_owner")
    if car_owner then
    local account getPlayerAccount(player)
        if account then
        local name getAccountName(account)
            if car_owner == name then
            --mamy prawo wejscia do auta
            prawo_ true
            end
        end
    
        if prawo_ then
        --wchodzim
        prawo_ false
        else
        --sio
        outputChatBox("Nie masz kluczyk?w do tego pojazdu."player255255255true)
        cancelEvent()
        end
    end
  end
end
addEventHandler ("onVehicleStartEnter"resourceRootonVehicleStartEnter)

--<<ZAPIS POJAZDU-->>

function zapiszPojazdy()
    for i,v in pairs(getElementsByType("vehicle")) do
    local id getElementData(v"car_id")
        if id then
        local owner getElementData(v"car_owner")
        local xygetElementPosition(v)
        local __rot getElementRotation(v)
        local color1color2color3color4 getVehicleColor(vtrue)
        local paliwo getElementData(v"pojazd_paliwo")
        local przebieg getElementData(v"pojazd_przebieg")
        dbExec(handler"UPDATE pojazdy SET x='"..x.."', y='"..y.."', z='"..z.."', rot='"..rot.."', ca='"..color1.."', cb='"..color2.."', cc='"..color3.."', przebieg='"..przebieg.."', paliwo='"..paliwo.."' WHERE id='"..id.."'")
        
        local paintjob getVehiclePaintjob(v)
        local rggetVehicleHeadLightColor(v)
        sav = {}
            for i=016 do
            local upgrade getVehicleUpgradeOnSlot(vi)
            sav[i] = upgrade or 0
            end
        dbExec(handler"UPDATE tuning SET t0='"..sav[0].."', t1='"..sav[1].."', t2='"..sav[2].."', t3='"..sav[3].."', t4='"..sav[4].."', t5='"..sav[5].."', t6='"..sav[6].."', t7='"..sav[7].."', t8='"..sav[8].."', t9='"..sav[9].."', t10='"..sav[10].."', t11='"..sav[11].."', t12='"..sav[12].."', t13='"..sav[13].."', t14='"..sav[14].."', t15='"..sav[15].."', t16='"..sav[16].."', paintjob='"..paintjob.."', hr='"..r.."', hg='"..g.."', hb='"..b.."', ea='"..getVehicleHandling(v).engineAcceleration.."' WHERE id="..id.."")
        sav nil
        end
    end
end
setTimer(zapiszPojazdy50000)

function zapiszKomenda(player)
local acc getAccountName (getPlayerAccount(player))
    if isObjectInACLGroup ("user."..accaclGetGroup ("Admin")) then
    zapiszPojazdy()
    outputChatBox("** Zapisano pojazdy."player255255255true)
    end
end
addCommandHandler("zapiszpojazdy"zapiszKomenda)

-- mapaf11
addEvent("pobierzPojazdyGracza"true)
addEventHandler("pobierzPojazdyGracza"getRootElement(),
function()
local account getPlayerAccount(source)
    if account then
    local name getAccountName(account)
    local vehs getVehiclesByOwner(name)
    triggerClientEvent(source"zwrocPojazdyGracza"rootvehs)
    end
end)

--
--zwraca pojazd o danym ID
function getVehicleByID(poszukiwane_id)
    for i,v in pairs(getElementsByType("vehicle")) do
    local id getElementData(v"car_id")
        if id then
        local id tonumber(id)
        local poszukiwane_id tonumber(poszukiwane_id)
            if id == poszukiwane_id then
            return v
            end
        end
    end
    return false
end

--zwraca pojazdy ktore posiada dany login
function getVehiclesByOwner(szukany)
tab = {}
    for i,v in pairs(getElementsByType("vehicle")) do
    local owner getElementData(v"car_owner")
        if owner then
            if owner == szukany then
            table.insert(tabv)
            end
        end
    end
    return tab
end

--zwraca liczbe pojazdow jaka ma dany login
function getYourVehicleCount(login)
local vehs getVehiclesByOwner(login)
return #vehs
end



Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 10:43


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Kronix.Cooder, ok zaraz wytestuje, a jak dodam do starej bazy to nie b?dzie wadzi?o ? Bo nie chcia? bym aut oddawac :) a z 80 pozycji mam, i si? to nadpiesze ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 11:02


Kronix.Cooder







Wiek: 36
Na forum: 4900 dni
Posty: 26

Piwa: 15

Respekt: 90

nawet jak dodasz r?cznie te kolumn? to stare pojazdy bed? mia?y warto?? `ea` 0 (ustawion? domy?ln?)
a ta warto?? powinna by? inna dla ka?dego przy uruchomieniu wczyta i wyjd? krzaki, czyli wszystkie stare pojazdy b?d? mia?y jednolity "engineAcceleration"

najlepiej na szybko napisa? konwerter
wczytanie pojazd?w z bazy '1'
zapis pojazd?w do bazy '2' razem z now? warto?ci? pobran? dla ka?dego pojazdu
?mia?o mo?na wykorzysta? z twojego skryptu wczytywanie i zapis.
dasz rade? czy nie bardzo?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 11:26


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Kronix.Cooder, Mam now? baze danych i nadal si? nie zapisuje :C
Tu DB

Tutaj Baza, powinno by? 17 a jest nadal 7.2


[ Dodano: 2016-01-20, 11:27 ]
sebik2303, co do tego zapisu i wczytywania to chyba nie za bardzo :C

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-01-20, 12:23


Kronix.Cooder







Wiek: 36
Na forum: 4900 dni
Posty: 26

Piwa: 15

Respekt: 90

Poddaje sie. Nie wiem co robisz ?le, testowa?em u siebie smiga a? mi?o.

pr?bowa?em celowo wywo?a? taki b??d, nie uda?o mi si?.
Preferujesz pomoc zdaln?? je?li tak pode?lij na pw

Postaw piwo autorowi tego posta
 

 
Tagi: zapis :: tuningu
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