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

Wysłany: 2016-02-15, 18:52


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Witam, mam pytanie - jak zrobi?, by na li?cie pojazd?w przy sprzeda?y, opr?cz modelu wy?wietla?o si? te? ID? System pojazd?w by PanPrezes, tutaj fragment kodu (my?l?, ?e to ten :) ).

guiSetVisible(guig[7], true)
    for i,v in pairs(pojazdy) do
    local row guiGridListAddRow(guig[9])
    guiGridListSetItemText(guig[9], rowguig[10], getVehicleNameFromModel(v["model"]), falsefalse)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 19:46


Fanciak

BOT






Wiek: 25
Na forum: 4446 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500

ID pojazdu w GTA, tak?


Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleID


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 19:48


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Nie, ID pojazdu jako, hmmm, kt?ry to pojazd na serwerze :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 19:51


_Wicek_

Majstersztyk






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

Piwa: 1841

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

Ostrzeżeń: 40%
getElementData(v,"car:id")


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 20:32


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Stworzy?em now? kolumn?:
guig[19] = guiGridListAddColumn(guig[9], "ID"0.3)

I doda?em takie co?:
guiGridListSetItemText(guig[9], rowguig[19], getElementData(v,"car:id"), falsefalse)


Kolumna jest, ID nie wy?wietla :/ Jakie? pomys?y? :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 20:37


_Wicek_

Majstersztyk






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

Piwa: 1841

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

Ostrzeżeń: 40%
Przepraszam , m?j b?ad :/ (ka?demu si? zdarza :) )

getElementData(v,"car_id")


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 20:44


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Poprawi?em, jednak nadal brak ID w kolumnie :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 20:46


_Wicek_

Majstersztyk






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

Piwa: 1841

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

Ostrzeżeń: 40%
M?glby? podes?a? tutaj ca?y kod ? , bo ci??ko si? pracuje na kawa?eczku :)

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 20:50


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Ca?ego systemu pojazd?w chyba nie ma sensu, podam 2 pliki ze sprzeda?? :)

C:
local sXsY guiGetScreenSize()

function createGUIGielda()
    if not guig then
    guig = {}
    guig[1] = guiCreateWindow((sX 350)/2, (sY 360)/2350360"Sprzeda? pojazdu"false)
    guig[2] = guiCreateLabel(102333040"Wybierz z listy graczy, kt?rzy znajduj? si? w makerze tego, komu chcesz sprzeda? pojazd."falseguig[1])
    guiLabelSetHorizontalAlign(guig[2], "center"true)
    guig[3] = guiCreateGridList(1060330250falseguig[1])
    guig[4] = guiGridListAddColumn(guig[3], "Gracze"0.9)
    guig[5] = guiCreateButton(103208030"Zamknij"falseguig[1])
    guig[6] = guiCreateButton(2603208030"Dalej"falseguig[1])
    
    addEventHandler("onClientGUIClick"guig[5], onSprzedazClickZamknijfalse)
    addEventHandler("onClientGUIClick"guig[6], onSprzedazClickGraczeDalejfalse)
    
    --wybieranie pojazdu
    guig[7] = guiCreateWindow((sX 350)/2, (sY 360)/2350360"Sprzeda? pojazdu"false)
    guig[8] = guiCreateLabel(102333040"Z listy pojazd?w wybierz pojazd, kt?ry chcesz sprzeda?"falseguig[7])
    guiLabelSetHorizontalAlign(guig[8], "center"true)
    guig[9] = guiCreateGridList(1060330250falseguig[7])
    guig[10] = guiGridListAddColumn(guig[9], "Twoje pojazdy"0.6)
        guig[19] = guiGridListAddColumn(guig[9], "ID"0.3)
    guig[11] = guiCreateButton(103208030"Zamknij"falseguig[7])
    guig[12] = guiCreateButton(2603208030"Dalej"falseguig[7])
    
    addEventHandler("onClientGUIClick"guig[11], onSprzedazClickZamknijfalse)
    addEventHandler("onClientGUIClick"guig[12], onSprzedazClickPojazdyDalejfalse)
    
    --cena
    guig[13] = guiCreateWindow((sX 280)/2, (sY 190)/2280190"Sprzeda? pojazdu"false)
    guig[14] = guiCreateLabel(102326040"Wpisz cen? pojazdu, za kt?r? chcesz sprzeda? Tw?j pojazd."falseguig[13])
    guiLabelSetHorizontalAlign(guig[14], "center"true)
    guig[15] = guiCreateLabel(15753020"Cena:"falseguig[13])
    guig[16] = guiCreateEdit(527112030""falseguig[13])
    guig[17] = guiCreateButton(101508030"Zamknij"falseguig[13])
    guig[18] = guiCreateButton(1901508030"Sprzedaj"falseguig[13])
    
    addEventHandler("onClientGUIClick"guig[17], onSprzedazClickZamknijfalse)
    addEventHandler("onClientGUIClick"guig[18], onSprzedazClickSprzedajfalse)
    end
