--[[
Ten plik zawiera:
* liste pojazdow i ich cene
* marker salonu
* funkcje kupujaca pojazd z salonu
--]]
local salonowePojazdyR = {}
--wzor: salonowePojazdy[id_pojazdu] = cena
salonowePojazdyR[404] = 650.00 -- Perennial
salonowePojazdyR[418] = 550.00 --Moonebeam
salonowePojazdyR[410] = 955.00 --Manana
local salonR = createMarker(1653.96,-1655.73,22.52-1, "cylinder", 2, 125, 125, 125, 100)
local salonRb = createBlip(1653.96,-1655.73,22.52, 55)
local weText = createElement("ogrpg-3dtext")
setElementPosition(weText, 1653.96,-1655.73,22.52)
setElementData(weText, "text", "Salon pojazd?w")
function onSalonHitR(hitElement, dim)
if getElementType(hitElement) == "player" then
triggerClientEvent(hitElement, "pokazGUIRumun", root, salonowePojazdyR)
end
end
addEventHandler("onMarkerHit", salonR, onSalonHitR)
addEvent("kupPojazdRumun", true)
addEventHandler("kupPojazdRumun", getRootElement(),
function(id)
local cena = salonowePojazdyR[id]
if cena then
if getPlayerMoney(source) >= cena then
local account = getPlayerAccount(source)
if account then
local wlasciciel = getAccountName(account)
if 3 >= getYourVehicleCount(wlasciciel) then
takePlayerMoney(source, cena)
triggerClientEvent(source, "potwierdzKupnoPojazduPrywatnegoR", root)
fadeCamera(source, false)
setTimer(function(source)
local x, y, z, rot = 1650.73,-1719.56,20.21,0.4,1.3,359.4
local veh = createVehicle(id, x, y, z)
local rotX, rotY, rotZ = getElementRotation(localPlayer) -- get the local players's rotation
setElementRotation(veh, 0.0,0.0,90.1,"default",true) -- turn the player 10 degrees clockwise
setElementInterior(veh, 0)
setElementInterior(source, 0)
setVehicleHandling(veh,"maxVelocity", 110.00) -- 70 + 10 = 80km/h
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)
outputChatBox("Pami?taj o zatankowaniu swojego pojazdu gdy? Tw?j pojazd nie ma za du?o paliwa",source, 255, 255, 255)
setElementData(veh, "pojazdy_paliwo",math.random(4,36))
setElementData(veh, "pojazdy_przebieg",math.random(0, 0))
end, 1500, 1, source)
else
exports["POL-notyfikacje"]:addNotification(source, "Nie mo?esz mie? wiecej pojazd?w niz 3.")
end
end
else
exports["POL-notyfikacje"]:addNotification(source, "Nie posiadasz pieni?dzy na ten samoch?d.")
end
end
end)
i
- local screenW, screenH = guiGetScreenSize()
local sw,sh=guiGetScreenSize()
function createGUIRumun()
if not guisR then
guisR = {}
guisR[1] = guiCreateWindow(149/640*sw, 102/480*sh, 367/640*sw, 209/480*sh, "Salon", false)
guiWindowSetSizable(guisR[1], false)
guisR[2] = guiCreateGridList(9/640*sw, 22/480*sh, 220/640*sw, 177/480*sh, false, guisR[1])
guisR[3] = guiGridListAddColumn(guisR[2], "Model", 0.5)
guisR[4] = guiGridListAddColumn(guisR[2], "Cena", 0.5)
guiSetFont(guisR[1], "default-bold-small")
guisR[5] = guiCreateButton(239/640*sw, 126/480*sh, 114/640*sw, 54/480*sh, "Zamknij", false, guisR[1])
guisR[6] = guiCreateButton(239/640*sw, 50/480*sh, 114/640*sw, 54/480*sh, "Zakup", false, guisR[1])
addEventHandler("onClientGUIClick", guisR[5], onSalonClickZamknijRumun, false)
addEventHandler("onClientGUIClick", guisR[6], onSalonClickKupRumun, false)
end
guiGridListClear(guisR[2])
guiSetVisible(guisR[1], true)
showCursor(true)
end
addEvent("pokazGUIRumun", true)
addEventHandler("pokazGUIRumun", getRootElement(),
function(pojazdy)
createGUIRumun()
for i,v in pairs(pojazdy) do
local name = getVehicleNameFromModel(i)
if name then --istnieje taki pojazd
local row = guiGridListAddRow(guisR[2])
guiGridListSetItemText(guisR[2], row, guisR[3], getVehicleNameFromModel(i), false, false)
guiGridListSetItemText(guisR[2], row, guisR[4], v.." PLN", false, false)
guiGridListSetItemData(guisR[2], row, guisR[3], i)
end
end
end)
function onSalonClickZamknijRumun()
guiSetVisible(guisR[1], false)
showCursor(false)
end
function onSalonClickKupRumun()
local row, column = guiGridListGetSelectedItem(guisR[2])
if row ~= -1 then
local id = guiGridListGetItemData(guisR[2], row, guisR[3])
if id then
triggerServerEvent("kupPojazdRumun", localPlayer, id)
guiSetVisible( guisR[1], false)
showCursor(false)
end
end
end
addEvent("potwierdzKupnoPojazduPrywatnegoRumun", true)
addEventHandler("potwierdzKupnoPojazduPrywatnegoRumun", getRootElement(),
function()
onSalonClickZamknijRumun()
end)
i
local sX, sY = guiGetScreenSize()
function createGUIGielda()
if not guig then
guig = {}
guig[1] = guiCreateWindow((sX - 607) / 2, (sY - 344) / 2, 607, 344, "Sprzeda? pojazd?w", false)
guig[2] = guiCreateLabel(110, 24, 487, 29, "Wybierz z listy Gracza ktoremy chcesz sprzedac pojazd \n Gracz ktoremu sprzedajemy pojazd musi wejsc pierwszy w marker.", false, guig[1])
guiSetFont(guig[2], "default-bold-small")
guig[3] = guiCreateGridList(9, 63, 588, 212, false, guig[1])
guig[4] = guiGridListAddColumn(guig[3], "Gracze:", 0.9)
guig[5] = guiCreateButton(12, 281, 223, 53, "Zamknij", false, guig[1])
guig[6] = guiCreateButton(374, 281, 223, 53, "Dalej", false, guig[1])
addEventHandler("onClientGUIClick", guig[5], onSprzedazClickZamknij, false)
addEventHandler("onClientGUIClick", guig[6], onSprzedazClickGraczeDalej, false)
--wybieranie pojazdu
guig[7] = guiCreateWindow((sX - 607) / 2, (sY - 344) / 2, 607, 344, "Sprzeda? pojazd?w", false)
guig[8] = guiCreateLabel(174, 24, 487, 29, "Wybierz z listy pojazd ktory chcesz sprzedac.", false, guig[7])
guiSetFont(guig[8], "default-bold-small")
guig[9] = guiCreateGridList(9, 63, 588, 212, false, guig[7])
guig[10] = guiGridListAddColumn(guig[9], "Twoje pojazdy:", 0.9)
guig[11] = guiCreateButton(12, 281, 223, 53, "Zamknij", false, guig[7])
guig[12] = guiCreateButton(374, 281, 223, 53, "Dalej", false, guig[7])
addEventHandler("onClientGUIClick", guig[11], onSprzedazClickZamknij, false)
addEventHandler("onClientGUIClick", guig[12], onSprzedazClickPojazdyDalej, false)
--cena
guig[13] = guiCreateWindow((sX - 607) / 2, (sY - 344) / 2, 607, 344, "Sprzeda? pojazd?w", false)
guig[14] = guiCreateLabel(161, 29, 487, 29, "Wpisz w pole cene, za kt?r? sprzeda? sw?j pojazd.", false, guig[13])
guiSetFont(guig[14], "default-bold-small")
guig[211] = guiCreateLabel(204, 113, 244, 31, "Cene podajemy jednym ci?giem \ntzn. 12000 a nie 12.000", false, guig[13])
guiLabelSetColor(guig[211], 255, 0, 0)
guiSetFont(guig[211], "default-bold-small")
guig[15] = guiCreateLabel(68, 178, 57, 41, "Cena:", false, guig[13])
guig[16] = guiCreateEdit((607 - 192) / 2, (344 - 37) / 2, 192, 37, "", false, guig[13])
guig[17] = guiCreateButton(12, 281, 223, 53, "Zamknij", false, guig[13])
guig[18] = guiCreateButton(374, 281, 223, 53, "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)
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
showCursor(false)
guiSetVisible(guig[13], false)
--
triggerServerEvent("zaproponujKupnoPojazdu", localPlayer, savePLAYER, saveVEHICLE, cena)
else
outputChatBox("Wpisz cen? za jak? chcesz sprzeda? sw?j pojazd.", 255, 255, 255, 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, 100, "Gracz oferuje Ci kupno swojego prywatnego pojazdu.\n\nINFORMACJE DOTYCZ?CE OFERTY \nWY?WIETL? SI? NA CHACIE", false, guiku[1])
guiLabelSetHorizontalAlign(guiku[2], "center", true)
guiku[3] = guiCreateButton(10, 125, 80, 30, "Odrzu?", false, guiku[1])
guiku[4] = guiCreateButton(210, 125, 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()
end)
function onOfertaKupnaZamknij()
guiSetVisible(guiku[1], false)
showCursor(false)
end
function onOfertaKupnaOdrzuc()
onOfertaKupnaZamknij()
triggerServerEvent("odrzucOferteKupna", localPlayer)
end
function onOfertaKupnaKup()
onOfertaKupnaZamknij()
triggerServerEvent("przyjmijOferteKupna", localPlayer)
end
i - local sprzedaz = createMarker(1665.38,-1640.96,14.22-1.5, "cylinder", 2.5, 0, 115, 153, 100)
--local sprzedazmini = createMarker(1665.38,-1640.96,14.22-1, "cylinder", 0.8, 102, 51, 255, 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 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
outputChatBox("#FF9D00[#919191Informacja#FF9D00] Gracz "..getPlayerName(source).." #FF9D00zaproponowa? Ci kupno pojazdu prywatnego #fff000"..pojazd.." #ffffff #fff000ID ["..id.."] #ffffffza#FF9D00 "..cena.."$.", gracz, 255, 255, 255, true)
outputChatBox("#FF9D00[#919191Informacja#FF9D00] Zaproponowa?e? "..getPlayerName(gracz).." #FF9D00kupno pojazdu prywatnego #fff000"..pojazd.." #ffffff #fff000ID ["..id.."] #ffffffza#FF9D00 "..cena.."$.", source, 255, 255, 255, true)
triggerClientEvent(gracz, "pokazOferteKupnaPojazdu", root, source, pojazd, cena, przebieg)
else
outputChatBox("Ten gracz w tym momencie ma otwart? inn? ofert? kupna pojazdu...", source, 255, 255, 255, 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, 255, 255, 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 5 >= 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).." przyja? Twoj? ofert? i kupi? Tw?j pojazd "..pojazd.." za "..cena.."$.", od_kogo_oferta, 255, 255, 255, true)
outputChatBox("Kupi?e? pojazd "..pojazd.." za "..cena.."$ od gracza "..getPlayerName(od_kogo_oferta)..".", source, 255, 255, 255, true)
else
outputChatBox("Gracz "..getPlayerName(source).." nie ma wystarczaj?co pieni?dzy by kupi? Tw?j pojazd.", od_kogo_oferta, 255, 255, 255, true)
outputChatBox("Nie masz wystarczaj?co pieni?dzy by kupi? ten pojazd.", source, 255, 255, 255, true)
end
else
outputChatBox("Gracz kt?ry sk?ada? Ci ofert? nie jest ju? online na serwerze.", source, 255, 255, 255, true)
end
else
outputChatBox("Mo?esz posiada? maksymalnie 5 pojazd?w.", source, 255, 255, 255, true)
end
else
outputChatBox("Nie jeste? zalogowany.", source, 255, 255, 255, true)
end
else
outputChatBox("Wyst?pi? b??d, nie mo?esz teraz kupi? pojazdu :|", source, 255, 255 ,255, true)
end
ofertyKupna[source] = nil
end)