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 ).
Ca?ego systemu pojazd?w chyba nie ma sensu, podam 2 pliki ze sprzeda??
C:
local sX, sY = guiGetScreenSize()
function createGUIGielda()
if not guig then
guig = {}
guig[1] = guiCreateWindow((sX - 350)/2, (sY - 360)/2, 350, 360, "Sprzeda? pojazdu", false)
guig[2] = guiCreateLabel(10, 23, 330, 40, "Wybierz z listy graczy, kt?rzy znajduj? si? w makerze tego, komu chcesz sprzeda? pojazd.", false, guig[1])
guiLabelSetHorizontalAlign(guig[2], "center", true)
guig[3] = guiCreateGridList(10, 60, 330, 250, false, guig[1])
guig[4] = guiGridListAddColumn(guig[3], "Gracze", 0.9)
guig[5] = guiCreateButton(10, 320, 80, 30, "Zamknij", false, guig[1])
guig[6] = guiCreateButton(260, 320, 80, 30, "Dalej", false, guig[1])
addEventHandler("onClientGUIClick", guig[5], onSprzedazClickZamknij, false)
addEventHandler("onClientGUIClick", guig[6], onSprzedazClickGraczeDalej, false)
--wybieranie pojazdu
guig[7] = guiCreateWindow((sX - 350)/2, (sY - 360)/2, 350, 360, "Sprzeda? pojazdu", false)
guig[8] = guiCreateLabel(10, 23, 330, 40, "Z listy pojazd?w wybierz pojazd, kt?ry chcesz sprzeda?", false, guig[7])
guiLabelSetHorizontalAlign(guig[8], "center", true)
guig[9] = guiCreateGridList(10, 60, 330, 250, false, guig[7])
guig[10] = guiGridListAddColumn(guig[9], "Twoje pojazdy", 0.6)
guig[19] = guiGridListAddColumn(guig[9], "ID", 0.3)
guig[11] = guiCreateButton(10, 320, 80, 30, "Zamknij", false, guig[7])
guig[12] = guiCreateButton(260, 320, 80, 30, "Dalej", false, guig[7])
addEventHandler("onClientGUIClick", guig[11], onSprzedazClickZamknij, false)
addEventHandler("onClientGUIClick", guig[12], onSprzedazClickPojazdyDalej, false)
--cena
guig[13] = guiCreateWindow((sX - 280)/2, (sY - 190)/2, 280, 190, "Sprzeda? pojazdu", false)
guig[14] = guiCreateLabel(10, 23, 260, 40, "Wpisz cen? pojazdu, za kt?r? chcesz sprzeda? Tw?j pojazd.", false, guig[13])
guiLabelSetHorizontalAlign(guig[14], "center", true)
guig[15] = guiCreateLabel(15, 75, 30, 20, "Cena:", false, guig[13])
guig[16] = guiCreateEdit(52, 71, 120, 30, "", false, guig[13])
guig[17] = guiCreateButton(10, 150, 80, 30, "Zamknij", false, guig[13])
guig[18] = guiCreateButton(190, 150, 80, 30, "Sprzedaj", false, guig[13])
addEventHandler("onClientGUIClick", guig[17], onSprzedazClickZamknij, false)
addEventHandler("onClientGUIClick", guig[18], onSprzedazClickSprzedaj, false)
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 v ~= localPlayer then
local row = guiGridListAddRow(guig[3])
guiGridListSetItemText(guig[3], row, guig[4], getPlayerName(v), false, false)
guiGridListSetItemData(guig[3], row, guig[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 row, column = guiGridListGetSelectedItem(guig[3])
if row ~= -1 then
local player = guiGridListGetItemData(guig[3], row, guig[4])
if player then
savePLAYER = player
triggerServerEvent("pobierzListePojazdow", localPlayer, id)
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], row, guig[10], getVehicleNameFromModel(v["model"]), false, false)
guiGridListSetItemText(guig[9], row, guig[19], getElementData(v,"car_id"), false, false)
guiGridListSetItemData(guig[9], row, guig[10], v["id"])
end
end)
function onSprzedazClickPojazdyDalej()
local row, column = guiGridListGetSelectedItem(guig[9])
if row ~= -1 then
local id = guiGridListGetItemData(guig[9], row, guig[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", localPlayer, savePLAYER, saveVEHICLE, cena)
else
outputChatBox("> Podana cena jest nieprawid?owa.", 255, 0, 0, true)
end
else
outputChatBox("> Wpisz cen?, za jak? chcesz sprzeda? sw?j pojazd.", 255, 0, 0, true)
end
end
end
--######## OFERTA KUPNA #########
function createGUIKupnoUzywanego()
if not guiku then
guiku = {}
guiku[1] = guiCreateWindow((sX - 300)/2, (sY - 150)/2, 300, 150, "Oferta kupna pojazdu", false)
guiku[2] = guiCreateLabel(10, 25, 280, 60, "Gracz <nick> zaproponowa? Ci kupno pojazdu prywatnego <nazwa> o przebiegu <przebieg> km za <cena> z?.", false, guiku[1])
guiLabelSetHorizontalAlign(guiku[2], "center", true)
guiku[3] = guiCreateButton(10, 110, 80, 30, "Odrzu?", false, guiku[1])
guiku[4] = guiCreateButton(210, 110, 80, 30, "Kup", false, guiku[1])
addEventHandler("onClientGUIClick", guiku[3], onOfertaKupnaOdrzuc, false)
addEventHandler("onClientGUIClick", guiku[4], onOfertaKupnaKup, false)
end
guiSetVisible(guiku[1], true)
showCursor(true)
end
addEvent("pokazOferteKupnaPojazdu", true)
addEventHandler("pokazOferteKupnaPojazdu", getRootElement(),
function(gracz, nazwa, cena, przebieg)
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", 2, 255, 0, 0, 100)
function onSprzedazHit(hitElement, dim)
if getElementType(hitElement) == "player" then
local players = getElementsInMarker(sprzedaz)
triggerClientEvent(hitElement, "pokazGUISprzedazy", root, players)
end
end
addEventHandler("onMarkerHit", sprzedaz, onSprzedazHit)
function getElementsInMarker(marker)
elements = {}
for i,v in pairs(getElementsByType("player")) do
if isElementWithinMarker(v, marker) then
table.insert(elements, v)
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 result, num_rows, errormsg = dbPoll (query, -1)
triggerClientEvent(source, "pokazListePojazdow", root, result)
end
end)
ofertyKupna = {}
addEvent("zaproponujKupnoPojazdu", true)
addEventHandler("zaproponujKupnoPojazdu", getRootElement(),
function(gracz, id, cena)
if not ofertyKupna[gracz] then
ofertyKupna[gracz] = {}
ofertyKupna[gracz] = {gracz, source, id, cena}
local query = dbQuery(handler, "SELECT model,przebieg FROM pojazdy WHERE id='"..id.."'")
local result, num_rows, errormsg = dbPoll (query, -1)
local pojazd = result[1].model
local pojazd = getVehicleNameFromModel(pojazd)
local przebieg = result[1].przebieg
triggerClientEvent(gracz, "pokazOferteKupnaPojazdu", root, source, pojazd, cena, przebieg)
else
outputChatBox("> Ten gracz ma w tym momencie otwart? inn? ofert? kupna pojazdu.", source, 255, 0, 0, true)
end
end)
addEvent("odrzucOferteKupna", true)
addEventHandler("odrzucOferteKupna", getRootElement(),
function()
if ofertyKupna[source] then
local od_kogo_oferta = ofertyKupna[source][2]
if isElement(od_kogo_oferta) then
outputChatBox("> Gracz "..getPlayerName(source).." odrzuci? Twoj? ofert? kupna pojazdu.", od_kogo_oferta, 255, 0, 0, true)
end
ofertyKupna[source] = nil
end
end)
addEvent("przyjmijOferteKupna", true)
addEventHandler("przyjmijOferteKupna", getRootElement(),
function()
if ofertyKupna[source] then
local account = getPlayerAccount(source)
if account then
local login = getAccountName(account)
if 999 >= getYourVehicleCount(login) then
local od_kogo_oferta = ofertyKupna[source][2]
local veh = ofertyKupna[source][3] --id pojazdu
local cena = ofertyKupna[source][4]
if isElement(od_kogo_oferta) then
local cena = tonumber(cena)
if getPlayerMoney(source) >= cena then
takePlayerMoney(source, cena)
givePlayerMoney(od_kogo_oferta, cena)
--nadpisanie danych
local vehicle = getVehicleByID(veh)
ustawDanePojazdu(vehicle, veh, login)
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_oferta, 0, 255, 0, true)
outputChatBox("> Kupi?e? pojazd: "..pojazd.." za: "..cena.." z?, od gracza: "..getPlayerName(od_kogo_oferta)..".", source, 0, 255, 0, true)
else
outputChatBox("> Gracz "..getPlayerName(source).." nie ma wystarczaj?co pieni?dzy, aby kupi? Tw?j pojazd.", od_kogo_oferta, 255, 0, 0, true)
outputChatBox("> Nie masz wystarczaj?co pieni?dzy, aby kupi? ten pojazd.", source, 255, 0, 0, true)
end
else
outputChatBox("> Gracza, kt?ry sk?ada? Ci ofert?, nie ma ju? na serwerze.", source, 255, 0, 0, true)
end
else
outputChatBox("> Mo?esz posiada? maksymalnie 999 pojazd?w.", source, 255, 0, 0, true)
end
else
outputChatBox("> Nie jeste? zalogowany.", source, 255, 0, 0, true)
end
else
outputChatBox("> Wyst?pi? b??d, nie mo?esz teraz kupi? pojazdu.", source, 255, 0 , 0, true)
end
ofertyKupna[source] = nil
end)
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):
--nadpisanie danych
local vehicle = getVehicleByID(veh)
ustawDanePojazdu(vehicle, veh, login)
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.
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.
local salon = createMarker(-1952.65,305.72,35.47-0.9, "cylinder", 1, 255, 0, 0, 100)
function onSalonHit(hitElement, dim)
if getElementType(hitElement) == "player" then
triggerClientEvent(hitElement, "pokazGUISalonu", root, salonowePojazdy)
end
end
addEventHandler("onMarkerHit", salon, onSalonHit)
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(wlasciciel) then
takePlayerMoney(source, cena)
triggerClientEvent(source, "potwierdzKupnoPojazduPrywatnego", root)
fadeCamera(source, false)
setTimer(function(source)
local x, y, z, rot = -1925.51, 244.27, 41, 90
local veh = createVehicle(id, x, y, z)
setElementData(veh, "pojazd_paliwo", 50) --na specjalna prosbe ;)
setElementData(veh, "pojazd_przebieg", 0)
local r, g, b = getVehicleColor(veh, true)
fadeCamera(source, true)
--<<-->>
local query = dbQuery(handler, "INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)", wlasciciel, id, x, y, z, rot, r, g, b, 50, 0)
local result, num_affected_rows, last_insert_id = dbPoll(query, -1)
local r, g, b = getVehicleHeadLightColor(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", r, g, b)
--<<-->>
setElementRotation(veh, 0, 0, rot)
ustawDanePojazdu(veh, last_insert_id, wlasciciel)
warpPedIntoVehicle(source, veh)
end, 1500, 1, source)
else
outputChatBox("> Mo?esz posiada? maksymalnie 999 pojazd?w.", source, 255, 255, 255, true)
end
end
else
outputChatBox("> Potrzebujesz "..cena.." z?, aby kupi? ten pojazd.", source, 255, 255, 255, true)
end
end
end)
--komenda tworzaca
function stworzPojazdCMD(player, cmd, id, wlasciciel)
local acc = getAccountName (getPlayerAccount(player))
if acc then
if isObjectInACLGroup ("user."..acc, aclGetGroup ("Admin")) then
if id and wlasciciel then
local id = tonumber(id)
if id then
if getVehicleNameFromModel(id) then
local x, y, z = getElementPosition(player)
local _, _, rot = getElementRotation(player)
local veh = createVehicle(id, x, y, z)
if veh then
setElementData(veh, "pojazd_paliwo", 50) --na specjalna prosbe ;)
setElementData(veh, "pojazd_przebieg", 0)
local r, g, b = getVehicleColor(veh, true)
--<<-->>
local query = dbQuery(handler, "INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)", wlasciciel, id, x, y, z, rot, r, g, b, 50, 0)
local result, num_affected_rows, last_insert_id = dbPoll(query, -1)
local r, g, b = getVehicleHeadLightColor(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", r, g, b)
--<<-->>
setElementRotation(veh, 0, 0, rot)
ustawDanePojazdu(veh, last_insert_id, wlasciciel)
else
outputChatBox("> Podane ID jest niepoprawne.", player, 255, 255, 255, true)
end
else
outputChatBox("> Podane ID jest niepoprawne.", player, 255, 255, 255, true)
end
end
else
outputChatBox("> Wpisz /stworz <id-pojazdu> <wlasciciel>", player, 255, 255, 255, true)
end
end
end
end
addCommandHandler("stworz", stworzPojazdCMD)
zapis_aut_s:
--zapis aut, laczenie z baza sql, zapis co 15 min , komenda /zapisz, blokada 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 result, num_rows, errormsg = dbPoll (query, -1)
for i,v in pairs(result) do
local veh = createVehicle(v["model"], v["x"], v["y"], v["z"])
setElementRotation(veh, 0, 0, v["rot"])
setVehicleColor(veh, v["ca"], v["cb"], v["cc"])
ustawDanePojazdu(veh, v["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 result, num_rows, errormsg = dbPoll (query, -1)
setVehiclePaintjob(veh, result[1].paintjob)
setVehicleHeadLightColor(veh, result[1].hr, result[1].hg, result[1].hb)
for i,v in pairs(result) do
for ii, vv 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(veh, vv)
end
end
end
end
end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartLoadVehicles)
function ustawDanePojazdu(veh, id, wlasciciel) --id = INT, wlasciciel = STRING
setElementData(veh, "car_id", id)
setElementData(veh, "car_owner", wlasciciel)
end
function onVehicleStartEnter(player, seat, jacked)
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.", player, 255, 0, 0, true)
cancelEvent()
end
end
end
end
addEventHandler ("onVehicleStartEnter", resourceRoot, onVehicleStartEnter)
--<<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 x, y, z = getElementPosition(v)
local _, _, rot = getElementRotation(v)
local color1, color2, color3, color4 = getVehicleColor(v, true)
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 r, g, b = getVehicleHeadLightColor(v)
sav = {}
for i=0, 16 do
local upgrade = getVehicleUpgradeOnSlot(v, i)
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(zapiszPojazdy, 900000, 0)
function zapiszKomenda(player)
local acc = getAccountName (getPlayerAccount(player))
if isObjectInACLGroup ("user."..acc, aclGetGroup ("Admin")) then
zapiszPojazdy()
outputChatBox("*** Zapisano pojazdy ***", player, 0, 255, 255, true)
end
end
addCommandHandler("zapiszpojazdy", zapiszKomenda)
-- mapa, f11
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", root, vehs)
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(tab, v)
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(plr, cmd, vid)
local login = getAccountName ( getPlayerAccount ( plr ) )
if isObjectInACLGroup ("user."..login, aclGetGroup ( "Admin" ) ) then
if not tonumber(vid) then return end
for i,v in ipairs(getElementsByType("vehicle")) do
if getElementData(v, "car_id") == tonumber(vid) then
local x,y,z = getElementPosition(plr)
setElementFrozen(v, false)
warpPedIntoVehicle(plr, v)
setElementPosition(v, x,y,z)
setElementInterior(v, getElementInterior(plr))
setElementDimension(v, getElementDimension(plr))
return
end
end
end
outputChatBox("> Nie masz praw do tej komendy lub nie znaleziono auta o takim ID!", plr, 255, 0, 0)
end)
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