guiSetVisible(guig[1], false)
guiSetVisible(guig[7], false)
guiSetVisible(guig[13], false)
guiGridListClear(guig[3])
guiGridListClear(guig[9])
guiSetText(guig[16], "")
showCursor(true)
end

addEvent("pokazGUISprzedazy"true)
addEventHandler("pokazGUISprzedazy"getRootElement(),
function(players)
createGUIGielda()
guiSetVisible(guig[1], true)
    for i,v in pairs(players) do
        --if ~= localPlayer then
        local row guiGridListAddRow(guig[3])
        guiGridListSetItemText(guig[3], rowguig[4], getPlayerName(v), falsefalse)
        guiGridListSetItemData(guig[3], rowguig[4], v)
        --end
    end
end)

function onSprzedazClickZamknij()
savePLAYER nil
saveVEHICLE nil

guiSetVisible(guig[1], false)
guiSetVisible(guig[7], false)
guiSetVisible(guig[13], false)
showCursor(false)
end

function onSprzedazClickGraczeDalej()
local rowcolumn guiGridListGetSelectedItem(guig[3])
    if row ~= -1 then
    local player guiGridListGetItemData(guig[3], rowguig[4])
        if player then
        savePLAYER player
        triggerServerEvent("pobierzListePojazdow"localPlayerid)
        end
    end
end

--<< pojazdy >>--

addEvent("pokazListePojazdow"true)
addEventHandler("pokazListePojazdow"getRootElement(),
function(pojazdy)
guiSetVisible(guig[1], false)
guiSetVisible(guig[7], true)
    for i,v in pairs(pojazdy) do
    local row guiGridListAddRow(guig[9])
    guiGridListSetItemText(guig[9], rowguig[10], getVehicleNameFromModel(v["model"]), falsefalse)
        guiGridListSetItemText(guig[9], rowguig[19], getElementData(v,"car_id"), falsefalse)
    guiGridListSetItemData(guig[9], rowguig[10], v["id"])
    end
end)

function onSprzedazClickPojazdyDalej()
local rowcolumn guiGridListGetSelectedItem(guig[9])
    if row ~= -1 then
    local id guiGridListGetItemData(guig[9], rowguig[10])
        if id then
        saveVEHICLE id
        
        guiSetVisible(guig[7], false)
        guiSetVisible(guig[13], true)
        guiSetText(guig[16], "")
        end
    end
end

--<< cena
function onSprzedazClickSprzedaj()
local cena guiGetText(guig[16])
    if #cena >= 1 then
    local cena tonumber(cena)
        if type(cena) == "number" then
            if cena >= 1 then
                showCursor(false)
                guiSetVisible(guig[13], false)
                --
                triggerServerEvent("zaproponujKupnoPojazdu"localPlayersavePLAYERsaveVEHICLEcena)
            else
                outputChatBox("> Podana cena jest nieprawid?owa."25500true)
            end
        else
            outputChatBox("> Wpisz cen?, za jak? chcesz sprzeda? sw?j pojazd."25500true)
        end
    end
