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

Wysłany: 2016-04-13, 22:40


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Witam mam problem z zapisem id na tablicy mam systempanaprezesa w poprzednim temacie barcioo pom?g? mi z tym jak zrobi? tworzenie tablic a teraz chodzi mi oto ?e jak restartne serwer to id na tablicy znika jak doda? to ?eby si? zapisywa?o
Za pomoc stawiam :piwo: i respekt

Ostatnio zmieniony przez Krzemo1234 2016-04-14, 14:25, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-13, 22:41


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%

Więcej informacji znajdziesz w Wikipedii MTA:

setVehiclePlateText


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-13, 23:07


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Robienie tablic mam potrzebne mi zapisywanie ich

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-14, 13:41


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

Musisz doda? do bazy danych kolumn? z tablic? rejestracyjn? i w odpowiednich funkcjach doda? wczytywanie oraz zapisywanie ich.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-14, 17:37


Barcioo

Kiedyś to było ST






Wiek: 26
Na forum: 4048 dni
Posty: 458
Nick w MP: Bartek.

Piwa: 1887

Respekt: 460
Respekt: 460

Krzemo1234,
 local query dbQuery(handler"INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo,ids) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?,?)"wlascicielididsxyzrotrgb500)
zamie? sobie to w 133 linijka :D

Podpis
Kanał Youtube;
A tu zapraszam
, pomogłem Ci? Wynagrodź mnie :piwo: :)


SUPPORT TEAM- 2016-09-03 do 2018-05-25
Test Mod- 2018-05-25
1k dni na Forum - 2018-01-28


GG: 62111935
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-14, 18:41


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Ale w czym zapis/salon/sprzedasz

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-14, 18:49


Barcioo

Kiedyś to było ST






Wiek: 26
Na forum: 4048 dni
Posty: 458
Nick w MP: Bartek.

Piwa: 1887

Respekt: 460
Respekt: 460

Salon_s

Podpis
Kanał Youtube;
A tu zapraszam
, pomogłem Ci? Wynagrodź mnie :piwo: :)


SUPPORT TEAM- 2016-09-03 do 2018-05-25
Test Mod- 2018-05-25
1k dni na Forum - 2018-01-28


GG: 62111935
Postaw piwo autorowi tego posta
 

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


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

ok lukne

[ Dodano: 2016-04-14, 19:17 ]
To co mi si? dzieje pisze jakie? Sf TAB daje .
ss; http://imgur.com/onAlnUs

[ Dodano: 2016-04-14, 19:20 ]

local salonowePojazdy = {}
--wzorsalonowePojazdy[id_pojazdu] = cena
salonowePojazdy[404] = 1000 --perek
salonowePojazdy[410] = 1450 --manana
salonowePojazdy[418] = 1550 --Moonbeam
salonowePojazdy[600] = 10222 --Picador
salonowePojazdy[543] = 2750 --Sadler
salonowePojazdy[478] = 2400 --Walton
salonowePojazdy[549] = 12000 --Tampa
salonowePojazdy[540] = 3500 --Vincent
salonowePojazdy[527] = 5800 --Cadrona
salonowePojazdy[547] = 9500 --Primo
salonowePojazdy[526] = 24000 --Fortune
salonowePojazdy[492] = 23000 --Greenwood
salonowePojazdy[517] = 11000 --Majestic
salonowePojazdy[405] = 19490 --Sentinel
salonowePojazdy[400] = 14250 --Landstalker
salonowePojazdy[500] = 25222 --Mesa
salonowePojazdy[542] = 9000 --Clover
-- Od 10K
salonowePojazdy[555] = 13899 --Windsor
salonowePojazdy[561] = 19856 --Stratum
salonowePojazdy[533] = 22900 --Feltzer
salonowePojazdy[579] = 19234 --Huntley
salonowePojazdy[495] = 64934 --Sandking
salonowePojazdy[475] = 19000 --Primo
salonowePojazdy[426] = 12000 --Premier
salonowePojazdy[566] = 14000 --Tahoma
salonowePojazdy[576] = 20899 --Torando
salonowePojazdy[562] = 200000 --Elegy
salonowePojazdy[536] = 20455 --Blade
salonowePojazdy[439] = 17890 --Stallion
salonowePojazdy[567] = 31233 --Savanna
salonowePojazdy[534] = 28000 --Remington
salonowePojazdy[535] = 37900 --Slamvan
salonowePojazdy[575] = 25989 --Broadway
salonowePojazdy[580] = 15600 --Stafford
salonowePojazdy[474] = 35750 --Hermes

