Guest User

Untitled

a guest
May 17th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.06 KB | None | 0 0
  1. vehicles=0
  2. root=getRootElement()
  3. resourceRoot=getResourceRootElement(getThisResource())
  4.  
  5. local nlOffsets={
  6. [411]={-1,0,-0.6}, -- infernus
  7. [470]={-1,0,-0.4}, -- patriot
  8. [541]={-0.9,0,-0.4}, -- bulelt
  9. [549]={-0.9,0,-0.4}, -- tampa
  10. [587]={-1,0,-0.5}, -- euros
  11. }
  12.  
  13. local nlIDX={
  14. 3962,2113,1784,2054,2428,2352
  15. }
  16.  
  17. function getVehicleHandlingProperty ( element, property )
  18. if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
  19. local handlingTable = getVehicleHandling ( element )
  20. local value = handlingTable[property]
  21.  
  22. if value then
  23. return value
  24. end
  25. end
  26.  
  27. return false
  28. end
  29.  
  30. function getAdmin2(plr,level)
  31. if level then
  32. local result=exports["pystories-db"]:dbGet("SELECT * from pystories_admins WHERE serial=? AND level=?", getPlayerSerial(plr), level)
  33. if result and #result > 0 then
  34. return true
  35. else
  36. return false
  37. end
  38. else
  39. local result=exports["pystories-db"]:dbGet("SELECT * from pystories_admins WHERE serial=?", getPlayerSerial(plr))
  40. if result and #result > 0 then
  41. return true
  42. else
  43. return false
  44. end
  45. end
  46. end
  47. --///////////////////////////////////// WCZYTYWANIE POJAZDÓW /////////////////////////////////
  48. function onRespawnVehicles(_,id,poss)
  49. -- Settings (QUERY)
  50. if id then
  51. result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_vehicles WHERE parking=1 AND id=?", id)
  52. query=exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=0 WHERE id=?", id)
  53. else
  54. result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_vehicles WHERE parking=0")
  55. end
  56.  
  57. -- Pairs
  58. for ile,vehicle in pairs(result) do
  59. vehicles=ile
  60.  
  61. if id then pos={poss[1], poss[2], poss[3], poss[4], poss[5], poss[6]}
  62. else pos=split(vehicle["pos"], ",") end
  63.  
  64. local color=split(vehicle["color"], ",")
  65. local lights=split(vehicle["headlights"], ",")
  66.  
  67. local veh=createVehicle(vehicle["model"], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6])
  68. setVehicleColor(veh, color[1], color[2], color[3], color[4],color[5], color[6], color[7], color[8],color[9], color[10], color[11], color[12])
  69. setVehicleHeadLightColor(veh, lights[1], lights[2], lights[3])
  70. if vehicle["plateText"] ~= "" then
  71. setVehiclePlateText(veh, vehicle["plateText"])
  72. else
  73. setVehiclePlateText(veh, tostring("SA "..vehicle["id"]))
  74. end
  75. if vehicle["paintjob"] ~= 3 then
  76. setVehiclePaintjob(veh, vehicle["paintjob"])
  77. end
  78. setElementHealth(veh, vehicle["health"])
  79. setElementData(veh,"vehicle:spawn",true)
  80. setElementData(veh,"vehicle:id", vehicle["id"])
  81. setElementData(veh,"vehicle:fuel", vehicle["fuel"])
  82. setElementData(veh,"vehicle:bak", vehicle["bak"])
  83. setElementData(veh, "vehicle:mk1", vehicle["mk1"])
  84. setElementData(veh, "vehicle:mk2", vehicle["mk2"])
  85. setElementData(veh, "vehicle:mk3", vehicle["mk3"])
  86. setElementData(veh, "vehicle:mk4", vehicle["mk4"])
  87. setElementData(veh,"vehicle:desc", vehicle["text"] or false)
  88. setElementData(veh,"vehicle:mileage", vehicle["mileage"])
  89. setElementData(veh,"vehicle:driver", vehicle["driver"])
  90. setElementData(veh,"vehicle:ownedGroup", vehicle["ownedGroup"])
  91. setElementData(veh,"vehicle:ownedPlayer", vehicle["ownedPlayer"])
  92. setElementData(veh,"vehicle:pojemnosc", vehicle["pojemnosc"])
  93. setElementData(veh,"vehicle:taxo", vehicle["taxi"])
  94. setElementData(veh,"vehicle:naped", vehicle["naped"])
  95. setElementData(veh,"vehicle:rodzaj", vehicle["rodzaj"])
  96. setVehicleVariant(veh, vehicle["v1"], vehicle["v2"])
  97.  
  98. if getElementData(veh, "vehicle:naped") == "Fabryczny" then
  99. elseif getElementData(veh, "vehicle:naped") == "AWD" then
  100. setVehicleHandling(veh, "driveType", "awd")
  101. setElementData(veh, "naped:awd", true)
  102. elseif getElementData(veh, "vehicle:naped") == "RWD" then
  103. setVehicleHandling(veh, "driveType", "rwd")
  104. setElementData(veh, "naped:rwd", true)
  105. elseif getElementData(veh, "vehicle:naped") == "FWD" then
  106. setVehicleHandling(veh, "driveType", "fwd")
  107. setElementData(veh, "naped:fwd", true)
  108. end
  109.  
  110. if vehicle["analogowy"] == 1 then
  111. setElementData (veh, "vehicle:licznik:analogowy", true)
  112. end
  113. setElementData(veh,"vehicle:licznik", vehicle["licznik"])
  114. if not vehicle["licznik"] then
  115. setElementData(veh,"vehicle:licznik", "zolty")
  116. end
  117.  
  118. if getElementData(veh, "vehicle:rodzaj") == "LPG" then
  119. local acceleration = getVehicleHandling(veh).engineAcceleration
  120. local velocity = getVehicleHandling(veh).maxVelocity
  121. setElementData(veh, "vehicle:fuel", false)
  122. setElementData(veh, "vehicle:gas",vehicle["gas"])
  123. setVehicleHandling(veh, "maxVelocity", velocity+1)
  124. setVehicleHandling(veh, "engineAcceleration", acceleration+0.1)
  125. setVehicleHandling(veh, "engineType", "electric")
  126. elseif getElementData(veh, "vehicle:rodzaj") == "ON" then
  127. local acceleration = getVehicleHandling(veh).engineAcceleration
  128. local velocity = getVehicleHandling(veh).maxVelocity
  129. setVehicleHandling(veh, "maxVelocity", velocity+1)
  130. setVehicleHandling(veh, "engineAcceleration", acceleration+0.1)
  131. setVehicleHandling(veh, "engineType", "diesel")
  132. elseif getElementData(veh, "vehicle:rodzaj") == "PB" then
  133. local acceleration = getVehicleHandling(veh).engineAcceleration
  134. local velocity = getVehicleHandling(veh).maxVelocity
  135. setVehicleHandling(veh, "maxVelocity", velocity+1.1)
  136. setVehicleHandling(veh, "engineAcceleration", acceleration+0.3)
  137. setVehicleHandling(veh, "engineType", "petrol")
  138. elseif getElementData(veh, "vehicle:rodzaj") == "ELECTRIC" then
  139. local acceleration = getVehicleHandling(veh).engineAcceleration
  140. local velocity = getVehicleHandling(veh).maxVelocity
  141. setVehicleHandling(veh, "maxVelocity", velocity+0.3)
  142. setVehicleHandling(veh, "engineAcceleration", acceleration+0.5)
  143. setVehicleHandling(veh, "engineType", "electric")
  144. end
  145.  
  146. if getElementData(veh, "vehicle:pojemnosc") == 1 then
  147. setElementData(veh, "vehicle:poj", "1.2")
  148.  
  149. elseif getElementData(veh, "vehicle:pojemnosc") == 2 then
  150. local acceleration = getVehicleHandling(veh).engineAcceleration
  151. local velocity = getVehicleHandling(veh).maxVelocity
  152. local kg = getVehicleHandling(veh).mass
  153. setElementData(veh, "vehicle:poj", "1.4")
  154. setVehicleHandling(veh, "mass", kg+1)
  155. setVehicleHandling(veh, "maxVelocity", velocity+0.2)
  156. setVehicleHandling(veh, "engineAcceleration", acceleration+0.3)
  157.  
  158. elseif getElementData(veh, "vehicle:pojemnosc") == 3 then
  159. local acceleration = getVehicleHandling(veh).engineAcceleration
  160. local velocity = getVehicleHandling(veh).maxVelocity
  161. local kg = getVehicleHandling(veh).mass
  162. setElementData(veh, "vehicle:poj", "1.6")
  163. setVehicleHandling(veh, "mass", kg+3)
  164. setVehicleHandling(veh, "maxVelocity", velocity+0.5)
  165. setVehicleHandling(veh, "engineAcceleration", acceleration+0.6)
  166.  
  167. elseif getElementData(veh, "vehicle:pojemnosc") == 4 then
  168. local acceleration = getVehicleHandling(veh).engineAcceleration
  169. local velocity = getVehicleHandling(veh).maxVelocity
  170. local kg = getVehicleHandling(veh).mass
  171. setElementData(veh, "vehicle:poj", "1.8")
  172. setVehicleHandling(veh, "mass", kg+6)
  173. setVehicleHandling(veh, "maxVelocity", velocity+1)
  174. setVehicleHandling(veh, "engineAcceleration", acceleration+2)
  175.  
  176. elseif getElementData(veh, "vehicle:pojemnosc") == 5 then
  177. local acceleration = getVehicleHandling(veh).engineAcceleration
  178. local velocity = getVehicleHandling(veh).maxVelocity
  179. local kg = getVehicleHandling(veh).mass
  180. setElementData(veh, "vehicle:poj", "1.9")
  181. setVehicleHandling(veh, "mass", kg+9)
  182. setVehicleHandling(veh, "maxVelocity", velocity+1.2)
  183. setVehicleHandling(veh, "engineAcceleration", acceleration+2.1)
  184.  
  185. elseif getElementData(veh, "vehicle:pojemnosc") == 6 then
  186. local acceleration = getVehicleHandling(veh).engineAcceleration
  187. local velocity = getVehicleHandling(veh).maxVelocity
  188. local kg = getVehicleHandling(veh).mass
  189. setElementData(veh, "vehicle:poj", "2.0")
  190. setVehicleHandling(veh, "mass", kg+11)
  191. setVehicleHandling(veh, "maxVelocity", velocity+1.5)
  192. setVehicleHandling(veh, "engineAcceleration", acceleration+2.5)
  193.  
  194. elseif getElementData(veh, "vehicle:pojemnosc") == 7 then
  195. local acceleration = getVehicleHandling(veh).engineAcceleration
  196. local velocity = getVehicleHandling(veh).maxVelocity
  197. local kg = getVehicleHandling(veh).mass
  198. setElementData(veh, "vehicle:poj", "2.2")
  199. setVehicleHandling(veh, "mass", kg+14)
  200. setVehicleHandling(veh, "maxVelocity", velocity+1.9)
  201. setVehicleHandling(veh, "engineAcceleration", acceleration+2.8)
  202.  
  203. elseif getElementData(veh, "vehicle:pojemnosc") == 8 then
  204. local acceleration = getVehicleHandling(veh).engineAcceleration
  205. local velocity = getVehicleHandling(veh).maxVelocity
  206. local kg = getVehicleHandling(veh).mass
  207. setElementData(veh, "vehicle:poj", "2.4")
  208. setVehicleHandling(veh, "mass", kg+17)
  209. setVehicleHandling(veh, "maxVelocity", velocity+2)
  210. setVehicleHandling(veh, "engineAcceleration", acceleration+2.9)
  211.  
  212. elseif getElementData(veh, "vehicle:pojemnosc") == 9 then
  213. local acceleration = getVehicleHandling(veh).engineAcceleration
  214. local velocity = getVehicleHandling(veh).maxVelocity
  215. local kg = getVehicleHandling(veh).mass
  216. setElementData(veh, "vehicle:poj", "2.6")
  217. setVehicleHandling(veh, "mass", kg+20)
  218. setVehicleHandling(veh, "maxVelocity", velocity+2.2)
  219. setVehicleHandling(veh, "engineAcceleration", acceleration+3)
  220.  
  221. elseif getElementData(veh, "vehicle:pojemnosc") == 10 then
  222. local acceleration = getVehicleHandling(veh).engineAcceleration
  223. local velocity = getVehicleHandling(veh).maxVelocity
  224. local kg = getVehicleHandling(veh).mass
  225. setElementData(veh, "vehicle:poj", "2.8")
  226. setVehicleHandling(veh, "mass", kg+22)
  227. setVehicleHandling(veh, "maxVelocity", velocity+2.5)
  228. setVehicleHandling(veh, "engineAcceleration", acceleration+3.5)
  229.  
  230. elseif getElementData(veh, "vehicle:pojemnosc") == 11 then
  231. local acceleration = getVehicleHandling(veh).engineAcceleration
  232. local velocity = getVehicleHandling(veh).maxVelocity
  233. local kg = getVehicleHandling(veh).mass
  234. setElementData(veh, "vehicle:poj", "2.9")
  235. setVehicleHandling(veh, "mass", kg+25)
  236. setVehicleHandling(veh, "maxVelocity", velocity+2.6)
  237. setVehicleHandling(veh, "engineAcceleration", acceleration+3.6)
  238.  
  239. elseif getElementData(veh, "vehicle:pojemnosc") == 12 then
  240. local acceleration = getVehicleHandling(veh).engineAcceleration
  241. local velocity = getVehicleHandling(veh).maxVelocity
  242. local kg = getVehicleHandling(veh).mass
  243. setElementData(veh, "vehicle:poj", "3.0")
  244. setVehicleHandling(veh, "mass", kg+27)
  245. setVehicleHandling(veh, "maxVelocity", velocity+2.8)
  246. setVehicleHandling(veh, "engineAcceleration", acceleration+3.8)
  247.  
  248. elseif getElementData(veh, "vehicle:pojemnosc") == 13 then
  249. local acceleration = getVehicleHandling(veh).engineAcceleration
  250. local velocity = getVehicleHandling(veh).maxVelocity
  251. local kg = getVehicleHandling(veh).mass
  252. setElementData(veh, "vehicle:poj", "3.2")
  253. setVehicleHandling(veh, "mass", kg+30)
  254. setVehicleHandling(veh, "maxVelocity", velocity+2.9)
  255. setVehicleHandling(veh, "engineAcceleration", acceleration+4)
  256.  
  257. elseif getElementData(veh, "vehicle:pojemnosc") == 14 then
  258. local acceleration = getVehicleHandling(veh).engineAcceleration
  259. local velocity = getVehicleHandling(veh).maxVelocity
  260. local kg = getVehicleHandling(veh).mass
  261. setElementData(veh, "vehicle:poj", "3.4")
  262. setVehicleHandling(veh, "mass", kg+33)
  263. setVehicleHandling(veh, "maxVelocity", velocity+3)
  264. setVehicleHandling(veh, "engineAcceleration", acceleration+4.1)
  265.  
  266. elseif getElementData(veh, "vehicle:pojemnosc") == 15 then
  267. local acceleration = getVehicleHandling(veh).engineAcceleration
  268. local velocity = getVehicleHandling(veh).maxVelocity
  269. local kg = getVehicleHandling(veh).mass
  270. setElementData(veh, "vehicle:poj", "3.5")
  271. setVehicleHandling(veh, "mass", kg+34)
  272. setVehicleHandling(veh, "maxVelocity", velocity+3.1)
  273. setVehicleHandling(veh, "engineAcceleration", acceleration+4.2)
  274.  
  275. elseif getElementData(veh, "vehicle:pojemnosc") == 16 then
  276. local acceleration = getVehicleHandling(veh).engineAcceleration
  277. local velocity = getVehicleHandling(veh).maxVelocity
  278. local kg = getVehicleHandling(veh).mass
  279. setElementData(veh, "vehicle:poj", "3.7")
  280. setVehicleHandling(veh, "mass", kg+36)
  281. setVehicleHandling(veh, "maxVelocity", velocity+3.2)
  282. setVehicleHandling(veh, "engineAcceleration", acceleration+4.3)
  283.  
  284. elseif getElementData(veh, "vehicle:pojemnosc") == 17 then
  285. local acceleration = getVehicleHandling(veh).engineAcceleration
  286. local velocity = getVehicleHandling(veh).maxVelocity
  287. local kg = getVehicleHandling(veh).mass
  288. setElementData(veh, "vehicle:poj", "3.9")
  289. setVehicleHandling(veh, "mass", kg+40)
  290. setVehicleHandling(veh, "maxVelocity", velocity+3.5)
  291. setVehicleHandling(veh, "engineAcceleration", acceleration+4.5)
  292.  
  293. elseif getElementData(veh, "vehicle:pojemnosc") == 18 then
  294. local acceleration = getVehicleHandling(veh).engineAcceleration
  295. local velocity = getVehicleHandling(veh).maxVelocity
  296. local kg = getVehicleHandling(veh).mass
  297. setElementData(veh, "vehicle:poj", "4.0")
  298. setVehicleHandling(veh, "mass", kg+43)
  299. setVehicleHandling(veh, "maxVelocity", velocity+4)
  300. setVehicleHandling(veh, "engineAcceleration", acceleration+4.9)
  301.  
  302. elseif getElementData(veh, "vehicle:pojemnosc") == 19 then
  303. local acceleration = getVehicleHandling(veh).engineAcceleration
  304. local velocity = getVehicleHandling(veh).maxVelocity
  305. local kg = getVehicleHandling(veh).mass
  306. setElementData(veh, "vehicle:poj", "4.2")
  307. setVehicleHandling(veh, "mass", kg+44)
  308. setVehicleHandling(veh, "maxVelocity", velocity+4.1)
  309. setVehicleHandling(veh, "engineAcceleration", acceleration+5)
  310.  
  311. elseif getElementData(veh, "vehicle:pojemnosc") == 20 then
  312. local acceleration = getVehicleHandling(veh).engineAcceleration
  313. local velocity = getVehicleHandling(veh).maxVelocity
  314. local kg = getVehicleHandling(veh).mass
  315. setElementData(veh, "vehicle:poj", "4.5")
  316. setVehicleHandling(veh, "mass", kg+45)
  317. setVehicleHandling(veh, "maxVelocity", velocity+4.5)
  318. setVehicleHandling(veh, "engineAcceleration", acceleration+5.5)
  319.  
  320. elseif getElementData(veh, "vehicle:pojemnosc") == 21 then
  321. local acceleration = getVehicleHandling(veh).engineAcceleration
  322. local velocity = getVehicleHandling(veh).maxVelocity
  323. local kg = getVehicleHandling(veh).mass
  324. setElementData(veh, "vehicle:poj", "4.8")
  325. setVehicleHandling(veh, "mass", kg+46)
  326. setVehicleHandling(veh, "maxVelocity", velocity+4.8)
  327. setVehicleHandling(veh, "engineAcceleration", acceleration+5.8)
  328.  
  329. elseif getElementData(veh, "vehicle:pojemnosc") == 22 then
  330. local acceleration = getVehicleHandling(veh).engineAcceleration
  331. local velocity = getVehicleHandling(veh).maxVelocity
  332. local kg = getVehicleHandling(veh).mass
  333. setElementData(veh, "vehicle:poj", "5.0")
  334. setVehicleHandling(veh, "mass", kg+50)
  335. setVehicleHandling(veh, "maxVelocity", velocity+5)
  336. setVehicleHandling(veh, "engineAcceleration", acceleration+6)
  337.  
  338. elseif getElementData(veh, "vehicle:pojemnosc") == 23 then
  339. local acceleration = getVehicleHandling(veh).engineAcceleration
  340. local velocity = getVehicleHandling(veh).maxVelocity
  341. local kg = getVehicleHandling(veh).mass
  342. setElementData(veh, "vehicle:poj", "5.2")
  343. setVehicleHandling(veh, "mass", kg+52)
  344. setVehicleHandling(veh, "maxVelocity", velocity+6)
  345. setVehicleHandling(veh, "engineAcceleration", acceleration+7)
  346.  
  347. elseif getElementData(veh, "vehicle:pojemnosc") == 24 then
  348. local acceleration = getVehicleHandling(veh).engineAcceleration
  349. local velocity = getVehicleHandling(veh).maxVelocity
  350. local kg = getVehicleHandling(veh).mass
  351. setElementData(veh, "vehicle:poj", "5.5")
  352. setVehicleHandling(veh, "mass", kg+55)
  353. setVehicleHandling(veh, "maxVelocity", velocity+7)
  354. setVehicleHandling(veh, "engineAcceleration", acceleration+8)
  355.  
  356. elseif getElementData(veh, "vehicle:pojemnosc") == 25 then
  357. local acceleration = getVehicleHandling(veh).engineAcceleration
  358. local velocity = getVehicleHandling(veh).maxVelocity
  359. local kg = getVehicleHandling(veh).mass
  360. setElementData(veh, "vehicle:poj", "5.9")
  361. setVehicleHandling(veh, "mass", kg+59)
  362. setVehicleHandling(veh, "maxVelocity", velocity+8)
  363. setVehicleHandling(veh, "engineAcceleration", acceleration+9)
  364.  
  365. elseif getElementData(veh, "vehicle:pojemnosc") == 26 then
  366. local acceleration = getVehicleHandling(veh).engineAcceleration
  367. local velocity = getVehicleHandling(veh).maxVelocity
  368. local kg = getVehicleHandling(veh).mass
  369. setElementData(veh, "vehicle:poj", "6.0")
  370. setVehicleHandling(veh, "mass", kg+60)
  371. setVehicleHandling(veh, "maxVelocity", velocity+10)
  372. setVehicleHandling(veh, "engineAcceleration", acceleration+11)
  373.  
  374. elseif getElementData(veh, "vehicle:pojemnosc") == 27 then
  375. local acceleration = getVehicleHandling(veh).engineAcceleration
  376. local velocity = getVehicleHandling(veh).maxVelocity
  377. local kg = getVehicleHandling(veh).mass
  378. setElementData(veh, "vehicle:poj", "6.1")
  379. setVehicleHandling(veh, "mass", kg+61)
  380. setVehicleHandling(veh, "maxVelocity", velocity+10.8)
  381. setVehicleHandling(veh, "engineAcceleration", acceleration+11.9)
  382.  
  383. elseif getElementData(veh, "vehicle:pojemnosc") == 28 then
  384. local acceleration = getVehicleHandling(veh).engineAcceleration
  385. local velocity = getVehicleHandling(veh).maxVelocity
  386. local kg = getVehicleHandling(veh).mass
  387. setElementData(veh, "vehicle:poj", "6.3")
  388. setVehicleHandling(veh, "mass", kg+63)
  389. setVehicleHandling(veh, "maxVelocity", velocity+11)
  390. setVehicleHandling(veh, "engineAcceleration", acceleration+13)
  391.  
  392. elseif getElementData(veh, "vehicle:pojemnosc") == 29 then
  393. local acceleration = getVehicleHandling(veh).engineAcceleration
  394. local velocity = getVehicleHandling(veh).maxVelocity
  395. local kg = getVehicleHandling(veh).mass
  396. setElementData(veh, "vehicle:poj", "7.2")
  397. setVehicleHandling(veh, "mass", kg+72)
  398. setVehicleHandling(veh, "maxVelocity", velocity+15)
  399. setVehicleHandling(veh, "engineAcceleration", acceleration+17)
  400.  
  401. elseif getElementData(veh, "vehicle:pojemnosc") == 30 then
  402. local acceleration = getVehicleHandling(veh).engineAcceleration
  403. local velocity = getVehicleHandling(veh).maxVelocity
  404. local kg = getVehicleHandling(veh).mass
  405. setElementData(veh, "vehicle:poj", "7.6")
  406. setVehicleHandling(veh, "mass", kg+76)
  407. setVehicleHandling(veh, "maxVelocity", velocity+17)
  408. setVehicleHandling(veh, "engineAcceleration", acceleration+18)
  409.  
  410. elseif getElementData(veh, "vehicle:pojemnosc") == 31 then
  411. local acceleration = getVehicleHandling(veh).engineAcceleration
  412. local velocity = getVehicleHandling(veh).maxVelocity
  413. local kg = getVehicleHandling(veh).mass
  414. setElementData(veh, "vehicle:poj", "8.2")
  415. setVehicleHandling(veh, "mass", kg+82)
  416. setVehicleHandling(veh, "maxVelocity", velocity+19)
  417. setVehicleHandling(veh, "engineAcceleration", acceleration+19)
  418.  
  419. elseif getElementData(veh, "vehicle:pojemnosc") == 32 then
  420. local acceleration = getVehicleHandling(veh).engineAcceleration
  421. local velocity = getVehicleHandling(veh).maxVelocity
  422. local kg = getVehicleHandling(veh).mass
  423. setElementData(veh, "vehicle:poj", "8.9")
  424. setVehicleHandling(veh, "mass", kg+89)
  425. setVehicleHandling(veh, "maxVelocity", velocity+20)
  426. setVehicleHandling(veh, "engineAcceleration", acceleration+18)
  427.  
  428. elseif getElementData(veh, "vehicle:pojemnosc") == 33 then
  429. local acceleration = getVehicleHandling(veh).engineAcceleration
  430. local velocity = getVehicleHandling(veh).maxVelocity
  431. local kg = getVehicleHandling(veh).mass
  432. setElementData(veh, "vehicle:poj", "9.3")
  433. setVehicleHandling(veh, "mass", kg+93)
  434. setVehicleHandling(veh, "maxVelocity", velocity+22)
  435. setVehicleHandling(veh, "engineAcceleration", acceleration+22)
  436.  
  437. elseif getElementData(veh, "vehicle:pojemnosc") == 34 then
  438. local acceleration = getVehicleHandling(veh).engineAcceleration
  439. local velocity = getVehicleHandling(veh).maxVelocity
  440. local kg = getVehicleHandling(veh).mass
  441. setElementData(veh, "vehicle:poj", "40kWh")
  442. setVehicleHandling(veh, "mass", kg+4)
  443. setVehicleHandling(veh, "maxVelocity", velocity+4)
  444. setVehicleHandling(veh, "engineAcceleration", acceleration+8)
  445.  
  446. elseif getElementData(veh, "vehicle:pojemnosc") == 35 then
  447. local acceleration = getVehicleHandling(veh).engineAcceleration
  448. local velocity = getVehicleHandling(veh).maxVelocity
  449. local kg = getVehicleHandling(veh).mass
  450. setElementData(veh, "vehicle:poj", "60kWh")
  451. setVehicleHandling(veh, "mass", kg+8)
  452. setVehicleHandling(veh, "maxVelocity", velocity+7)
  453. setVehicleHandling(veh, "engineAcceleration", acceleration+13)
  454.  
  455. elseif getElementData(veh, "vehicle:pojemnosc") == 36 then
  456. local acceleration = getVehicleHandling(veh).engineAcceleration
  457. local velocity = getVehicleHandling(veh).maxVelocity
  458. local kg = getVehicleHandling(veh).mass
  459. setElementData(veh, "vehicle:poj", "85kWh")
  460. setVehicleHandling(veh, "mass", kg+10)
  461. setVehicleHandling(veh, "maxVelocity", velocity+10)
  462. setVehicleHandling(veh, "engineAcceleration", acceleration+15)
  463.  
  464. elseif getElementData(veh, "vehicle:pojemnosc") == 37 then
  465. local acceleration = getVehicleHandling(veh).engineAcceleration
  466. local velocity = getVehicleHandling(veh).maxVelocity
  467. local kg = getVehicleHandling(veh).mass
  468. setElementData(veh, "vehicle:poj", "P90d")
  469. setVehicleHandling(veh, "mass", kg+15)
  470. setVehicleHandling(veh, "maxVelocity", velocity+15)
  471. setVehicleHandling(veh, "engineAcceleration", acceleration+22)
  472. end
  473.  
  474. if getElementHealth(veh) < 1000 then
  475. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  476. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-5.5);
  477. elseif getElementHealth(veh) < 900 then
  478. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  479. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-10.5);
  480. elseif getElementHealth(veh) < 800 then
  481. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  482. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-30);
  483. elseif getElementHealth(veh) < 700 then
  484. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  485. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-40.5);
  486. elseif getElementHealth(veh) < 600 then
  487. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  488. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-50);
  489. elseif getElementHealth(veh) < 500 then
  490. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  491. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-60.5);
  492. elseif getElementHealth(veh) < 400 then
  493. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  494. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-70);
  495. elseif getElementHealth(veh) < 300 then
  496. local zyciepojazdu = getVehicleHandlingProperty(veh,"maxVelocity")
  497. setVehicleHandling(veh, "maxVelocity", zyciepojazdu-80.5);
  498. end
  499.  
  500.  
  501. --local mk1 = vehicle['mk1']
  502. --local mk2 = vehicle['mk2']
  503. --local mk3 = vehicle['mk3']
  504. --local gleba = vehicle['gleba']
  505. local rh = vehicle['rh']
  506.  
  507.  
  508. if (type(vehicle['rent']) == "string") then
  509. local tabelka = {}
  510. local rente = split(vehicle['rent'], ',')
  511. for k,v in ipairs(rente) do
  512. table.insert(tabelka,v)
  513. end
  514. setElementData(veh,"vehicle:rent", tabelka or false)
  515. else
  516. setElementData(veh,"vehicle:rent",0)
  517. end
  518.  
  519. local mk1 = vehicle['mk1']
  520. if tonumber(mk1) ~= 0 then
  521. local masa = getVehicleHandlingProperty(veh,"mass")
  522. local masa2 = getVehicleHandlingProperty(veh,"turnMass")
  523. local xd = getVehicleHandlingProperty(veh,"tractionMultiplier")
  524. local coef = getVehicleHandlingProperty(veh,"dragCoeff")
  525. local skret = getVehicleHandlingProperty(veh,"steeringLock")
  526. setVehicleHandling(veh,"mass",masa+25)
  527. setVehicleHandling(veh,"steeringLock", skret+15.7)
  528. setVehicleHandling(veh,"tractionMultiplier",xd+0.1)
  529. setVehicleHandling(veh,"dragCoeff",coef+0.07)
  530. end
  531.  
  532. local mk2 = vehicle['mk2']
  533. if tonumber(mk1) ~= 0 then
  534. local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
  535. local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
  536. local masa = getVehicleHandlingProperty(veh,"mass")
  537. local masa2 = getVehicleHandlingProperty(veh,"turnMass")
  538. local xd = getVehicleHandlingProperty(veh,"tractionMultiplier")
  539. local coef = getVehicleHandlingProperty(veh,"dragCoeff")
  540. setVehicleHandling(veh,"engineAcceleration",fast+1)
  541. setVehicleHandling(veh,"maxVelocity",maxfast+10)
  542. setVehicleHandling(veh,"tractionMultiplier",xd+0.1)
  543. setVehicleHandling(veh,"mass",masa+10)
  544. setVehicleHandling(veh,"dragCoeff",coef+0.07)
  545. end
  546.  
  547. local mk3 = vehicle['mk3']
  548. if tonumber(mk3) ~= 0 then
  549. local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
  550. local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
  551. local masa = getVehicleHandlingProperty(veh,"mass")
  552. local masa2 = getVehicleHandlingProperty(veh,"turnMass")
  553. local xd = getVehicleHandlingProperty(veh,"tractionMultiplier")
  554. local coef = getVehicleHandlingProperty(veh,"dragCoeff")
  555. setVehicleHandling(veh,"engineAcceleration",fast+2)
  556. setVehicleHandling(veh,"driveType", "awd")
  557. setVehicleHandling(veh,"maxVelocity",maxfast+2)
  558. setVehicleHandling(veh,"tractionMultiplier",xd+0.1)
  559. setVehicleHandling(veh,"mass",masa+15)
  560. setVehicleHandling(veh,"dragCoeff",coef+0.01)
  561. end
  562.  
  563. local mk4 = vehicle['mk4']
  564. if tonumber(mk4) ~= 0 then
  565. local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
  566. local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
  567. local masa = getVehicleHandlingProperty(veh,"mass")
  568. local masa2 = getVehicleHandlingProperty(veh,"turnMass")
  569. local xd = getVehicleHandlingProperty(veh,"tractionMultiplier")
  570. local coef = getVehicleHandlingProperty(veh,"dragCoeff")
  571. local skret = getVehicleHandlingProperty(veh,"steeringLock")
  572. local hamuj = getVehicleHandlingProperty(veh,"brakeDeceleration")
  573. setVehicleHandling(veh,"engineAcceleration",fast+1)
  574. setVehicleHandling(veh,"maxVelocity",maxfast+0.1)
  575. setVehicleHandling(veh,"mass",masa+50)
  576. setVehicleHandling(veh,"steeringLock", skret+5.7)
  577. setVehicleHandling(veh,"tractionMultiplier",xd+0.1)
  578. setVehicleHandling(veh,"dragCoeff",coef+0.07)
  579. setVehicleHandling(veh,"brakeDeceleration",hamuj+15)
  580. end
  581.  
  582. local hood = vehicle['removehood']
  583. if tonumber(hood) == 1 then
  584. setElementData(veh,"vehicle:bonnet",true)
  585. end
  586.  
  587. local mask = vehicle['masked']
  588. if tonumber(mask) ~= 0 then
  589. setElementData(veh,"vehicle:masked",vehicle['masked'])
  590. end
  591.  
  592. setElementData(veh,"neony", vehicle["neon"])
  593. if vehicle["blokada"] == "true" then
  594. setElementData(veh,"vehicle:block", true)
  595. setVehicleWheelStates(veh, 2, 2, 2, 2)
  596. else
  597. setElementData(veh,"vehicle:block", false)
  598. end
  599. local rodzajneonu=tonumber(getElementData(veh,"neony"))
  600. if getElementData(veh,"neony") ~= 0 then
  601. local m = getElementModel(veh)
  602. local of
  603. if not nlOffsets[m] then
  604. of={-1,0,-0.5}
  605. else
  606. of=nlOffsets[m]
  607. end
  608. neon1=createObject(nlIDX[rodzajneonu],0,0,0)
  609. neon2=createObject(nlIDX[rodzajneonu],0,0,0)
  610. setElementData(veh,"zneony", {neon1, neon2})
  611. attachElements(neon1,veh,of[1],of[2],of[3])
  612. attachElements(neon2,veh,-of[1],of[2],of[3])
  613. end
  614.  
  615. for i,v in ipairs(split(vehicle["tuning"], ",")) do addVehicleUpgrade(veh, v) end
  616. for i,v in ipairs(split(vehicle["panelstates"], ",")) do setVehiclePanelState(veh, i, tonumber(v)) end
  617. setVehicleDamageProof(veh, true)
  618. end
  619. outputDebugString("[MStories] Zaladowano "..vehicles.." pojazdow.")
  620. end
  621. --///////////////////////////////////// ZAPISYWANIE POJAZDÓW /////////////////////////////////
  622. function onSaveVehicle(vehicle)
  623. if getElementData(vehicle,"vehicle:spawn") then
  624. -- Setting
  625. local panelstates={}
  626. local model=getElementModel(vehicle)
  627. local health=getElementHealth(vehicle)
  628. local x,y,z=getElementPosition(vehicle)
  629. local rx,ry,rz=getElementRotation(vehicle)
  630. local desc=getElementData(vehicle,"vehicle:desc") or ""
  631. local id=getElementData(vehicle,"vehicle:id")
  632. local fuel=getElementData(vehicle,"vehicle:fuel")
  633. local mileage=getElementData(vehicle,"vehicle:mileage")
  634. local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12=getVehicleColor(vehicle, true)
  635. local driver=getElementData(vehicle,"vehicle:driver") or ""
  636. local rent=getElementData(vehicle,"vehicle:rent")
  637. local player=getElementData(vehicle,"vehicle:ownedPlayer")
  638. local blokada=getElementData(vehicle,"vehicle:block")
  639. local naped=getElementData(vehicle,"vehicle:naped")
  640. local neon=getElementData(vehicle,"neony")
  641. local h1,h2,h3=getVehicleHeadLightColor(vehicle)
  642. local paintjob=getVehiclePaintjob(vehicle)
  643. local rear="Brak"
  644. local mask=getElementData(vehicle,"vehicle:masked") or 0
  645. local frozen= isElementFrozen(vehicle) and 1 or 0
  646. local v1,v2 = getVehicleVariant(vehicle)
  647. for i=0,6 do table.insert(panelstates, getVehiclePanelState(vehicle,i)) end
  648. panelstates=table.concat(panelstates,",")
  649. upgrades=getVehicleUpgrades(vehicle)
  650. if not upgrades then upgrades={} end
  651. upgrades=table.concat(upgrades, ",")
  652. -- Query
  653. local query = exports["pystories-db"]:dbSet(string.format("UPDATE pystories_vehicles SET model='%d', pos='%.2f,%.2f,%.2f,%.2f,%.2f,%.2f', rent='%d',text='%s', masked='%d', health='%d', fuel='%d', mileage='%d', frozen='%d', driver='%s', color='%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d', panelstates='%s', paintjob='%d', tuning='%s', headlights='%d,%d,%d', ownedPlayer='%d', naped='%s', neon='%d', v1='%d', v2='%d', blokada='%s' WHERE id=%d",
  654. model, x,y,z, rx,ry,rz, "0",desc, mask, health, fuel, mileage, frozen, driver, c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12, panelstates, paintjob, upgrades, h1,h2,h3, player, naped, neon, v1,v2, tostring(blokada), id))
  655. if (type(rent) == "table") then
  656. local rr = string.format("%s", table.concat(rent, ',') )
  657. -- outputDebugString(rr)
  658. local query2= exports['pystories-db']:dbSet("UPDATE pystories_vehicles SET rent=? WHERE id=?",rr,id)
  659. end
  660. end
  661. end
  662.  
  663. function onParkVehicle(vehicle)
  664. local query=exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=1 WHERE id=?", getElementData(vehicle,"vehicle:id"))
  665. if query then
  666. local zneony=getElementData(vehicle,"zneony")
  667. if (zneony and type(zneony)=="table") then
  668. destroyElement(zneony[1])
  669. destroyElement(zneony[2])
  670. removeElementData(vehicle,"zneony")
  671. end
  672. destroyElement(vehicle)
  673. end
  674. end
  675.  
  676. --///////////////////////////////////// SPRAWDZANIE USTAWIEŃ /////////////////////////////////
  677. function getSettings(plr,code,value)
  678. local sid=getElementData(plr,"player:sid")
  679. local uid=getElementData(plr,"player:sid")
  680. if not sid then return end
  681. if value == "faction" then
  682. local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_factions WHERE code=? AND sid=?", code, sid)
  683. if result and #result > 0 then
  684. return result[1].code
  685. else
  686. return false
  687. end
  688. end
  689. if value == "organization" then
  690. local result=exports["pystories-db"]:dbGet("SELECT * FROM ogrpg_organizations WHERE uid=?", uid)
  691. if result and #result > 0 then
  692. return result[1].code
  693. else
  694. return false
  695. end
  696. end
  697. if value == "owner" then
  698. local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?", sid)
  699. if result and #result > 0 then
  700. return result[1].id
  701. else
  702. return false
  703. end
  704. end
  705. end
  706.  
  707. --///////////////////////////////////// INNE USTAWIENIA /////////////////////////////////
  708. addEventHandler("onVehicleExit", root, function(plr,seat)
  709. if seat ~= 0 then return end
  710. onSaveVehicle(plr)
  711. setVehicleEngineState(plr, false)
  712. setVehicleDamageProof(plr, true)
  713. unbindKey(plr, 'n', 'down', bindHoron4)
  714. end)
  715.  
  716.  
  717. addEventHandler("onPlayerQuit", root, function()
  718. local veh=getPedOccupiedVehicle(source)
  719. if veh then
  720. setVehicleDamageProof(source, true)
  721. onSaveVehicle(veh)
  722. end
  723. end)
  724.  
  725. addEventHandler("onResourceStop", resourceRoot, function()
  726. for i,v in ipairs(getElementsByType("vehicle")) do
  727. onSaveVehicle(v)
  728. local zneony=getElementData(v,"zneony")
  729. if (zneony and type(zneony)=="table") then
  730. destroyElement(zneony[1])
  731. destroyElement(zneony[2])
  732. removeElementData(v,"zneony")
  733. end
  734. end
  735. outputDebugString("[MStories] Zapisano wszystkie pojazdy!")
  736. end)
  737. addEventHandler("onVehicleEnter", root, function(plr,seat)
  738. if seat ~= 0 then return end
  739. setVehicleEngineState(source, false)
  740. setElementData(source,"vehicle:driver",getPlayerName(plr))
  741. if getElementData(source,"vehicle:taxo") == 1 then
  742. outputChatBox("* Posiadasz taxometr.",plr,255,255,255,true)
  743. end
  744. end)
  745. addEventHandler("onVehicleEnter", root, function(plr,seat)
  746. if seat ~= 0 then return end
  747. setVehicleEngineState(source, false)
  748. setElementData(source,"vehicle:driver",getPlayerName(plr))
  749. if getElementData(source,"neony") and getElementData(source,"neony") ~= 0 then
  750. outputChatBox("* Posiadasz neony w pojezdzie, możesz wlączyć i wylaczyc je za pomocą przycisku N.",plr)
  751. bindKey(plr, 'n', 'down', bindHoron4, plr)
  752. end
  753. end)
  754.  
  755. --///////////////////////////////////// SPRAWDZENIE WŁAŚCICIELA /////////////////////////////////
  756. addEventHandler("onVehicleStartEnter", resourceRoot, function(plr,seat,jacked)
  757. if seat == 0 then
  758. local rent=getElementData(source, "vehicle:rent")
  759. local group=getElementData(source, "vehicle:ownedGroup")
  760. if group == "0" then group = "Brak" end
  761. local player=getElementData(source, "vehicle:ownedPlayer")
  762. if getAdmin2(plr, 4) then
  763. return
  764. end
  765. if rent and (type(rent) == "table") then
  766. for i,s in pairs(rent) do
  767. if tonumber(s) == getElementData(plr,"player:sid") then
  768. return end
  769. end
  770. end
  771. local plrgroup = getElementData(plr,"player:organization")
  772. if plrgroup then
  773. if getSettings(plr,false,"organization") == group then return end
  774. end
  775. if player and player ~= getSettings(plr,false,"owner") then
  776. outputChatBox("* Nie posiadasz kluczyków do tego pojazdu.", plr)
  777. cancelEvent()
  778. end
  779. end
  780. end)
  781.  
  782. addEventHandler("onVehicleStartEnter", root, function(plr,seat,jacked)
  783. if jacked then
  784. if getElementData(source,"vehicle:ownedPlayer") == getElementData(plr,"player:sid") then return end
  785. cancelEvent()
  786. end
  787. end)
  788.  
  789. addEventHandler("onVehicleStartEnter", root, function(plr,seat,jacked)
  790. if seat == 0 then
  791. if getElementData(source,"spawnowany")== true then
  792. if getElementData(plr,"player:admin")== false then
  793. cancelEvent()
  794. end
  795. end
  796. end
  797. end)
  798.  
  799.  
  800.  
  801. function bindHoron4(plr)
  802. veh=getPedOccupiedVehicle(plr)
  803. if not veh then return end
  804. local rodzajneonu=tonumber(getElementData(veh,"neony"))
  805. if not rodzajneonu then return end
  806. if rodzajneonu==0 then
  807. outputChatBox('* Brak Neonow.', plr, 255, 0 ,0)
  808. return end
  809. local zneony=getElementData(veh,"zneony")
  810. if (zneony and type(zneony)=="table") then
  811. destroyElement(zneony[1])
  812. destroyElement(zneony[2])
  813. removeElementData(veh,"zneony")
  814.  
  815. --triggerClientEvent(plr,"addNotification",root,'* Wyłączyłeś Neony.',"warning")
  816. outputChatBox("* Odłączyłeś(aś) neony od pojazdu.",plr)
  817. else
  818. local m = getElementModel(veh)
  819. local of
  820. if not nlOffsets[m] then
  821. of={-1,0,-0.5}
  822. else
  823. of=nlOffsets[m]
  824. end
  825. neon1=createObject(nlIDX[rodzajneonu],0,0,0)
  826. neon2=createObject(nlIDX[rodzajneonu],0,0,0)
  827. setElementData(veh,"zneony", {neon1, neon2})
  828. attachElements(neon1,veh,of[1],of[2],of[3])
  829. attachElements(neon2,veh,-of[1],of[2],of[3])
  830. --triggerClientEvent(plr,"addNotification",root,'* Włączyłeś Neony. Pojawią się one jak poruszysz pojazdem!',"info")
  831. outputChatBox("* Załączyłeś(aś) neony w pojeździe.",plr)
  832. end
  833. end
  834.  
  835. addEventHandler("onElementDestroy", getRootElement(), function ()
  836. if getElementType(source) == "vehicle" then
  837. local zneony=getElementData(source,"zneony")
  838. if (zneony and type(zneony)=="table") then
  839. destroyElement(zneony[1])
  840. destroyElement(zneony[2])
  841. removeElementData(source,"zneony")
  842. end
  843. end
  844. end)
  845.  
  846.  
  847. addEventHandler("onResourceStart", resourceRoot, function() onRespawnVehicles(_,false) end)
  848.  
  849. local categoryA={[463] = true,[462] = true,[461] = true,[581] = true,[448] = true,[468] = true,[471] = true,[521] = true,[522] = true,[523] = true}
  850. local categoryB={[602] = true,[545] = true,[496] = true,[517] = true,[401] = true,[410] = true,[518] = true,[600] = true,[527] = true,[436] = true,[589] = true,[580] = true,[419] = true,[439] = true,[533] = true,[549] = true,[526] = true,[491] = true,[474] = true,[445] = true,[467] = true,[604] = true,[426] = true,[507] = true,[547] = true,[585] = true,[405] = true,[587] = true,[409] = true,[466] = true,[550] = true,[492] = true,[566] = true,[546] = true,[540] = true,[551] = true,[421] = true,[516] = true,[529] = true,[488] = true,[460] = true,
  851. [469] = true,[487] = true,[510] = true,[509] = true,[481] = true,[586] = true,[472] = true,[473] = true,[493] = true,[595] = true,[484] = true,[430] = true,[453] = true,[452] = true,[446] = true,[454] = true,[485] = true,[552] = true,
  852. [438] = true,[574] = true,[420] = true,[525] = true,[408] = true,[596] = true,[597] = true,[427] = true,[599] = true,[490] = true,[432] = true,[528] = true,[601] = true,[407] = true,[544] = true,[470] = true,[598] = true,[588] = true,
  853. [532] = true,[443] = true,[486] = true,[531] = true,[543] = true,[422] = true,[583] = true,[478] = true,[605] = true,[554] = true,[530] = true,[418] = true,[572] = true,[582] = true,[536] = true,[575] = true,[534] = true,
  854. [567] = true,[535] = true,[576] = true,[412] = true,[402] = true,[542] = true,[603] = true,[475] = true,[449] = true,[537] = true,[570] = true,[441] = true,[464] = true,[501] = true,[465] = true,[564] = true,[568] = true,[557] = true,[424] = true,[504] = true,[495] = true,[457] = true,[539] = true,[483] = true,[571] = true,[500] = true,
  855. [444] = true,[556] = true,[429] = true,[411] = true,[541] = true,[559] = true,[415] = true,[561] = true,[480] = true,[560] = true,[562] = true,[506] = true,[565] = true,[451] = true,[434] = true,[558] = true,[494] = true,[555] = true,[502] = true,[477] = true,[503] = true,[579] = true,[400] = true,[404] = true,[489] = true,[505] = true,[479] = true,[442] = true,[458] = true,
  856. [606] = true,[607] = true,[610] = true,[590] = true,[569] = true,[611] = true,[584] = true,[608] = true,[435] = true,[450] = true,[591] = true,[594] = true}
  857. local categoryC={[403] = true,[406] = true,[413] = true,[414] = true,[416] = true,[423] = true,[428] = true,[431] = true,[433] = true,[437] = true,[440] = true,[455] = true,[456] = true,[459] = true,[482] = true,[498] = true,[499] = true,[508] = true,[514] = true,[515] = true,[524] = true,[538] = true,[573] = true}
  858. addEventHandler("onVehicleStartEnter", resourceRoot, function(plr,seat,jacked)
  859. if seat == 0 then
  860. if categoryA[getElementModel(source)] then
  861. if exports["pystories-ustawienia-prac"]:getVehicleLicense(plr,"A") then
  862. cancelEvent()
  863. end
  864. elseif categoryB[getElementModel(source)] then
  865. if exports["pystories-ustawienia-prac"]:getVehicleLicense(plr,"B") then
  866. cancelEvent()
  867. end
  868. elseif categoryC[getElementModel(source)] then
  869. if exports["pystories-ustawienia-prac"]:getVehicleLicense(plr,"C") then
  870. cancelEvent()
  871. end
  872. end
  873. end
  874. end)
  875.  
  876. addEventHandler("onVehicleEnter", getRootElement(), function(plr,seat,jacked)
  877. if seat ~= 0 then return end
  878. if getElementData(source, "vehicle:id") and getElementData(source, "vehicle:spawn") then
  879. --local gleba = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND gleba=?",getElementData(source, "vehicle:id"), "1")
  880. --local mk2 = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk2=?",getElementData(source, "vehicle:id"), "1")
  881. --local mk1 = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk1=?",getElementData(source, "vehicle:id"), "1")
  882. local rh = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND rh=?",getElementData(source, "vehicle:id"), "1")
  883. --local mk3 = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk3=?",getElementData(source, "vehicle:id"), "1")
  884. end
  885. end)
  886.  
  887. local strefa = { }
  888. local strefy = {
  889. {1336.23840, 656.78876, 9.85624, 60.50634765625, 146.80010986328, 16.164074325562 },
  890. {924.07690, 1661.90576, 9.25354, 194.91711425781, 138.31750488281, 23.899999046326},
  891. {2197.99780, 2405.43872, -31.81085, 178.1982421875, 112.3896484375, 57.499998474121},
  892. }
  893.  
  894. local ogranicznik = createElement ("ogranicznik");
  895. for i,v in ipairs ( strefy ) do
  896. strefa[i] = createColCuboid ( v [ 1 ], v [ 2 ], v [ 3 ], v [ 4 ], v [ 5 ], v [ 6 ], v [7] )
  897. setElementParent (strefa [i], ogranicznik);
  898. end
  899.  
  900. addEventHandler("onColShapeHit", ogranicznik, function(el,md)
  901. if getElementType(el)=="vehicle" then
  902. setElementData(el,"vehicle:tempspeed", 50)
  903. end
  904. end)
  905. addEventHandler("onColShapeLeave", ogranicznik, function(el,md)
  906. if getElementType(el)=="vehicle" then
  907. removeElementData(el,"vehicle:tempspeed")
  908. end
  909. end)
  910.  
  911. addEventHandler("onVehicleEnter", root, function(plr,seat,jacked)
  912. if source then
  913. if source and getElementData(source,"vehicle:masked") then
  914. setElementData(plr,"player:old:nick",getPlayerName(plr))
  915. local x = string.format("#040707%s",getPlayerName(plr):gsub("#%x%x%x%x%x%x",""))
  916. setPlayerName(plr,x)
  917. end
  918. end
  919. end)
  920. addEventHandler("onVehicleExit", root, function(plr,seat,jacked)
  921. if source then
  922. if source and getElementData(source,"vehicle:masked") then
  923. local name = getElementData(plr,"player:old:nick")
  924. setPlayerName(plr,name)
  925. end
  926. end
  927. end)
  928. addEventHandler("onElementDestroy", root, function()
  929. if getElementType(source) ~= "vehicle" then return end
  930. if getElementData(source,"vehicle:masked") then
  931. for i,p in pairs(getVehicleOccupants(source)) do
  932. local name = getElementData(p,"player:old:nick")
  933. setPlayerName(p,name)
  934. end
  935. end
  936. end)
Advertisement
Add Comment
Please, Sign In to add comment