--[[
Komisy samochodowe
@author value <value2k@gmail.com>
@Edit: DylemaT929 :)
Nie masz prawa u?y? tego kodu bez mojej zgody
]]
createBlip(2159.99, -1796.78, 13.36, 55,2,0,0,0,0,0,275) --- ls motory
createBlip(2928.03, -797.16, 11.53, 55,2,0,0,0,0,0,275) --- ls sportowy
createBlip(2126.78, -1130.25, 25.52, 55,2,0,0,0,0,0,275) --- ls terenowe
createBlip(-79.37, -1575.67, 2.61, 55,2,0,0,0,0,0,275) --- ls cygan
createBlip(1605.93, -2174.90, 13.59, 55,2,0,0,0,0,0,275)
createBlip(-72.90, -1130.97, 1.12, 55,2,0,0,0,0,0,275)
local vehicles = {}
local komis_shapes = {}
local slots = {
-- Doherty Diesel
{ 1581.42, -2170.19, 13.37, 244.8, model=401, dmax=0, dmin=0, price=math.random(2000000,2100000), sell=10, gdzie="dohertysf"}, -- Bravura
{ 1581.68, -2179.74, 13.36, 296.4, model=436, dmax=0, dmin=0, price=math.random(1500000,1700000), sell=10, gdzie="dohertysf"}, -- Previon
{ 1594.50, -2170.10, 13.21, 153.1, model=565, dmax=0, dmin=0, price=math.random(22300000,24500000), sell=10, gdzie="dohertysf"}, -- flash
{ 1603.38, -2170.91, 13.39, 151.6, model=475, dmax=0, dmin=0, price=math.random(5300000,5700000), sell=10, gdzie="dohertysf"}, -- Szabla
{ 1621.03, -2164.36, 13.42, 146.0, model=402, dmax=0, dmin=0, price=math.random(2400000,2500000), sell=10, gdzie="dohertysf"}, -- Mg?awica
{ 1613.63, -2163.72, 13.44, 155.4, model=517, dmax=0, dmin=0, price=math.random(2100000,2200000), sell=10, gdzie="dohertysf"}, -- majestic
{ 1630.04, -2179.85, 13.35, 41.9, model=526, dmax=0, dmin=0, price=math.random(4100000,4200000), sell=10, gdzie="dohertysf"}, -- Fortuna
{ 1622.80, -2180.90, 13.22, 36.6, model=529, dmax=0, dmin=0, price=math.random(6900000,7000000), sell=10, gdzie="dohertysf"}, -- Williard
{ 1627.87, -2164.06, 13.30, 141.6, model=600, dmax=0, dmin=0, price=math.random(1200000,1300000), sell=10, gdzie="dohertysf"}, -- Picador
{ 1615.47, -2179.99, 13.33, 32.6, model=426, dmax=0, dmin=0, price=math.random(7500000,7600000), sell=10, gdzie="dohertysf"}, -- Premier
{ 1615.01, -2150.09, 13.94, 182.6, model=495, dmax=0, dmin=0, price=math.random(4100000,4200000), sell=10, gdzie="dohertysf"}, -- Sanking
{ 1608.54, -2180.53, 13.39, 49.6, model=602, dmax=0, dmin=0, price=math.random(15500000,15600000), sell=10, gdzie="dohertysf"}, -- Alpha
-- Doherty Indlewood
{ 2187.74, -1805.18, 12.94, 0.1, model=522, dmax=0, dmin=0, price=math.random(31000000,32000000), sell=10, gdzie="sf"}, -- NRG-500
{ 2181.77, -1805.30, 12.95, 2.9, model=461, dmax=0, dmin=0, price=math.random(17000000,17000000), sell=10, gdzie="sf"}, -- PCJ-600
{ 2175.15, -1805.85, 12.94, 2.6, model=521, dmax=0, dmin=0, price=math.random(20000000,21000000), sell=10, gdzie="sf"}, -- FCR-900
{ 2163.73, -1805.86, 13.04, 359.6, model=468, dmax=0, dmin=0, price=math.random(15523900,16152410), sell=10, gdzie="sf"}, -- Sanchez
{ 2169.24, -1806.11, 12.97, 0.4, model=581, dmax=0, dmin=0, price=math.random(12890000,13893000), sell=10, gdzie="sf"}, -- Bf-400
{ 2157.95, -1806.16, 12.90, 4.4, model=586, dmax=0, dmin=0, price=math.random(26000000,27972000), sell=10, gdzie="sf"}, -- Wayfarer
-- Cygan LPG
{-101.63, -1586.67, 2.27, 277.4, model=410, dmax=99343, dmin=97323, price=math.random(321000,322000), sell=10, gdzie="cygan"}, -- manana
{-82.04, -1551.39, 2.49, 177.3, model=458, dmax=99343, dmin=97323, price=math.random(390000,400000), sell=10, gdzie="cygan"}, -- Solair
{-59.55, -1552.62, 2.70, 120.5, model=418, dmax=100343, dmin=97323, price=math.random(150000,150000), sell=10, gdzie="cygan"}, -- Moonbeam
{-52.18, -1576.54, 2.48, 27.9, model=543, dmax=101343, dmin=97000, price=math.random(520000,521000), sell=10, gdzie="cygan"}, -- Sadler
{-96.20, -1594.92, 2.61, 277.3, model=478, dmax=111343, dmin=107333, price=math.random(112000,113000), sell=10, gdzie="cygan"}, -- walton
{-78.70, -1601.48, 2.35, 278.8, model=404, dmax=118343, dmin=116333, price=math.random(600000,601000), sell=10, gdzie="cygan"}, -- perek
-- Salon Downtown SF Benzyna
{2958.58, -783.87, 11.57, 137.6, model=480, dmax=0, dmin=0, price=math.random(27000000,28000000), sell=10, gdzie="sf"}, -- Comet
{2966.33, -784.14, 11.50, 148.8, model=506, dmax=0, dmin=0, price=math.random(30000000,31000000), sell=10, gdzie="unikat"}, -- sgt
{2945.67, -803.61, 11.45, 147.4, model=559, dmax=0, dmin=0, price=math.random(32000000,33000000), sell=10, gdzie="sf"}, -- jester
{2973.12, -832.80, 11.50, 63.9, model=560, dmax=0, dmin=0, price=math.random(58000000,59000000), sell=10, gdzie="unikat"}, -- Su?tan
{-1676.95, 1207.07, 13.31,253, model=587, dmax=0, dmin=0, price=math.random(24000000,25111111), sell=10, gdzie="sf"}, -- euros
{2975.18, -783.90, 11.57, 146.0, model=415, dmax=0, dmin=0, price=math.random(70000000,71000000), sell=10, gdzie="sf"}, --chetah
{2954.17, -804.13, 11.48, 145.5, model=429, dmax=0, dmin=0, price=math.random(39000000,40000000), sell=10, gdzie="sf"}, -- Bansheee
{2945.96, -833.31, 11.46, 289.7, model=562, dmax=0, dmin=0, price=math.random(47000000,48000000), sell=10, gdzie="sf"}, -- Elegy
{2948.24, -783.78, 11.61, 140.4, model=545, dmax=0, dmin=0, price=math.random(62000000,63000000), sell=10, gdzie="sf"}, -- Hustler
-- Salon Jefferson
{ 2136.00, -1129.77, 25.51, 52.7, model=567, dmax=0, dmin=0, price=math.random(31000000,32000000), sell=10, gdzie="dohertysf"}, -- Savanna
{ 2135.74, -1136.02, 25.28, 50.8, model=576, dmax=0, dmin=0, price=math.random(32750000,34000000), sell=10, gdzie="dohertysf"}, -- Tornado
{ 2136.03, -1142.62, 24.86, 48.7, model=419, dmax=0, dmin=0, price=math.random(40000000,41000000), sell=10, gdzie="dohertysf"}, -- Esperanto
{ 2118.77, -1130.13, 25.00, 314.7, model=533, dmax=0, dmin=0, price=math.random(34000000,35000000), sell=10, gdzie="dohertysf"}, -- Feltzer
{ 2118.64, -1136.73, 24.85, 309.5, model=518, dmax=0, dmin=0, price=math.random(36999999,37500000), sell=10, gdzie="dohertysf"}, -- Buccaneer
{ 2118.47, -1143.27, 24.50, 310.6, model=467, dmax=0, dmin=0, price=math.random(33500000,34200000), sell=10, gdzie="dohertysf"}, -- Oceanic
-- Salon Doherty SF
{ -1946.31, 265.16, 35.18, 42.4, model=411, dmax=0, dmin=0, price=math.random(75000000,76000000), sell=10, gdzie="unikat3"}, -- infek
{ -1950.23, 258.69, 35.07, 27.0, model=541, dmax=0, dmin=0, price=math.random(64000000,65000000), sell=10, gdzie="unikat3"}, -- turek
{ -1956.85, 259.07, 35.12, 349.2, model=451, dmax=0, dmin=0, price=math.random(55000000,56000000), sell=10, gdzie="unikat3"}, -- bullet
-- Salon ci??arowy LS
{ -30.03, -1123.27, 1.27, 129.5, model=456, dmax=0, dmin=0, price=math.random(6400000,6600000), sell=10, gdzie="dohertysf"}, -- yankee
{ -37.12, -1119.02, 1.19, 130.5, model=414, dmax=0, dmin=0, price=math.random(5200000,5400000), sell=10, gdzie="dohertysf"}, -- mule
{ -42.92, -1116.22, 1.19, 131.5, model=413, dmax=0, dmin=0, price=math.random(3500000,3600000), sell=10, gdzie="dohertysf"}, -- pony
{ -49.41, -1114.03, 1.24, 135.7, model=482, dmax=0, dmin=0, price=math.random(3500000,3600000), sell=10, gdzie="dohertysf"}, -- burrito
{ -57.62, -1144.76, 1.56, 15.6, model=455, dmax=0, dmin=0, price=math.random(11200000,11400000), sell=10, gdzie="dohertysf"}, -- Flatbed
{ -66.51, -1143.57, 1.19, 10.7, model=609, dmax=0, dmin=0, price=math.random(5200000,8400000), sell=10, gdzie="dohertysf"}, -- Black Boxville
{ -75.82, -1108.10, 2.14, 183.6, model=515, dmax=0, dmin=0, price=math.random(13200000,13400000), sell=10, gdzie="dohertysf"}, -- Roadtrain
{ -60.37, -1112.50, 1.71, 130.7, model=514, dmax=0, dmin=0, price=math.random(14200000,14300000), sell=10, gdzie="dohertysf"}, -- tanker
{ -39.87, -1141.18, 1.68, 65.1, model=450, dmax=0, dmin=0, price=math.random(8200000,9300000), sell=10, gdzie="dohertysf"}, -- przyczepa
{ -42.60, -1147.60, 1.68, 66.0, model=591, dmax=0, dmin=0, price=math.random(8200000,9300000), sell=10, gdzie="dohertysf"}, -- przyczepa2
-- Salon ariport
{ 1880.39, -2262.34, 14.23, 320.4, model=487, dmax=0, dmin=0, price=math.random(88000000,89000000), sell=10, gdzie="unikat3"}, -- Maverick
{ 1861.67, -2262.35, 14.07, 320.8, model=469, dmax=0, dmin=0, price=math.random(86000000,87000000), sell=10, gdzie="unikat3"}, -- sparrow
{ 1860.83, -2237.27, 14.52, 233.1, model=593, dmax=0, dmin=0, price=math.random(85000000,87000000), sell=10, gdzie="unikat3"}, -- dodo
{ 1881.23, -2237.80, 14.60, 140.3, model=513, dmax=0, dmin=0, price=math.random(86000000,87000000), sell=10, gdzie="unikat3"}, -- dodo
}
addEventHandler("onResourceStart", resourceRoot, function ()
for i,v in ipairs(slots) do
komis_shapes[i] = createColSphere(v[1], v[2], v[3], 3)
setElementData(komis_shapes[i], "i", i)
createKomisVehicle(i)
addEventHandler("onColShapeHit", komis_shapes[i], function (hit,dim)
if getElementType(hit) == "player" and getElementData(komis_shapes[i], "komis:veh") then
triggerClientEvent(hit, "onClientAddNotification", hit,"Zainteresowa? ci? ten pojazd? /kuppojazd")
end
end)
end
end)
addCommandHandler("kuppojazd", function (plr, cmd)
local shape = isPlayerInVehicleColShape(plr)
if not shape then return end
local veh = getElementData(shape, "komis:veh")
if not veh then return end
local slot = getElementData(shape, "komis:slot")
local s = vehicles[slot].sell
local price = vehicles[slot].price
local money = getPlayerMoney(plr)
if price > money then
if price > s-1 then
triggerClientEvent(plr, "onClientAddNotification", plr,"* Nie sta? ci? na kupno tego pojazdu. Id? zar?b na pracach dorywczych i wr?c p??niej!")
else
triggerClientEvent(plr, "onClientAddNotification", plr,"* Nie ma ju? dost?pnych aut. Wr?c p??niej!")
return
end
end
takePlayerMoney(plr, price, s-1)
local x,y,z = getElementPosition(veh)
local rx,ry,rz = getElementRotation(veh)
local i = getElementInterior(veh)
local d = getElementDimension(veh)
local pos = x..", "..y..", "..z..", "..rx..", "..ry..", "..rz..", "..i..", "..d
local r1,g1,b1, r2,g2,b2, r3,g3,b3, r4,g4,b4 = getVehicleColor(veh, true)
local color = r1..", "..g1..", "..b1..", "..r2..", "..g2..", "..b2
local owner = getElementData(plr, "player:uid")
local model = getElementModel(veh)
local dist = vehicles[slot].mileage
local poj = vehicles[slot].poj
local rodzaj = vehicles[slot].rodzaj
local gdzie = vehicles[slot].gdzie
destroyElement(veh)
setElementData(shape, "komis:veh", false)
setElementData(shape, "salonowe", false)
local q, num, id = exports["tiyl-db"]:dbGet("INSERT INTO tiyl_pojazdy SET pos=?, fuel=15, gas=25, bak=100, mileage=?, ownedPlayer=?, parking=1, pojemnosc=?, rodzaj=?, color=?, model=?", pos, dist, owner, poj, rodzaj, color, model)
if q then
createKomisVehicle(slot)
triggerClientEvent(plr, "onClientAddNotification", plr,"Gratulacje! Zakupi?e? sw?j pierwszy lub kolejny pojazd na serwerze! Pojazd zosta? przeniesiony do przechowywalni")
setElementData(plr, "vehicle:desc", false)
setElementData(plr, "vehicle:mileage", vehicles[slot].mileage)
setElementData(plr, "vehicle:rodzaj", vehicles[slot].rodzaj)
setElementData(plr, "vehicle:poj", vehicles[slot].poj2)
setElementData(plr, "komis:slot", vehicles[slot].sell-1)
else
triggerClientEvent(plr, "onClientAddNotification", plr," Wyst?pi? problem z kupnem pojazdu! Zg?o? to administracji serwera!")
end
end)
function createKomisVehicle(slot)
if #getElementsWithinColShape(komis_shapes[slot]) > 0 then setTimer(createKomisVehicle, 250, 1, slot) return end
vehicles[slot] = {}
vehicles[slot].mileage = math.random(slots[slot].dmin, slots[slot].dmax)
vehicles[slot].price = slots[slot].price
vehicles[slot].sell = slots[slot].sell
vehicles[slot].veh = createVehicle(slots[slot].model, slots[slot][1], slots[slot][2], slots[slot][3], 0, 0, slots[slot][4], slots[slot][5])
setElementFrozen(vehicles[slot].veh, true)
setVehicleDamageProof(vehicles[slot].veh, true)
setVehicleLocked(vehicles[slot].veh, true)
setElementData(komis_shapes[slot], "komis:veh", vehicles[slot].veh)
setElementData(komis_shapes[slot], "komis:slot", vehicles[slot].sell)
setElementData(vehicles[slot].veh, "komis:veh", true)
setElementData(vehicles[slot].veh, "salonowe", true)
setVehicleOverrideLights ( vehicles[slot].veh, 2 )
setVehicleColor(vehicles[slot].veh, math.random(0,255),math.random(0,255),math.random(0,255))
setVehicleHeadLightColor(vehicles[slot].veh, 255, 55, 0)
if slots[slot].gdzie == "dohertysf" then
vehicles[slot].rodzaj = "Diesel"
vehicles[slot].poj = math.random(3,4)
vehicles[slot].gdzie = "dohertysf"
elseif slots[slot].gdzie == "dohertysf2" then
vehicles[slot].rodzaj = "Diesel"
vehicles[slot].poj = math.random(4,5)
vehicles[slot].gdzie = "dohertysf2"
elseif slots[slot].gdzie == "cygan" then
vehicles[slot].rodzaj = "LPG"
vehicles[slot].poj = math.random(1,2)
vehicles[slot].gdzie = "cygan"
elseif slots[slot].gdzie == "sf" then
vehicles[slot].rodzaj = "Benzyna"
vehicles[slot].poj = math.random(5,6)
vehicles[slot].gdzie = "unikat"
elseif slots[slot].gdzie == "unikat" then
vehicles[slot].rodzaj = "Benzyna"
vehicles[slot].poj = math.random(7,8)
vehicles[slot].gdzie = "unikat"
elseif slots[slot].gdzie == "unikat2" then
vehicles[slot].rodzaj = "Benzyna"
vehicles[slot].poj = math.random(9,10)
vehicles[slot].gdzie = "unikat2"
elseif slots[slot].gdzie == "unikat3" then
vehicles[slot].rodzaj = "Benzyna"
vehicles[slot].poj = math.random(11,12)
vehicles[slot].gdzie = "unikat3"
end
if vehicles[slot].poj == 1 then
vehicles[slot].poj2 = 1.2
elseif vehicles[slot].poj == 2 then
vehicles[slot].poj2 = 1.6
elseif vehicles[slot].poj == 3 then
vehicles[slot].poj2 = 1.8
elseif vehicles[slot].poj == 4 then
vehicles[slot].poj2 = 2.0
elseif vehicles[slot].poj == 5 then
vehicles[slot].poj2 = 2.2
elseif vehicles[slot].poj == 6 then
vehicles[slot].poj2 = 2.5
elseif vehicles[slot].poj == 7 then
vehicles[slot].poj2 = 2.6
elseif vehicles[slot].poj == 8 then
vehicles[slot].poj2 = 2.7
elseif vehicles[slot].poj == 9 then
vehicles[slot].poj2 = 2.8
elseif vehicles[slot].poj == 10 then
vehicles[slot].poj2 = 2.9
elseif vehicles[slot].poj == 11 then
vehicles[slot].poj2 = 3.0
elseif vehicles[slot].poj == 12 then
vehicles[slot].poj2 = 3.1
end
setElementData(vehicles[slot].veh, "vehicle:desc", "---------\nPojazd: "..getVehicleName(vehicles[slot].veh).."\nKoszt: "..slots[slot].price.." PLN\nPrzebieg: "..vehicles[slot].mileage.." km\nPojemno?? Silnika: "..vehicles[slot].poj2.." cm3\nRodzaj paliwa: "..vehicles[slot].rodzaj.."\nPojemno?? Baku: 100 L\nDost?pne Sztuki: "..vehicles[slot].sell.."\nZainteresowa? ci? ten pojazd? /kuppojazd\n---------")
end
function isPlayerInVehicleColShape(player)
for i,v in ipairs(komis_shapes) do
if isElementWithinColShape(player, v) then return v end
end
return false
end