end


--######## OFERTA KUPNA #########
function createGUIKupnoUzywanego()
    if not guiku then
    guiku = {}
    
    guiku[1] = guiCreateWindow((sX 300)/2, (sY 150)/2300150"Oferta kupna pojazdu"false)
    guiku[2] = guiCreateLabel(102528060"Gracz <nick> zaproponowa? Ci kupno pojazdu prywatnego <nazwa> o przebiegu <przebieg> km za <cena> z?."falseguiku[1])
    guiLabelSetHorizontalAlign(guiku[2], "center"true)
    guiku[3] = guiCreateButton(101108030"Odrzu?"falseguiku[1])
    guiku[4] = guiCreateButton(2101108030"Kup"falseguiku[1])
    
    addEventHandler("onClientGUIClick"guiku[3], onOfertaKupnaOdrzucfalse)
    addEventHandler("onClientGUIClick"guiku[4], onOfertaKupnaKupfalse)
    end
guiSetVisible(guiku[1], true)
showCursor(true)
end

addEvent("pokazOferteKupnaPojazdu"true)
addEventHandler("pokazOferteKupnaPojazdu"getRootElement(),
function(gracznazwacenaprzebieg)
createGUIKupnoUzywanego()
guiSetText(guiku[2], "Gracz "..getPlayerName(gracz).." zaproponowa? Ci kupno pojazdu prywatnego "..nazwa.." o przebiegu "..przebieg.." km za "..cena.." z?.")
end)

function onOfertaKupnaZamknij()
guiSetVisible(guiku[1], false)
showCursor(false)
end

function onOfertaKupnaOdrzuc()
onOfertaKupnaZamknij()
triggerServerEvent("odrzucOferteKupna"localPlayer)
end

function onOfertaKupnaKup()
onOfertaKupnaZamknij()
triggerServerEvent("przyjmijOferteKupna"localPlayer)
end



S:
local sprzedaz createMarker(-2029.64,-121.91,34.3"cylinder"225500100)

function onSprzedazHit(hitElementdim)
    if getElementType(hitElement) == "player" then
    local players getElementsInMarker(sprzedaz)
    triggerClientEvent(hitElement"pokazGUISprzedazy"rootplayers)
    end
end
addEventHandler("onMarkerHit"sprzedazonSprzedazHit)

