Guest User

Untitled

a guest
Aug 25th, 2019
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- s-side
  2. -- autor: Asper
  3.  
  4. local db = exports['pystories-db']
  5. local vehs = exports['pystories-vehicles']
  6.  
  7. local oddaj = createMarker(-2461.61, 793.65, 35.18-4, "cylinder", 5, 255, 0, 0, 255)
  8. local wez = createMarker(-2457.14, 775.20, 35.17-0.90, "cylinder", 1.2, 255, 200, 0)
  9.  
  10. addEventHandler("onMarkerHit", oddaj, function(hit)
  11.     if(hit and isElement(hit) and getElementType(hit) == "player")then
  12.         local veh = getPedOccupiedVehicle(hit)
  13.         if(veh)then
  14.             local id = getElementData(veh, "vehicle:id")
  15.             if(id)then
  16.                 db:dbSet("update pystories_vehicles set parking=1 where id=?", id)
  17.                 outputChatBox("Twój pojazd trafił na parking.", hit)
  18.                 vehs:onSaveVehicle(veh)
  19.                 destroyElement(veh)
  20.             end
  21.         end
  22.     end
  23. end)
  24.  
  25. addEventHandler("onMarkerHit", wez, function(hit)
  26.     if(hit and isElement(hit) and getElementType(hit) == "player")then
  27.         local veh = getPedOccupiedVehicle(hit)
  28.         if(not veh)then
  29.             local q = db:dbGet("select * from pystories_vehicles where ownedPlayer=? and parking=1", getElementData(hit, "player:sid"))
  30.             if(q and #q > 0)then
  31.                 triggerClientEvent(hit, "get:vehicles", resourceRoot, q)
  32.             else
  33.                 outputChatBox("Nie posiadasz żadnych pojazdów w przechowalni.", hit)
  34.             end
  35.         end
  36.     end
  37. end)
  38.  
  39. addEventHandler("onMarkerLeave", wez, function(hit)
  40.     if(hit and isElement(hit) and getElementType(hit) == "player")then
  41.         local veh = getPedOccupiedVehicle(hit)
  42.         if(not veh)then
  43.             triggerClientEvent(hit, "get:vehicles", resourceRoot)
  44.         end
  45.     end
  46. end)
  47.  
  48. addEvent("get:veh", true)
  49. addEventHandler("get:veh", resourceRoot, function(id)
  50.     local q = db:dbGet("select * from pystories_vehicles where parking=1 and id=?", id)
  51.     if(q and #q > 0)then
  52.         db:dbSet("update pystories_vehicles set parking=0 where id=?", id)
  53.  
  54.         local q = db:dbGet("select * from pystories_vehicles where id=?", id)
  55.         local veh = vehs:onRespawnVehicles(_,id,{-2462.71, 779.80, 34.90, 0.0, 0.0, 87.8})
  56.             warpPedIntoVehicle(client, veh)
  57.     end
  58. end)
RAW Paste Data