Facebook
From Kulegg, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 288
  1. --[[
  2.  
  3. local positionVehicles = {
  4.     -- nazwa, model, przebieg, cena, x,y,z,rx,ry,rz, sprzedaż
  5.     -- CYGAN
  6.       {'Tampa', 549, {66000,77000}, {15231,21435}, 1940.80, -1859.74, 13.56+0.1, -0.00, 0.00, 133.26, "1.6"},
  7.       {'Bobcat', 422, {66000,77000}, {7000,12000}, 1929.34, -1856.16, 13.56+0.1, -0.00, 0.00, 100.42, "1.4"},
  8.       {'Perennial', 404, {66000,77000}, {7000,12000}, 1915.24, -1856.87, 13.56+0.1, -0.00, 0.00, 232.33, "1.2"},
  9.       {'Sadler', 543, {66000,77000}, {9000,15000}, 1924.26, -1874.30, 13.55, -0.00, 0.00, 319.73, "1.4"},
  10.       {'Bravura', 401, {66000,77000}, {7000,12000}, 1939.26, -1873.41, 13.56+0.1, -0.00, 0.00, 26.64, "1.2"},
  11.     -- SALON LS (Motocykle_GLEN_PARK)
  12.       {'NRG-500', 522, {0,100}, {3100000,3685000}, 2129.66, -1132.95, 25.61, -0.00, 0.00, 40.79, "2.8"},
  13.       {'Quad', 471, {0,100}, {70000,80000}, 2135.96, -1128.76, 25.61, -0.00, 0.00, 124.76, "1.2"},
  14.       {'Faggio', 462, {0,100}, {10000,12000}, 2126.92, -1151.16, 24.06, -4.26, 9.88, 324.80, "1.2"},
  15.       {'Sanchez', 468, {0,100}, {310000,340000}, 2121.04, -1146.18, 24.51, -3.71, 10.13, 298.22, "1.6"},
  16.       {'PCJ-600', 461, {0,100}, {675000,720000}, 2120.95, -1141.82, 24.86, -0.44, 9.89, 267.02, "2.0"},
  17.       {'Wayfarer', 586, {0,100}, {529000,580000}, 2121.02, -1129.74, 25.39, -0.00, 0.00, 265.84, "1.6"},
  18.       {'FCR-900', 521, {0,100}, {920000,980000}, 2120.91, -1135.73, 25.27, -0.00, 0.00, 266.78, "2.2"},
  19.       {'Freeway', 463, {0,100}, {410000,474500}, 2119.64, -1125.89, 25.39, -0.00, 0.00, 211.56, "1.4"},
  20.       {'BF-400', 581, {0,100}, {580000,595000}, 2136.56, -1133.92, 25.70, -0.00, 0.00, 14.29, "2.0"},
  21.     -- SALON LS (NormalCars_OBOK_CEMENTARZA)
  22.       {'Bullet', 541, {0,100}, {15500000,17000000}, 892.63, -1182.54, 16.98, -0.00, 0.00, 224.76, "3.2"},
  23.       {'Admiral', 445, {0,100}, {1200000,1300000}, 905.80, -1183.49, 16.98, -0.00, 0.00, 140.59, "1.8"},
  24.       {'Stallion', 439, {0,100}, {785000,850000}, 902.59, -1196.49, 16.98, -0.00, 0.00, 55.79, "1.6"},
  25.       {'Feltzer', 533, {0,100}, {2120000,2340000}, 892.12, -1196.34, 16.98, -0.00, 0.00, 36.88, "2.0"},
  26.       {'Rancher', 489, {0,100}, {850000,1000000}, 871.21, -1191.54, 16.98, -0.00, 0.00, 244.26, "2.0"},
  27.       {'Jester', 559, {0,100}, {3200000,3600000}, 883.00, -1189.36, 16.58+0.3, -0.00, 0.00, 266.12, "2.4"},
  28.       {'Sandking', 495, {0,100}, {5130000,5600000}, 862.18, -1198.67, 16.58+0.3, -0.00, 0.00, 266.12, "2.0"},
  29.          -- SALON OBOK TUNE LS
  30.       {'Burrito', 482, {0,100}, {560000,590000}, 2100.93, -2093.09, 13.85, -0.00, 0.00, 302.51, "1.6"},
  31.       {'Patriot', 470, {0,100}, {3250000,3570000}, 2108.10, -2087.22, 13.55, -0.00, 0.00, 236.19, "2.4"},
  32.       {'Hermes', 474, {0,100}, {1580000,1630000}, 2121.31, -2088.08, 13.55, -0.00, 0.00, 232.20, "1.6"},
  33.       --{'Rancher', 489, {0,100}, {15000000,15000000}, 2130.14, -2081.51, 13.55, -0.00, 0.00, 222.95, "2.0"},
  34.       {'Oceanic', 467, {0,100}, {380000,422000}, 2140.55, -2080.67, 13.55, -0.00, 0.00, 144.52, "1.4"},
  35.       {'Previon', 436, {0,100}, {300000,350000}, 2141.03, -2092.82, 13.85, -0.00, 0.00, 61.31, "1.2"},
  36.         -- ROWERY
  37.       {'BMX', 481, {12000,12100}, {8000,10000}, 1917.62, -1414.07, 13.17, -0.00, 0.00, 78.06, "brak"},  --BMX NA SKATEPARK'u
  38.           {'Rower', 509, {12000,12100}, {3000,6500}, 1349.52, -1757.93, 13.11, -0.00, 0.00, 293.64, "brak"}, --- ROWER ZWYKLY w miescie jest
  39.           {'Rower Górski', 510, {12000,12100}, {10000,18000}, -2232.60, -1738.09, 480.84, -0.00, 0.00, 332.16, "brak"}, --ROWER GORSKI jest na MC
  40. }
  41. --]]
  42.  
  43. function init()
  44. local q=exports["ogrpg-db"]:dbSet("select * from iyw_salon")
  45. for i,v in ipairs(q) do
  46. local q2=exports["ogrpg-db"]:dbSet("select * from Rozpis_pojemnosci where model=?", v.model)
  47. loadveh(v,q2)
  48. end
  49. end
  50.  
  51. function initid(id)
  52. local q=exports["ogrpg-db"]:dbSet("select * from iyw_salon where id=?", id)
  53. for i,v in ipairs(q) do
  54. local q2=exports["ogrpg-db"]:dbSet("select * from Rozpis_pojemnosci where model=?", v.model)
  55. loadveh(v,q2)
  56. end
  57. end
  58.  
  59. --x,y,z,rx,ry,rz,dim,int
  60.  
  61. function loadveh(v,q)
  62.         if not q or #q < 1 then capacity="1.2" else capacity=q[1].capacity end
  63.         local pos=split(v.pos, ",")
  64.         local vehicle=Vehicle(v.model,pos[1],pos[2],pos[3],pos[4],pos[5],pos[6],"SALON")
  65.         vehicle.dimension = pos[7]
  66.         vehicle.interior = pos[8]
  67.         vehicle:setData("vehicle:for:sale", true)
  68.         vehicle.engineState = false
  69.         vehicle.overrideLights = 2
  70.         vehicle.damageProof = true
  71.         vehicle.frozen = true
  72.         vehicle.locked = true
  73.         vehicle:setData("salon:dbid", v.id)
  74.         exports["iyw_vehtexts"]:add3DTextForElement(vehicle,{0,0,0},vehicle.name.."\nPOJAZD NA SPRZEDAŻ!\n\nAby ujrzeć wszelkie informacje na temat\ntego pojazdu, podejdź bliżej.",{255,255,255,255},"czcionka4",1.0,30,1)
  75.         local cena; if type(v.koszt) == "table" then cena = (math.random(v.koszt[1], v.koszt[2])) else cena = v.koszt end
  76.         local przebieg; if type(v.przebieg) == "table" then przebieg = (math.random(v.przebieg[1], v.przebieg[2])) else przebieg = v.przebieg end
  77.         if v.model == 481 then
  78.         cuboid = ColShape.Cuboid(pos[1]-2.90, pos[2]-1.7, pos[3]-1.10, 6, 4, 5)
  79.         else
  80.         cuboid = ColShape.Cuboid(pos[1]-2.90, pos[2]-1.7, pos[3]-0.60, 6, 4, 5)
  81.         end
  82.         vehicle:setData("vehicle_mileage", przebieg)
  83.         cuboid:setData("cuboid:car_dealership", {
  84.                 ["veh"] = vehicle,
  85.                 ["vehicle"] = vehicle.model,
  86.                 ["vehicle_cost"] = tonumber(cena),
  87.                 ["vehicle_mileage"] = przebieg,
  88.                 ["vehicle_drivetype"] = getVehicleHandling(vehicle).driveType,
  89.                 ["vehicle_capacity"] = capacity
  90.         })
  91.         vehicle:setData("salon:cuboid", cuboid)
  92. end
  93.  
  94. addEvent("buyVehicle", true)
  95. addEventHandler("buyVehicle", resourceRoot, function(model, mileage, cost, capacity)
  96.         cost=tonumber(cost)
  97.         if model and mileage and cost then
  98.                 if cost <= client.money then           
  99.                         local uid = client:getData("player:uid")
  100.                         if not uid then return false end
  101.                        
  102.                         client:takeMoney(cost)
  103.                         triggerClientEvent(client, "onClientAddNotification", client, "Zakupiłeś(aś) pojazd prywatny, znajdziesz go w przechowalni pojazdów.", "success")
  104.                         exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model, ownedPlayer, firstowner, mileage, parking, capacity) VALUES (?,?,?,?,1,?)", model, uid, client.name, mileage, capacity)
  105.                 else
  106.                         triggerClientEvent(client, "onClientAddNotification", client, "Nie posiadasz wystarczajacej kwoty pieniędzy!\n(Brakuje Ci: "..string.format("%.02fPLN", cost-client.money)..")", "error")
  107.                 end
  108.         end
  109. end)
  110.  
  111. function salon(plr,cmd,arg1,arg2,arg3)
  112. if exports['dutyadmin']:getAdmin(plr,4) and plr:getData("player:uid") or plr:getData("player:uid") == 4 then
  113. if arg1 == "edytuj" then
  114.         if not arg2 or not tonumber(arg2) then
  115.                 plr:outputChat("Użycie: /salon edytuj <salon_dbid>", 255, 0, 0)
  116.                 return
  117.         end
  118.         local pojazdy=getElementsByType("vehicle", resourceRoot)
  119.         for i,v in ipairs(pojazdy) do
  120.         if tonumber(v:getData("salon:dbid")) == tonumber(arg2) then
  121.                 warpPedIntoVehicle(plr, v)
  122.                 v.frozen = false
  123.                 plr:outputChat("/salon (edytuj,stworz,usun,cena,model,przebieg,zapisz,rz)", 255, 0, 0)
  124.         end
  125.         end
  126. elseif arg1 == "stworz" then
  127.         if not arg2 or not tonumber(arg2) then
  128.                 plr:outputChat("Użycie: /salon stworz <model_id>", 255, 0, 0)
  129.                 return
  130.         end
  131.         local veh2=Vehicle(arg2,-1959.70, 263.83, 35.47,0,0,180)
  132.         if not veh2 then plr:outputChat("Nieprawidłowy pojazd!", 255, 0, 0) return end
  133.         warpPedIntoVehicle(plr,veh2)
  134.         plr:outputChat("Aby wyrównać rotacje pojazdu użyj /salon rz <ile stopni (0,90,180,360)>", 0, 255, 0)
  135.         plr:outputChat("Aby wprowadzić pojazd do systemu - wyjdź z pojazdu.", 255, 0, 0)
  136.         veh2.locked = true
  137.         veh2.engineState = true
  138.         addEventHandler("onVehicleStartExit", veh2, function()
  139.         local x,y,z=getElementPosition(veh2)
  140.         local rx,ry,rz=getElementRotation(veh2)
  141.         local int=veh2.interior
  142.         local dim=veh2.dimension
  143.         local posformat=x..", "..y..", "..z..", "..rx..", "..ry..", "..rz..", "..dim..", "..int
  144.         local _,_,lastid=exports["ogrpg-db"]:dbSet("insert into iyw_salon (pos,model,koszt,przebieg) VALUES(?,?,?,?)", posformat, veh2.model, 9999999999, 9999999)
  145.         veh2:destroy()
  146.         initid(lastid)
  147.         end)
  148. elseif arg1 == "usun" then
  149.         if not arg2 or not tonumber(arg2) then
  150.                 plr:outputChat("Użycie: /salon usun <salon_dbid>", 255, 0, 0)
  151.                 return
  152.         end
  153.         local pojazdy=getElementsByType("vehicle", resourceRoot)
  154.         for i,v in ipairs(pojazdy) do
  155.         if tonumber(v:getData("salon:dbid")) == tonumber(arg2) then
  156.                 exports["ogrpg-db"]:dbSet("delete from iyw_salon where id=?", v:getData("salon:dbid"))
  157.                 v:getData("salon:cuboid"):destroy()
  158.                 v:destroy()
  159.         end
  160.         end
  161. elseif arg1 == "cena" then
  162.         if not arg2 or not tonumber(arg2) then
  163.                 plr:outputChat("Użycie: /salon cena <cena>", 255, 0, 0)
  164.                 return
  165.         end
  166.         local veh=plr.vehicle
  167.         if not veh or not veh:getData("salon:dbid") then
  168.                 plr:outputChat("Nie jesteś w pojeździe salonowym!", 255, 0, 0)
  169.                 return
  170.         end
  171.         local cuboid2=veh:getData("salon:cuboid")
  172.         local cuboid=cuboid2:getData("cuboid:car_dealership")
  173.         cuboid2:setData("cuboid:car_dealership", {
  174.                 ["veh"] = cuboid["veh"],
  175.                 ["vehicle"] = cuboid["vehicle"],
  176.                 ["vehicle_cost"] = arg2,
  177.                 ["vehicle_mileage"] = cuboid["vehicle_mileage"],
  178.                 ["vehicle_drivetype"] = cuboid["vehicle_drivetype"],
  179.                 ["vehicle_capacity"] = cuboid["vehicle_capacity"]
  180.         })
  181.         exports["ogrpg-db"]:dbSet("update iyw_salon set koszt=? where id=?", arg2, veh:getData("salon:dbid"))
  182.         plr:outputChat("Cena pojazdu została zmieniona na "..arg2.." PLN", 0, 255, 0)
  183. elseif arg1 == "model" then
  184.         if not arg2 or not tonumber(arg2) then
  185.                 plr:outputChat("Użycie: /salon model <model_id>", 255, 0, 0)
  186.                 return
  187.         end
  188.         local veh=plr.vehicle
  189.         if not veh or not veh:getData("salon:dbid") then
  190.                 plr:outputChat("Nie jesteś w pojeździe salonowym!", 255, 0, 0)
  191.                 return
  192.         end
  193.         local model=veh:setModel(arg2)
  194.         if model then
  195.         local cuboid2=veh:getData("salon:cuboid")
  196.         local cuboid=cuboid2:getData("cuboid:car_dealership")
  197.         local q=exports["ogrpg-db"]:dbGet("select * from Rozpis_pojemnosci where model=?", arg2)[1]
  198.         if not q then capacity="1.2" else capacity=q.capacity end
  199.         cuboid2:setData("cuboid:car_dealership", {
  200.                 ["veh"] = cuboid["veh"],
  201.                 ["vehicle"] = arg2,
  202.                 ["vehicle_cost"] = cuboid["vehicle_cost"],
  203.                 ["vehicle_mileage"] = cuboid["vehicle_mileage"],
  204.                 ["vehicle_drivetype"] = cuboid["vehicle_drivetype"],
  205.                 ["vehicle_capacity"] = capacity
  206.         })
  207.         exports["ogrpg-db"]:dbSet("update iyw_salon set model=? where id=?", arg2, veh:getData("salon:dbid"))
  208.         plr:outputChat("Model pojazdu został zmieniony na "..arg2.."", 0, 255, 0)
  209.         exports["iyw_vehtexts"]:add3DTextForElement(veh,{0,0,0},getVehicleNameFromModel(arg2).."\nPOJAZD NA SPRZEDAŻ!\n\nAby ujrzeć wszelkie informacje na temat\ntego pojazdu, podejdź bliżej.",{255,255,255,255},"czcionka4",1.0,30,1)
  210.         else
  211.         plr:outputChat("Nie znaleziono takiego modelu!", 255, 0, 0)
  212.         end
  213. elseif arg1 == "przebieg" then
  214.         if not arg2 or not tonumber(arg2) then
  215.                 plr:outputChat("Użycie: /salon przebieg <przebieg>", 255, 0, 0)
  216.                 return
  217.         end
  218.         local veh=plr.vehicle
  219.         if not veh or not veh:getData("salon:dbid") then
  220.                 plr:outputChat("Nie jesteś w pojeździe salonowym!", 255, 0, 0)
  221.                 return
  222.         end
  223.         local cuboid2=veh:getData("salon:cuboid")
  224.         local cuboid=cuboid2:getData("cuboid:car_dealership")
  225.         cuboid2:setData("cuboid:car_dealership", {
  226.                 ["veh"] = cuboid["veh"],
  227.                 ["vehicle"] = cuboid["vehicle"],
  228.                 ["vehicle_cost"] = cuboid["vehicle_cost"],
  229.                 ["vehicle_mileage"] = arg2,
  230.                 ["vehicle_drivetype"] = cuboid["vehicle_drivetype"],
  231.                 ["vehicle_capacity"] = cuboid["vehicle_capacity"]
  232.         })
  233.         exports["ogrpg-db"]:dbSet("update iyw_salon set przebieg=? where id=?", arg2, veh:getData("salon:dbid"))
  234.         plr:outputChat("Przebieg pojazdu został zmieniony na "..arg2.." KM", 0, 255, 0)
  235. elseif arg1 == "rz" then
  236.         if not arg2 or not tonumber(arg2) then
  237.                 plr:outputChat("Użycie: /salon rz <rz>", 255, 0, 0)
  238.                 return
  239.         end
  240.         local veh=plr.vehicle
  241.         if not veh then
  242.                 plr:outputChat("Nie jesteś w pojeździe!", 255, 0, 0)
  243.                 return
  244.         end
  245.         for i,v in ipairs(getElementsByType("vehicle"), resourceRoot) do
  246.                 if v == veh then
  247.                         local rx,ry,rz = getElementRotation(veh)
  248.                         setElementRotation(veh,rx,ry,arg2)
  249.                 end
  250.         end
  251.         plr:outputChat("Aby zapisać pojazd użyj /salon zapisz", 0, 255, 0)
  252. elseif arg1 == "zapisz" then
  253.         local veh=plr.vehicle
  254.         if not veh or not veh:getData("salon:dbid") then
  255.                 plr:outputChat("Nie jesteś w pojeździe salonowym!", 255, 0, 0)
  256.                 return
  257.         end
  258.         local x,y,z=getElementPosition(veh)
  259.         local rx,ry,rz=getElementRotation(veh)
  260.         local int=veh.interior
  261.         local dim=veh.dimension
  262.         local posformat=x..", "..y..", "..z..", "..rx..", "..ry..", "..rz..", "..dim..", "..int
  263.         exports["ogrpg-db"]:dbSet("update iyw_salon set pos=? where id=?", posformat, veh:getData("salon:dbid"))
  264.         restartResource(getThisResource())
  265. else
  266. plr:outputChat("Użycie: /salon (edytuj,stworz,usun,cena,model,przebieg,zapisz,rz)", 255, 0, 0)
  267. end
  268. end
  269. end
  270. addCommandHandler("salon", salon)
  271.  
  272. addEventHandler("onVehicleStartEnter", resourceRoot, function(player, seat)
  273.         if source:getData("vehicle:for:sale") then
  274.                 cancelEvent()
  275.         end
  276. end)
  277.  
  278. init()