function getElementsInMarker(marker)
elements = {}
    for i,v in pairs(getElementsByType("player")) do
        if isElementWithinMarker(vmarkerthen
        table.insert(elementsv)
        end
    end
return elements
end

addEvent("pobierzListePojazdow"true)
addEventHandler("pobierzListePojazdow"getRootElement(), 
function()
local account getPlayerAccount(source)
    if account then
    local wlasciciel getAccountName(account)
    local query dbQuery(handler"SELECT * FROM pojazdy WHERE wlasciciel='"..wlasciciel.."'")
    local resultnum_rowserrormsg dbPoll (query, -1)
    triggerClientEvent(source"pokazListePojazdow"rootresult)
    end
end)

ofertyKupna = {}

addEvent("zaproponujKupnoPojazdu"true)
addEventHandler("zaproponujKupnoPojazdu"getRootElement(),
function(graczidcena)
    if not ofertyKupna[graczthen
    ofertyKupna[gracz] = {}
    ofertyKupna[gracz] = {graczsourceidcena}
    
    local query dbQuery(handler"SELECT model,przebieg FROM pojazdy WHERE id='"..id.."'")
    local resultnum_rowserrormsg dbPoll (query, -1)
    local pojazd result[1].model
    local pojazd getVehicleNameFromModel(pojazd)
    local przebieg result[1].przebieg
    triggerClientEvent(gracz"pokazOferteKupnaPojazdu"rootsourcepojazdcenaprzebieg)
    else
    outputChatBox("> Ten gracz ma w tym momencie otwart? inn? ofert? kupna pojazdu."source25500true)
    end
end)

addEvent("odrzucOferteKupna"true)
addEventHandler("odrzucOferteKupna"getRootElement(),
function()
    if ofertyKupna[sourcethen
    local od_kogo_oferta ofertyKupna[source][2]
        if isElement(od_kogo_ofertathen
        outputChatBox("> Gracz "..getPlayerName(source).." odrzuci? Twoj? ofert? kupna pojazdu."od_kogo_oferta25500true)
        end
    ofertyKupna[source] = nil
    end
end)

addEvent("przyjmijOferteKupna"true)
addEventHandler("przyjmijOferteKupna"getRootElement(),
function()
    if ofertyKupna[sourcethen
    local account getPlayerAccount(source)
      if account then
      local login getAccountName(account)
        if 999 >= getYourVehicleCount(loginthen
        local od_kogo_oferta ofertyKupna[source][2]
        local veh ofertyKupna[source][3] --id pojazdu
        local cena ofertyKupna[source][4]
            if isElement(od_kogo_ofertathen
            local cena tonumber(cena)
                if getPlayerMoney(source) >= cena then
                takePlayerMoney(sourcecena)
                givePlayerMoney(od_kogo_ofertacena)
                --nadpisanie danych
                local vehicle getVehicleByID(veh)
                ustawDanePojazdu(vehiclevehlogin)
                dbExec(handler"UPDATE pojazdy SET wlasciciel='"..login.."' WHERE id="..veh.."")
                --chat
                local pojazd getVehicleName(vehicle)
                outputChatBox("> Gracz "..getPlayerName(source).." przyj?? Twoj? ofert? i kupi? Tw?j pojazd: "..pojazd.." za: "..cena.." z?."od_kogo_oferta02550true)
                outputChatBox("> Kupi?e? pojazd: "..pojazd.." za: "..cena.." z?, od gracza: "..getPlayerName(od_kogo_oferta).."."source02550true)
                else
                outputChatBox("> Gracz "..getPlayerName(source).." nie ma wystarczaj?co pieni?dzy, aby kupi? Tw?j pojazd."od_kogo_oferta25500true)
                outputChatBox("> Nie masz wystarczaj?co pieni?dzy, aby kupi? ten pojazd."source25500true)
                end
            else
            outputChatBox("> Gracza, kt?ry sk?ada? Ci ofert?, nie ma ju? na serwerze."source25500true)
            end
        else
        outputChatBox("> Mo?esz posiada? maksymalnie 999 pojazd?w."source25500true)
        end
      else
      outputChatBox("> Nie jeste? zalogowany."source25500true)
      end
    else
    outputChatBox("> Wyst?pi? b??d, nie mo?esz teraz kupi? pojazdu."source2550true)
    end
ofertyKupna[source] = nil
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 20:53


_Wicek_

Majstersztyk






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

Piwa: 1841

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

Ostrzeżeń: 40%
To powinno dzia?a?

v["id"]


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 21:04


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Kolumna nadal pusta, nie wiem, co mo?e by? przyczyn? :(

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 21:49


Wittx

8===D






Wiek: 26
Na forum: 4794 dni
Posty: 121
Nick w MP: wittula

Piwa: 1905

Respekt: 120
Respekt: 120

guiGridListSetItemText(guig[9], rowguig[10], getVehicleNameFromModel(v["model"]), falsefalse)


Funkcja getVehicleNameFromModel() potrzebuje modelu, ?eby zwr?ci? nazw?. Podstawy angielskiego. Logiczne jest wtedy, ?e v["model"] to model pojazdu. :) Nie rozumiem dlaczego bawicie si? w jakie? element data czy funkcje.

Daj to razem z umieszczaniem nazwy pojazdu (bo przecie? stworzy?e? kolumn? ID):
guiGridListSetItemText(guig[9], rowguig[19], v["model"], falsefalse)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-15, 22:25


_Wicek_

Majstersztyk






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

Piwa: 1841

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

Ostrzeżeń: 40%
Wittx, Koledze chodzi o ID pojazdu w grze np 4

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-16, 00:41


Wittx

8===D






Wiek: 26
Na forum: 4794 dni
Posty: 121
Nick w MP: wittula

Piwa: 1905

Respekt: 120
Respekt: 120

"Wicek7" napisał/a:

Wittx, Koledze chodzi o ID pojazdu w grze np 4


Przepraszam, ?le zrozumia?em. :)

Przejrza?em kod i...:
local veh ofertyKupna[source][3] --id pojazdu

(...)
--nadpisanie danych
local vehicle getVehicleByID(veh)
ustawDanePojazdu(vehiclevehlogin)


Jak wida? autor doda? przy deklaracji zmiennej veh komentarz, z kt?rego wynika, ?e w tej zmiennej przechowywane jest ID pojazdu. Jak p??niej widzimy pojazd jest pobierany przez ID funkcj? getVehicleByID(), gdzie tym ID jest w?a?nie zmienna veh. Taka funkcja domy?lnie nie istnieje w MTA, wi?c oczywiste, ?e zosta?a stworzona przez autora.

"andrzej80" napisał/a:

Ca?ego systemu pojazd?w chyba nie ma sensu, podam 2 pliki ze sprzeda?? :)

Chyba jednak b?dzie sens - trzeba znale?? funkcj? (lub spos?b przypisania ID do pojazdu w celu stworzenia w?asnej) kt?ra jest odpowiedzialna za pobieranie ID z danego pojazdu. Mo?e jest gdzie? w kodzie i nie zauwa?y?em - nie wiem, za du?o tam "syfu". Na pewno b?dzie to strona serwera.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-16, 09:17


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

No to inne pliki ze strony servera:

salon_s: (pomin??em tabel? z pojazdami w salonie)
local salon createMarker(-1952.65,305.72,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 999 >= getYourVehicleCount(wlascicielthen
            takePlayerMoney(sourcecena)
            triggerClientEvent(source"potwierdzKupnoPojazduPrywatnego"root)
            fadeCamera(sourcefalse)
                setTimer(function(source)
                local xyzrot = -1925.51244.274190
                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 999 pojazd?w."source255255255true)
            end
          end
        else
        outputChatBox("> Potrzebujesz "..cena.." z?, aby 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)
                    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)


zapis_aut_s:
--zapis autlaczenie z baza sqlzapis co 15 min komenda /zapiszblokada wejscia i thv

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"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 jeste? w?a?cicielem tego pojazdu."player25500true)
        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"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 ***"player0255255true)
    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

addCommandHandler("thv", function(plrcmdvid)
    local login getAccountName getPlayerAccount plr ) )
     if isObjectInACLGroup ("user."..loginaclGetGroup "Admin" ) ) then
    if not tonumber(vidthen return end
    for i,v in ipairs(getElementsByType("vehicle")) do
    if getElementData(v"car_id") == tonumber(vidthen
                local x,y,getElementPosition(plr)
                setElementFrozen(vfalse)
                warpPedIntoVehicle(plrv)
                setElementPosition(vx,y,z)
                setElementInterior(vgetElementInterior(plr))
                setElementDimension(vgetElementDimension(plr))
                return
            end
          end
         end
         outputChatBox("> Nie masz praw do tej komendy lub nie znaleziono auta o takim ID!"plr25500)
    end)


To + te wy?ej to wszystko ze strony serwera.

Postaw piwo autorowi tego posta
 

 
Tagi: przy :: modelu
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