--SPORTOWE

salonowePojazdy[496] = 16430 --Blista Compact
salonowePojazdy[565] = 155450 --Flash
salonowePojazdy[603] = 356900 --Phoenix
salonowePojazdy[415] = 68999 --Cheetah
salonowePojazdy[558] = 68991 --Uranus
salonowePojazdy[506] = 155000 --Super GT
salonowePojazdy[602] = 60439 --Alpha
salonowePojazdy[429] = 240000 --Banshee
salonowePojazdy[402] = 30234 --Buffalo
salonowePojazdy[587] = 45000 --Euros
salonowePojazdy[541] = 145000 --Bullet
salonowePojazdy[559] = 85000 --Jester
salonowePojazdy[451] = 750000 --Turismo
salonowePojazdy[477] = 99000 --ZR-350
--Od 1 MLN
salonowePojazdy[411] = 950000 --Infernus
salonowePojazdy[434] = 89000 --Hotknife
salonowePojazdy[545] = 27000 --Hustler

--Motory

salonowePojazdy[462] = 9000 --Faggio
salonowePojazdy[461] = 25000 --PCJ-600
salonowePojazdy[581] = 35000 --BF-400
salonowePojazdy[521] = 19899 --FCR900
salonowePojazdy[463] = 104500 --Freeway
salonowePojazdy[586] = 100000 --Wayfarer
salonowePojazdy[571] = 23000 --Quad
salonowePojazdy[522] = 234520 --NRG-500


local salon createMarker(-1957.99,300.52,35.47-0.9"cylinder"1000100)

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 >= 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"70) --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,ids) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?,?)"wlascicielididsxyzrotrgb500)
                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)
                local ids getElementData(veh"car_id")
                setVehiclePlateText(veh"SF   "..ids)
                warpPedIntoVehicle(sourceveh)
                end15001source)
            else
            outputChatBox("Mo?esz posiada? maksymalnie 500 pojazd?w."source255255255true)
            end
          end
        else
        outputChatBox("Potrzebujesz "..cena.."$ 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 ("Admin")) 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,ids) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?,?)"wlascicielididsxyzrotrgb500)
                    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"stworzPojazd

M?j kod czy co? w nim nie tak

Postaw piwo autorowi tego posta
 

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


Rade







Wiek: 32
Na forum: 4115 dni
Posty: 32

Piwa: 3

Respekt: 50

co do tego "TAB" nie masz kolumny stworzonej w bazie zapis?w

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-15, 19:03


Retrok







Wiek: 27
Na forum: 3734 dni
Posty: 58
Nick w MP: Retrok

Piwa: 4

Respekt: 50


--[[
Ten plik zawiera:
    * liste pojazdow i ich cene
    marker salonu
    funkcje kupujaca pojazd z salonu
--]]

local salonowePojazdy = {}
--wzorsalonowePojazdy[id_pojazdu] = cena
salonowePojazdy[404] = 1500 --perek
salonowePojazdy[410] = 1750 --manana
salonowePojazdy[418] = 2040 --Moonbeam
salonowePojazdy[600] = 2500 --Picador
salonowePojazdy[543] = 2750 --Sadler
salonowePojazdy[478] = 2980 --Walton
salonowePojazdy[549] = 3441 --Tampa
salonowePojazdy[540] = 3944 --Vincent
salonowePojazdy[527] = 4500 --Cadrona
salonowePojazdy[547] = 5000 --Primo
salonowePojazdy[526] = 5320 --Fortune
salonowePojazdy[492] = 5780 --Greenwood
salonowePojazdy[517] = 6452 --Majestic
salonowePojazdy[405] = 7500 --Sentinel
salonowePojazdy[400] = 8120 --Landstalker
salonowePojazdy[500] = 8992 --Mesa
salonowePojazdy[542] = 9750 --Clover
-- Od 10K
salonowePojazdy[555] = 13899 --Windsor
salonowePojazdy[561] = 14500 --Stratum
salonowePojazdy[533] = 15210 --Feltzer
salonowePojazdy[579] = 19234 --Huntley
salonowePojazdy[495] = 23400 --Sandking
salonowePojazdy[475] = 24000 --Primo
salonowePojazdy[426] = 5800 --Premier
salonowePojazdy[566] = 26615 --Tahoma
salonowePojazdy[576] = 27899 --Torando
salonowePojazdy[562] = 27912 --Elegy
salonowePojazdy[536] = 29455 --Blade
salonowePojazdy[439] = 30222 --Stallion
salonowePojazdy[567] = 31233 --Savanna
salonowePojazdy[534] = 32000 --Remington
salonowePojazdy[535] = 35415 --Slamvan
salonowePojazdy[575] = 36989 --Broadway
salonowePojazdy[580] = 39450 --Stafford
salonowePojazdy[474] = 45750 --Hermes

