Guest User

Untitled

a guest
Sep 22nd, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. function getVehicleHandlingProperty ( element, property )
  2. if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string
  3. local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable
  4. local value = handlingTable[property] -- Get the value from the table
  5.  
  6. if value then -- If there's a value (valid property)
  7. return value -- Return it
  8. end
  9. end
  10.  
  11. return false -- Not an element, not a vehicle or no valid property string. Return failure
  12. end
  13.  
  14.  
  15. db = exports['sy_db']
  16.  
  17. -- db:setDB("INSERT INTO `pystories-vehicles` (`model`,`ownedPlayer`,`mileage`,`registered`,`parking`,`engine`,`color`,`fuel`) VALUES (?,?,?,?,1,?,?,?)", model, getElementData(player,"player:sid"),0,"true",data['engine'],"255,255,255,255,255,255,255,255,255,255,255,255",'15')
  18. local vehicles = {
  19. -- id,x,y,z,rx,ry,rz,cena,silnik,paliwo,naped
  20. {422,2797.37, -2012.66, 13.54, 359.1, 0.0, 55.0,4100,'1.2',math.random(70000,140000),255,255}, -- bobcat
  21. {404,2789.74, -2027.07, 13.29, 359.7, 0.0, 70.0,2400,'1.2',math.random(70000,140000),0,0}, -- perek
  22. {600,2776.90, -2010.20, 13.29, 359.2, 360.0, 281.0,3600,'1.2',math.random(70000,140000),255,255}, -- picador
  23. {478,2765.90, -2023.73, 13.54, 359.2, 360.0, 315.0,1300,'1.2',math.random(70000,140000),0,0}, -- walton
  24. {418,2768.31, -2006.18, 13.65, 0.1, 360.0, 221.7,2200,'1.2',math.random(70000,140000),0,0}, -- klocek
  25. {410,2775.28, -2026.31, 13.21, 359.4, 0.0, 298.1,2300,'1.2',math.random(70000,140000),1,1}, -- manana
  26. }
  27.  
  28. functions = {}
  29.  
  30. functions.spawnAllVehicles = function()
  31. for k,v in pairs(vehicles) do
  32. veh = createVehicle(v[1],v[2],v[3],v[4],v[5],v[6],v[7],'SALON')
  33. sphere = createColSphere(v[2],v[3],v[4],3)
  34. setElementFrozen(veh,true)
  35. setVehicleColor(veh,75,75,75)
  36. local model = getModelHandling(tonumber(v[1]))
  37. local naped = string.upper(model["driveType"])
  38. setVehicleVariant(veh,v[11],v[12])
  39. setElementData(veh,'vehicle:salon',true)
  40. createBlip(2780.97, -2017.18, 13.55,55,2,255,255,255,255,0,300)
  41. setElementData(sphere,'vehicle:sell:info',{
  42. ['model'] = v[1],
  43. ['cost'] = v[8],
  44. ['engine'] = v[9],
  45. ['naped'] = naped,
  46. ['variant'] = {v[11],v[12]},
  47. ['mileage1'] = v[10],
  48. },
  49. true)
  50. setElementData(veh,'vehicle:sell:info',{
  51. ['model'] = v[1],
  52. ['cost'] = v[8],
  53. ['engine'] = v[9],
  54. ['naped'] = naped,
  55. ['variant'] = {v[11],v[12]},
  56. ['mileage1'] = v[10],
  57. },
  58. true)
  59. end
  60. end
  61. --exports["sy_noti"]:noti("Zasób "..getResourceName(getThisResource())..' został przeładowany. Przepraszamy za utrudnienia.',root, "error", 10000)
  62. addEventHandler('onResourceStart',resourceRoot,functions.spawnAllVehicles)
  63.  
  64.  
  65. functions.onShapeHit = function(hitElement)
  66. if getElementType(hitElement) == 'player' then
  67. local x = getElementData(source,'vehicle:sell:info')
  68. setElementData(hitElement,'vehicle:sell:info',x)
  69. exports["sy_noti"]:noti("Kliknij K aby kupić pojazd.","info", 5000,hitElement)
  70. bindKey(hitElement,'K','down',functions.buy)
  71. end
  72. end
  73.  
  74.  
  75. addEventHandler('onColShapeHit',resourceRoot,functions.onShapeHit)
  76.  
  77. functions.buy = function(player)
  78. local data = getElementData(player,'vehicle:sell:info')
  79. cost = data.cost
  80. model = data.model
  81. engine = data.engine
  82. naped = data.naped
  83. fueltype = data.fueltype
  84. variant = data.variant
  85. mileage = data.mileage1
  86. iprint(variant)
  87. if cost > getPlayerMoney(player) then
  88. exports["sy_noti"]:noti("Nie masz tyle gotĂłwki!","error", 5000,player)
  89. return
  90. end
  91.  
  92. takePlayerMoney(player,cost)
  93. exports['pystories-vehicles']:purchaseVehicle(player, data.model, 25, engine, mileage, variant, {2777.44, -1999.83, 13.15, 359.9, 10.6, 92.3})
  94. exports["sy_noti"]:noti("Pomyślnie zakupiłeś pojazd "..getVehicleNameFromModel(model)..'.',"sukces", 5000,player)
  95. return
  96. end
  97.  
  98. functions.removeAllDatas = function(hitElement)
  99. if getElementType(hitElement) == 'player' then
  100. local x = getElementData(hitElement,'vehicle:sell:info')
  101. if x then
  102. setElementData(hitElement,'vehicle:sell:info',false)
  103. unbindKey(hitElement,'K','down')
  104. end
  105. end
  106. end
  107. addEventHandler('onColShapeLeave',resourceRoot,functions.removeAllDatas)
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. addEventHandler('onVehicleStartEnter',resourceRoot,function()
  115. for i,v in ipairs(getElementsByType('vehicle')) do
  116. if getElementData(v,'vehicle:salon') then
  117. cancelEvent()
  118. end
  119. end
  120. end)
  121.  
  122.  
  123.  
  124.  
  125.  
Advertisement
Add Comment
Please, Sign In to add comment