--SPORTOWE

salonowePojazdy[496] = 50140 --Blista Compact
salonowePojazdy[565] = 55400 --Flash
salonowePojazdy[603] = 61200 --Phoenix
salonowePojazdy[415] = 65188 --Cheetah
salonowePojazdy[558] = 68991 --Uranus
salonowePojazdy[506] = 72344 --Super GT
salonowePojazdy[602] = 73455 --Alpha
salonowePojazdy[429] = 78112 --Banshee
salonowePojazdy[402] = 81234 --Buffalo
salonowePojazdy[587] = 82347 --Euros
salonowePojazdy[541] = 89400 --Bullet
salonowePojazdy[559] = 90001 --Jester
salonowePojazdy[451] = 95800 --Turismo
salonowePojazdy[477] = 99900 --ZR-350
--Od 1 MLN
salonowePojazdy[411] = 101233 --Infernus
salonowePojazdy[434] = 123444 --Hotknife
salonowePojazdy[545] = 145000 --Hustler

--Motory

salonowePojazdy[462] = 1000 --Faggio
salonowePojazdy[461] = 3400 --PCJ-600
salonowePojazdy[581] = 8500 --BF-400
salonowePojazdy[521] = 9899 --FCR900
salonowePojazdy[463] = 14500 --Freeway
salonowePojazdy[586] = 25000 --Wayfarer
salonowePojazdy[571] = 23000 --Quad
salonowePojazdy[522] = 34520 --NRG-500


local salon createMarker(-1957.99,300.52,35.47-0.9"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 >= 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)
                setVehiclePlateText(veh,"LS "..last_insert_id)
                end15001source)
            else
            outputChatBox("Mo?esz posiada? maksymalnie 5 pojazd?w."source255255255true)
            end
          end
        else
        outputChatBox("Potrzebujesz "..cena.."$ 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 ("Admin")) 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)
                    setVehiclePlateText(veh,"LS "..last_insert_id)
                    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)




--[[
Ten plik zawiera:
    * tworzenie aut przy uruchomieniu skryptu
    laczenie sie z baza SQL Lite
    zapis danych aut co 15 min i przy wylaczeniu skryptu
    komende dla administratora sluzaca zapisowi aut
    funkcje blokujaca wejscie do auta jesli nie jestesmy jego wlascicieleme
--]]


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"])
    setVehiclePlateText(veh,"LS "..v["id"])
    
    --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(zapiszPojazdy9000000)

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


[ Dodano: 2016-04-15, 19:15 ]
Cut//pomagamy tylko na forum //emm

Ostatnio zmieniony przez Emm 2016-04-17, 23:20, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-17, 23:05


Byl3mTu

nikt taki






Wiek: 24
Na forum: 4087 dni
Posty: 40
Nick w MP: BylemTu

Piwa: 36

Respekt: 50

Ja osobi?cie zrobi?em tak:
Kod:

function ustawDanePojazdu(veh, id, wlasciciel) --id = INT, wlasciciel = STRING
setElementData(veh, "car_id", id)
setVehiclePlateText(veh, "LS, "..id.."")
setElementData(veh, "car_owner", wlasciciel)
end


Postaw piwo autorowi tego posta
 

 
Tagi: znowu :: tablica :: (id :: zapis)
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