Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.70 KB | None | 0 0
  1. --[[
  2. system pojazdow
  3. @author Lukasz Biegaj <wielebny@bestplay.pl>
  4. @author Karer <karer.programmer@gmail.com>
  5. @author WUBE <wube@lss-rp.pl>
  6. @copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
  7. @license Dual GPLv2/MIT
  8. @package MTA-XyzzyRP
  9. @link https://github.com/lpiob/MTA-XyzzyRP GitHub
  10. ]]--
  11.  
  12.  
  13.  
  14. function graczMaKlucze(vehicle)
  15. local dbid=getElementData(vehicle,"dbid")
  16. if (dbid) then
  17. if (exports["lss-gui"]:eq_getItemByID(6,tonumber(dbid))) then
  18. return true
  19. end
  20.  
  21. -- pojazd org. przestepczej
  22. local owning_co=getElementData(vehicle,"owning_co")
  23. if owning_co then
  24. local character=getElementData(localPlayer, "character")
  25. if character and character.co_id and tonumber(character.co_id)==tonumber(owning_co) then
  26. return true
  27. end
  28. end
  29.  
  30. -- pojazd frakcyjny
  31. local owning_faction=getElementData(vehicle,"owning_faction")
  32. if (owning_faction) then
  33.  
  34. local lfid=getElementData(localPlayer,"faction:id")
  35. if tonumber(owning_faction)==24 then return true end
  36. if (not lfid) then return false end
  37. if tonumber(lfid)~=tonumber(owning_faction) then return false end
  38. -- pobieramy range we frakcji do przyszlego wykorzystania
  39. local lfrid=getElementData(localPlayer,"faction:rank_id")
  40.  
  41. -- frakcja 4 - sm - kluczyki id 12
  42. if (tonumber(owning_faction)==4 and exports["lss-gui"]:eq_getItemByID(12) and lfrid>=2) then
  43. return true
  44. end
  45. -- frakcja 2 - policja - kluczyki id 11
  46. if (tonumber(owning_faction)==2 and exports["lss-gui"]:eq_getItemByID(11)) then
  47. return true
  48. end
  49. -- frakcja 3 warsztat kluczyki id 14
  50. if (tonumber(owning_faction)==3 and exports["lss-gui"]:eq_getItemByID(14) and lfrid>=2) then
  51. return true
  52. end
  53. -- frakcja 8 nauka jazdy kluczyki id 20
  54. if (tonumber(owning_faction)==8 and exports["lss-gui"]:eq_getItemByID(20)) then
  55. return true
  56. end
  57. -- frakcja taxi
  58. if (tonumber(owning_faction)==7 and exports["lss-gui"]:eq_getItemByID(26)) then
  59. return true
  60. end
  61. -- szpital
  62. if (tonumber(owning_faction)==6 and exports["lss-gui"]:eq_getItemByID(29) and lfrid>=2) then
  63. return true
  64. end
  65. -- straz
  66. if (tonumber(owning_faction)==11 and exports["lss-gui"]:eq_getItemByID(39) and lfrid>=2) then
  67. return true
  68. end
  69. -- frakcja 5 cnn news kluczyki id 49
  70. if (tonumber(owning_faction)==5 and exports["lss-gui"]:eq_getItemByID(49) and lfrid>=2) then
  71. return true
  72. end
  73. -- frakcja 1 urzad miasta kluczyki id 50
  74. if (tonumber(owning_faction)==1 and exports["lss-gui"]:eq_getItemByID(50) and lfrid>=2) then
  75. return true
  76. end
  77. -- frakcja 9 kurierzy kluczyki id 51
  78. if (tonumber(owning_faction)==9 and exports["lss-gui"]:eq_getItemByID(51)) then
  79. return true
  80. end
  81. -- frakcja 12 warsztat II kluczyki id 52
  82. if (tonumber(owning_faction)==12 and exports["lss-gui"]:eq_getItemByID(52) and lfrid>=2) then
  83. return true
  84. end
  85. -- frakcja 13 warsztat III kluczyki id 53
  86. if (tonumber(owning_faction)==13 and exports["lss-gui"]:eq_getItemByID(53) and lfrid>=2) then
  87. return true
  88. end
  89. -- frakcja 18 warsztat IV kluczyki id 54
  90. if (tonumber(owning_faction)==18 and exports["lss-gui"]:eq_getItemByID(54) and lfrid>=2) then
  91. return true
  92. end
  93. -- frakcja 19 warsztat V kluczyki id 55
  94. if (tonumber(owning_faction)==19 and exports["lss-gui"]:eq_getItemByID(55) and lfrid>=2) then
  95. return true
  96. end
  97. -- frakcja 16 nauka jazdy 2 kluczyki id 56
  98. if (tonumber(owning_faction)==16 and exports["lss-gui"]:eq_getItemByID(56)) then
  99. return true
  100. end
  101. -- frakcja 15 ochrona id 57
  102. if (tonumber(owning_faction)==15 and exports["lss-gui"]:eq_getItemByID(57) and lfrid>=2) then
  103. return true
  104. end
  105. -- frakcja 10 import id 62
  106. if (tonumber(owning_faction)==10 and exports["lss-gui"]:eq_getItemByID(62)) then
  107. return true
  108. end
  109. -- frakcja 14 kopalnia id 74
  110. if (tonumber(owning_faction)==14 and exports["lss-gui"]:eq_getItemByID(75)) then
  111. return true
  112. end
  113. -- frakcja 17 sąd rejonowy id 77
  114. if (tonumber(owning_faction)==17 and exports["lss-gui"]:eq_getItemByID(77) and lfrid>=2) then
  115. return true
  116. end
  117. -- frakcja 20 służby więzienne id 78
  118. if (tonumber(owning_faction)==20 and exports["lss-gui"]:eq_getItemByID(78) and lfrid>=2) then
  119. return true
  120. end
  121. -- frakcja 22 służby specjalne id 80
  122. if (tonumber(owning_faction)==22 and exports["lss-gui"]:eq_getItemByID(80) and lfrid>=2) then
  123. return true
  124. end
  125. -- frakcja 23 prywatna przychodna lekarska id 92
  126. if (tonumber(owning_faction)==23 and exports["lss-gui"]:eq_getItemByID(92) and lfrid>=2) then
  127. return true
  128. end
  129. -- frakcja 21 sluzby koscielne
  130. if (tonumber(owning_faction)==21 and exports["lss-gui"]:eq_getItemByID(101)) then
  131. return true
  132. end
  133.  
  134. -- 24 tartak klucz 103
  135. if (tonumber(owning_faction)==24) then
  136. return true
  137. end
  138.  
  139. -- 25 szkola lotnicza klucz 106
  140. if (tonumber(owning_faction)==25 and exports["lss-gui"]:eq_getItemByID(106) and lfrid>=2) then
  141. return true
  142. end
  143.  
  144. -- klucze Sklep 'na rogu' I
  145. if (tonumber(owning_faction)==26 and exports["lss-gui"]:eq_getItemByID(117) and lfrid>=2) then
  146. return true
  147. end
  148.  
  149. -- klucze Sklep Spożywczy 'Strug' II
  150. if (tonumber(owning_faction)==27 and exports["lss-gui"]:eq_getItemByID(118) and lfrid>=2) then
  151. return true
  152. end
  153.  
  154. -- klucze Knajpka 'na molo' III
  155. if (tonumber(owning_faction)==28 and exports["lss-gui"]:eq_getItemByID(119) and lfrid>=2) then
  156. return true
  157. end
  158.  
  159. -- klucze Restauracja 'The Well Stacked Pizza' IV
  160. if (tonumber(owning_faction)==29 and exports["lss-gui"]:eq_getItemByID(120) and lfrid>=2) then
  161. return true
  162. end
  163.  
  164. -- klucze Restauracja Hot-Food V
  165. if (tonumber(owning_faction)==30 and exports["lss-gui"]:eq_getItemByID(121) and lfrid>=2) then
  166. return true
  167. end
  168.  
  169. -- klucze Market 'Prima' VI
  170. if (tonumber(owning_faction)==31 and exports["lss-gui"]:eq_getItemByID(122) and lfrid>=2) then
  171. return true
  172. end
  173.  
  174. -- klucze Market 'Super Sam' VII
  175. if (tonumber(owning_faction)==32 and exports["lss-gui"]:eq_getItemByID(123) and lfrid>=2) then
  176. return true
  177. end
  178.  
  179. -- klucze Kawiarnia 'pod sceną' VIII
  180. if (tonumber(owning_faction)==33 and exports["lss-gui"]:eq_getItemByID(124) and lfrid>=2) then
  181. return true
  182. end
  183.  
  184. -- klucze Knajpa 'Paszcza Wieloryba' IX
  185. if (tonumber(owning_faction)==34 and exports["lss-gui"]:eq_getItemByID(125) and lfrid>=2) then
  186. return true
  187. end
  188.  
  189. -- klucze Departament Turystyki
  190. if (tonumber(owning_faction)==35 and exports["lss-gui"]:eq_getItemByID(126) and lfrid>=2) then
  191. return true
  192. end
  193.  
  194. -- klucze Knajpa 'Isaura' X
  195. if (tonumber(owning_faction)==36 and exports["lss-gui"]:eq_getItemByID(128) and lfrid>=2) then
  196. return true
  197. end
  198.  
  199. -- klucze Market 'Łubin' XI
  200. if (tonumber(owning_faction)==37 and exports["lss-gui"]:eq_getItemByID(127) and lfrid>=2) then
  201. return true
  202. end
  203.  
  204. -- klucze Restauracja 'Przy skarpie' XII
  205. if (tonumber(owning_faction)==38 and exports["lss-gui"]:eq_getItemByID(129) and lfrid>=2) then
  206. return true
  207. end
  208.  
  209. -- klucze Knajpa 'Diabelski mlyn' XIII
  210. if (tonumber(owning_faction)==39 and exports["lss-gui"]:eq_getItemByID(149) and lfrid>=2) then
  211. return true
  212. end
  213.  
  214. -- klucze Klubu Miasta Los Santos
  215. if (tonumber(owning_faction)==40 and exports["lss-gui"]:eq_getItemByID(163) and lfrid>=1) then
  216. return true
  217. end
  218.  
  219.  
  220.  
  221.  
  222.  
  223. end
  224. end
  225.  
  226. return false
  227. end
  228.  
  229.  
  230. function menu_startEngine(args)
  231. local vehicle=args.vehicle
  232. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  233. outputDebugString("menu_startEngine na elemencie ktory nie jest pojazdem!")
  234. return
  235. end
  236. -- sprawdzamy czy gracz ma klucz do tego pojazdu
  237. if (not graczMaKlucze(vehicle)) then
  238. outputChatBox("Nie masz kluczy do tego pojazdu.", 255,0,0,true)
  239. return
  240. end
  241.  
  242. if (getElementHealth(vehicle)<300) then
  243. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " próbuje uruchomić silnik.", 5, 10, true)
  244. return
  245. end
  246.  
  247. -- setVehicleEngineState(vehicle, true)
  248. triggerServerEvent("setVehicleEngineState", vehicle, true)
  249. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " uruchamia silnik.", 5, 10, true)
  250. end
  251.  
  252. function menu_stopEngine(args)
  253. local vehicle=args.vehicle
  254. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  255. outputDebugString("menu_startEngine na elemencie ktory nie jest pojazdem!")
  256. return
  257. end
  258. -- sprawdzamy czy gracz ma klucz do tego pojazdu
  259. if (not graczMaKlucze(vehicle)) then
  260. outputChatBox("Nie masz kluczy do tego pojazdu.", 255,0,0,true)
  261. return
  262. end
  263.  
  264.  
  265. -- setVehicleEngineState(vehicle, false)
  266. triggerServerEvent("setVehicleEngineState", vehicle, false)
  267. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " gasi silnik.", 5, 10, true)
  268. end
  269.  
  270. function menu_openVehicle(args)
  271. local vehicle=args.vehicle
  272. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  273. outputDebugString("menu_openVehicle na elemencie ktory nie jest pojazdem!")
  274. return
  275. end
  276. -- sprawdzamy odleglosc
  277. local x,y,z=getElementPosition(localPlayer)
  278. local vx,vy,vz=getElementPosition(vehicle)
  279. if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz)>5) then
  280. outputChatBox("Musisz podejść bliżej do pojazdu aby go otworzyć", 255,0,0,true)
  281. return
  282. end
  283. -- sprawdzamy czy gracz ma klucz do tego pojazdu
  284. if (not graczMaKlucze(vehicle)) then
  285. outputChatBox("Nie masz kluczy do tego pojazdu.", 255,0,0,true)
  286. return
  287. end
  288.  
  289. -- otwieramy go
  290. triggerServerEvent("setVehicleLocked", vehicle, false)
  291.  
  292. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " otwiera zamek w " .. (getVehicleType(vehicle)=="Automobile" and "samochodzie" or "pojeździe" ) .. ".", 5, 15, true)
  293. end
  294.  
  295. function menu_closeVehicle(args)
  296. local vehicle=args.vehicle
  297. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  298. outputDebugString("menu_openVehicle na elemencie ktory nie jest pojazdem!")
  299. return
  300. end
  301.  
  302. -- sprawdzamy odleglosc
  303. local x,y,z=getElementPosition(localPlayer)
  304. local vx,vy,vz=getElementPosition(vehicle)
  305. if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz)>5) then
  306. outputChatBox("Musisz podejść bliżej do pojazdu aby go zamknąć", 255,0,0,true)
  307. return
  308. end
  309. -- sprawdzamy czy gracz ma klucz do tego pojazdu
  310. if (not graczMaKlucze(vehicle)) then
  311. outputChatBox("Nie masz kluczy do tego pojazdu.", 255,0,0,true)
  312. return
  313. end
  314.  
  315. -- otwieramy go
  316. triggerServerEvent("setVehicleLocked", vehicle, true)
  317. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " zamyka zamek w " .. (getVehicleType(vehicle)=="Automobile" and "samochodzie" or "pojeździe" ) .. ".", 5, 15, true)
  318. end
  319.  
  320.  
  321.  
  322. function menu_freeze(args)
  323. local vehicle=args.vehicle
  324. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  325. outputDebugString("menu_maska na elemencie ktory nie jest pojazdem!")
  326. return
  327. end
  328.  
  329. -- zaciagamy reczny
  330. triggerServerEvent("setVehicleFrozen", vehicle, true)
  331. local vt=getVehicleType(vehicle)
  332. if (vt=="Boat") then
  333. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " zarzuca kotwice.", 5, 25, true)
  334. else
  335. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " zaciąga hamulec ręczny.", 5, 15, true)
  336. end
  337.  
  338.  
  339. end
  340.  
  341. function menu_unfreeze(args)
  342. local vehicle=args.vehicle
  343. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  344. outputDebugString("menu_unfreeze na elemencie ktory nie jest pojazdem!")
  345. return
  346. end
  347.  
  348. -- jezeli to motor lub lodz to wymagamy kluczyka
  349. local vt=getVehicleType(vehicle)
  350. if (vt=="Boat" or vt=="Bike") then
  351. if (not graczMaKlucze(vehicle)) then
  352. outputChatBox("Nie masz kluczy do tego pojazdu.", 255,0,0,true)
  353. return
  354. end
  355.  
  356. end
  357.  
  358. -- spuszczamy reczny
  359. triggerServerEvent("setVehicleFrozen", vehicle, false)
  360. if (vt=="Boat") then
  361. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " wciąga kotwice.", 5, 25, true)
  362. else
  363. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " spuszcza hamulec ręczny.", 5, 10, true)
  364. end
  365. end
  366.  
  367.  
  368.  
  369. function menu_maska(args)
  370. local vehicle=args.vehicle
  371. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  372. outputDebugString("menu_maska na elemencie ktory nie jest pojazdem!")
  373. return
  374. end
  375. -- sprawdzamy odleglosc
  376. local x,y,z=getElementPosition(localPlayer)
  377. local vx,vy,vz=getElementPosition(vehicle)
  378. if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz)>5) then
  379. outputChatBox("Musisz podejść bliżej do pojazdu.", 255,0,0,true)
  380. return
  381. end
  382.  
  383. if (isPedInVehicle(localPlayer)) then
  384. outputChatBox("Musisz wysiąść z pojazdu aby to zrobić.", 255,0,0,true)
  385. return
  386. end
  387.  
  388.  
  389. if (getVehicleDoorOpenRatio(vehicle,0)>0) then -- zamykanie maski
  390. triggerServerEvent("setVehicleDoorOpenRatio", vehicle, 0, 0, 1000)
  391. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " zamyka maskę w samochodzie.", 5, 15, true)
  392. return
  393. end
  394.  
  395. -- sprawdzamy czy pojazd jest otwarty
  396. if (isVehicleLocked(vehicle)) then
  397. outputChatBox("Pojazd jest zamknięty.", 255,0,0,true)
  398. return
  399. end
  400. -- otwieramy maske
  401. triggerServerEvent("setVehicleDoorOpenRatio", vehicle, 0, 1, 1000)
  402. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " otwiera maskę w samochodzie.", 5, 15, true)
  403. end
  404.  
  405. function menu_bagaznik(args)
  406. -- zastapione przez lss-bagazniki:menu_bagaznik
  407. local vehicle=args.vehicle
  408. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  409. outputDebugString("menu_bagaznik na elemencie ktory nie jest pojazdem!")
  410. return
  411. end
  412. -- sprawdzamy odleglosc
  413. local x,y,z=getElementPosition(localPlayer)
  414. local vx,vy,vz=getElementPosition(vehicle)
  415. if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz)>5) then
  416. outputChatBox("Musisz podejść bliżej do pojazdu.", 255,0,0,true)
  417. return
  418. end
  419.  
  420. if (isPedInVehicle(localPlayer)) then
  421. outputChatBox("Musisz wysiąść z pojazdu aby to zrobić.", 255,0,0,true)
  422. return
  423. end
  424.  
  425. if (getVehicleDoorOpenRatio(vehicle,1)>0) then -- zamykanie maski
  426. triggerServerEvent("setVehicleDoorOpenRatio", vehicle, 1, 0, 1000)
  427. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " zamyka bagażnik w samochodzie.", 5, 15, true)
  428. return
  429. end
  430.  
  431. -- sprawdzamy czy pojazd jest otwarty
  432. if (isVehicleLocked(vehicle)) then
  433. outputChatBox("Pojazd jest zamknięty.", 255,0,0,true)
  434. return
  435. end
  436. -- otwieramy maske
  437. triggerServerEvent("setVehicleDoorOpenRatio", vehicle, 1, 1, 1000)
  438. triggerServerEvent("broadcastCaptionedEvent", localPlayer, getPlayerName(localPlayer) .. " otwiera bagażnik w samochodzie.", 5, 15, true)
  439. end
  440.  
  441. function menu_kogut(args)
  442. local vehicle=args.vehicle
  443. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  444. outputDebugString("menu_kogut na elemencie ktory nie jest pojazdem!")
  445. return
  446. end
  447. if getPedOccupiedVehicle(localPlayer)~=vehicle then
  448. outputChatBox("Musisz byc w pojezdzie.", 255,0,0)
  449. return
  450. end
  451. if not getElementData(vehicle,"kogut") then
  452. outputChatBox("Ten pojazd nie ma koguta", 255,0,0)
  453. return
  454. end
  455. triggerServerEvent("toggleVehiclePL", vehicle, localPlayer)
  456. end
  457.  
  458. function menu_neony(args)
  459. local vehicle=args.vehicle
  460. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  461. outputDebugString("menu_neony na elemencie ktory nie jest pojazdem!")
  462. return
  463. end
  464. if getPedOccupiedVehicle(localPlayer)~=vehicle then
  465. outputChatBox("Musisz byc w pojezdzie.", 255,0,0)
  466. return
  467. end
  468. if not getElementData(vehicle,"neony") then
  469. outputChatBox("Ten pojazd nie ma neonów", 255,0,0)
  470. return
  471. end
  472. triggerServerEvent("toggleVehicleNL", vehicle, localPlayer)
  473. end
  474.  
  475. function menu_dach(args)
  476. local vehicle=args.vehicle
  477. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  478. outputDebugString("menu_dach na elemencie ktory nie jest pojazdem!")
  479. return
  480. end
  481. if getPedOccupiedVehicle(localPlayer)~=vehicle then
  482. outputChatBox("Musisz byc w pojezdzie.", 255,0,0)
  483. return
  484. end
  485. if (getElementModel(vehicle)~=555) and (getElementModel(vehicle)~=439) then
  486. return
  487. end
  488. triggerServerEvent("toggleVehicleRoof", vehicle, localPlayer)
  489. end
  490.  
  491.  
  492.  
  493.  
  494. function menu_flip(args)
  495. local vehicle=args.vehicle
  496. if (not isElement(vehicle) or getElementType(vehicle)~="vehicle") then -- nie powinno sie wydarzyc
  497. outputDebugString("menu_flip na elemencie ktory nie jest pojazdem!")
  498. return
  499. end
  500. -- sprawdzamy odleglosc
  501. local x,y,z=getElementPosition(localPlayer)
  502. local vx,vy,vz=getElementPosition(vehicle)
  503. if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz)>5) then
  504. outputChatBox("Musisz podejść bliżej do pojazdu.", 255,0,0,true)
  505. return
  506. end
  507.  
  508. if (isPedInVehicle(localPlayer)) then
  509. outputChatBox("Musisz wysiąść z pojazdu aby to zrobić.", 255,0,0,true)
  510. return
  511. end
  512.  
  513. triggerServerEvent("flipVehicle", vehicle, localPlayer)
  514.  
  515. end
  516.  
  517.  
  518. -------------
  519.  
  520.  
  521.  
  522.  
  523. --[[
  524. system pojazdow
  525. @author Lukasz Biegaj <wielebny@bestplay.pl>
  526. @author Karer <karer.programmer@gmail.com>
  527. @author WUBE <wube@lss-rp.pl>
  528. @copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
  529. @license Dual GPLv2/MIT
  530. @package MTA-XyzzyRP
  531. @link https://github.com/lpiob/MTA-XyzzyRP GitHub
  532. ]]--
  533.  
  534.  
  535.  
  536. --[[
  537. function createSpecialVehicle(veh)
  538. if (getElementModel(veh)==578) then -- dft
  539. local o1=createObject(2893,0,0,0)
  540. setElementDoubleSided(o1,true)
  541. attachElements(o1,veh, 1.5,2.3,0.1,0,90,16.5,0)
  542. local o2=createObject(2893,0,0,0)
  543. setElementDoubleSided(o2,true)
  544. attachElements(o2,veh, -1.5,2.3,0.1,0,270,-16.5,0)
  545. local o3=createObject(2937,0,0,0)
  546. attachElements(o3,veh, -0.8,-6.8,-0.8,25)
  547. local o4=createObject(2937,0,0,0)
  548. attachElements(o4,veh, 0.8,-6.8,-0.8,25)
  549. end
  550. end
  551. ]]--
  552.  
  553.  
  554.  
  555.  
  556. local function veh_create(v)
  557. -- outputDebugString("Tworzenie " .. v.id)
  558. v.loc=split(v.loc,",")
  559. v.rot=split(v.rot,",")
  560. local pojazd=createVehicle(v.model, v.loc[1],v.loc[2],v.loc[3],v.rot[1],v.rot[2],v.rot[3],v.tablica .. string.format("%06s",v.id)) -- tablica nie dziala?
  561.  
  562. if getElementModel(pojazd)==439 then setVehicleVariant(pojazd, 1, 255) end
  563. if getElementModel(pojazd)==555 then setVehicleVariant(pojazd, 0, 255) end
  564.  
  565. if (tonumber(v.d)>0) then
  566. setElementDimension(pojazd, tonumber(v.d))
  567. end
  568. if (tonumber(v.i)>0) then
  569. setElementInterior(pojazd, tonumber(v.i))
  570. end
  571.  
  572. if (v.special and type(v.special)=="string" and string.len(v.special)>1) then
  573. setElementData(pojazd,"special",v.special)
  574. end
  575.  
  576.  
  577. setVehicleDamageProof(pojazd, true)
  578. v.hp=tonumber(v.hp)
  579. if (v.hp<301) then v.hp=301 end
  580. setElementHealth(pojazd,v.hp)
  581. setElementData(pojazd,"dbid",v.id)
  582.  
  583.  
  584.  
  585. setElementData(pojazd,"paliwo", { tonumber(v.paliwo) or 25, tonumber(v.bak) or 25})
  586.  
  587. if (tonumber(v.hp)>0 and tonumber(v.model)~=510 and tonumber(v.model)~=509 and tonumber(v.model)~=481) then
  588. setVehicleLocked(pojazd, tonumber(v.locked)>0)
  589. setElementFrozen(pojazd, tonumber(v.frozen)>0)
  590. end
  591.  
  592. if (v.headlightcolor and type(v.headlightcolor)=="string") then
  593. v.headlightcolor=split(v.headlightcolor,",")
  594. -- srun setVehicleHeadLightColor(getPedOccupiedVehicle(getPlayerFromName("Shawn_Hanks")), 100,255,255)
  595. setVehicleHeadLightColor(pojazd, tonumber(v.headlightcolor[1]) or 255, tonumber(v.headlightcolor[2]) or 255 , tonumber(v.headlightcolor[3]) or 255)
  596. end
  597.  
  598. if (v.owning_faction and (type(v.owning_faction)=="string" or type(v.owning_faction)=="number")) then
  599. setElementData(pojazd, "owning_faction", tonumber(v.owning_faction))
  600. end
  601. if (v.owning_co and (type(v.owning_co)=="string" or type(v.owning_co)=="number")) then
  602. setElementData(pojazd, "owning_co", tonumber(v.owning_co))
  603. end
  604.  
  605. if (v.fprint1) then setElementData(pojazd,"fingerprint:1", v.fprint1 or "-") end
  606. if (v.fprint2) then setElementData(pojazd,"fingerprint:2", v.fprint2 or "-") end
  607. if (v.fprint3) then setElementData(pojazd,"fingerprint:3", v.fprint3 or "-") end
  608. if (v.fprint4) then setElementData(pojazd,"fingerprint:4", v.fprint4 or "-") end
  609. if (v.fprint5) then setElementData(pojazd,"fingerprint:5", v.fprint5 or "-") end
  610. if (v.cb and tonumber(v.cb)>0) then
  611. setElementData(pojazd,"cb", true)
  612. end
  613. if (v.kogut and tonumber(v.kogut)>0) then
  614. setElementData(pojazd,"kogut", true)
  615. end
  616.  
  617. if (v.neony and tonumber(v.neony)>0) then
  618. setElementData(pojazd,"neony", tonumber(v.neony))
  619. end
  620.  
  621.  
  622. if (v.damageproof and tonumber(v.damageproof)==1) then
  623. setElementData(pojazd,"damageproof", true)
  624. end
  625.  
  626.  
  627. if (v.gps and tonumber(v.gps)>0) then
  628. setElementData(pojazd,"gps", true, false)
  629. end
  630.  
  631. setElementData(pojazd,"przebieg", tonumber(v.przebieg) or 0)
  632. v.wheelstates=split(v.wheelstates,",")
  633. setVehicleWheelStates(pojazd, unpack(v.wheelstates))
  634. if (v.panelstates~="0,0,0,0,0,0,0") then
  635. v.panelstates=split(v.panelstates,",")
  636. for i,v in ipairs(v.panelstates) do
  637. setVehiclePanelState(pojazd,i-1, tonumber(v))
  638. end
  639. else
  640. v.panelstates=split(v.panelstates,",")
  641. end
  642. if (v.upgrades and type(v.upgrades)=="string") then
  643. v.upgrades=split(v.upgrades,",")
  644. for i,v in ipairs(v.upgrades) do
  645. addVehicleUpgrade(pojazd, tonumber(v))
  646. end
  647. end
  648.  
  649. if (v.opis and type(v.opis)=="string") then
  650. setElementData(pojazd,"opis", v.opis)
  651. end
  652.  
  653. setVehicleColor ( pojazd, math.floor(v.c1/65536), math.floor(v.c1/256%256), v.c1%256, math.floor(v.c2/65536), math.floor(v.c2/256%256), v.c2%256, math.floor(v.c3/65536), math.floor(v.c3/256%256), v.c3%256, math.floor(v.c4/65536), math.floor(v.c4/256%256), v.c4%256)
  654. setVehicleEngineState ( pojazd, false )
  655. end
  656.  
  657. function veh_reload(id)
  658. if (not id) then return end
  659. -- reload bez save!
  660. for i,v in ipairs(getElementsByType("vehicle")) do
  661. local dbid=getElementData(v,"dbid")
  662. if dbid and tonumber(dbid)==tonumber(id) then
  663.  
  664. local zneony=getElementData(v,"zneony")
  665. if (zneony and type(zneony)=="table") then
  666. destroyElement(zneony[1])
  667. destroyElement(zneony[2])
  668. end
  669.  
  670.  
  671. destroyElement(v)
  672. end
  673. end
  674. veh_load(id)
  675. end
  676.  
  677. function veh_load(id)
  678. local pojazd=exports.DB:pobierzWyniki("select id,przebieg,model,loc,d,i,rot,locked,frozen,tablica,hp,fprint1,fprint2,fprint3,fprint4,fprint5,owning_faction,owning_co,c1,c2,c3,c4,headlightcolor,cb,gps,kogut,neony,upgrades,wheelstates,panelstates,opis,paliwo,bak,special,damageproof from lss_vehicles WHERE przechowalnia=0 AND id="..tonumber(id))
  679. if pojazd and pojazd.id then
  680. veh_create(pojazd)
  681. end
  682. end
  683.  
  684. function veh_init()
  685. local pojazdy=exports.DB:pobierzTabeleWynikow("select id,przebieg,model,loc,d,i,rot,locked,frozen,tablica,hp,fprint1,fprint2,fprint3,fprint4,fprint5,owning_faction,owning_co,c1,c2,c3,c4,headlightcolor,cb,gps,kogut,neony,upgrades,wheelstates,panelstates,opis,paliwo,bak,special,damageproof from lss_vehicles WHERE przechowalnia=0")
  686. for i,v in ipairs(pojazdy) do
  687. veh_create(v)
  688. --[[
  689. if (tonumber(v.model)==578) then
  690. createSpecialVehicle(pojazd)
  691. end
  692. ]]--
  693. end
  694. end
  695.  
  696. -- zapisujemy stan pojazdu do bazy danych
  697. function veh_save(vehicle)
  698. local dbid=getElementData(vehicle, "dbid")
  699. if (not dbid) then
  700. return
  701. end
  702. local x,y,z=getElementPosition(vehicle)
  703. local rx,ry,rz=getElementRotation(vehicle)
  704. local hp=getElementHealth(vehicle)
  705. local fp1=getElementData(vehicle,"fingerprint:1") if (not fp1 or type(fp1)~="string") then fp1="-" end
  706. local fp2=getElementData(vehicle,"fingerprint:2") if (not fp1 or type(fp2)~="string") then fp2="-" end
  707. local fp3=getElementData(vehicle,"fingerprint:3") if (not fp1 or type(fp3)~="string") then fp3="-" end
  708. local fp4=getElementData(vehicle,"fingerprint:4") if (not fp1 or type(fp4)~="string") then fp4="-" end
  709. local fp5=getElementData(vehicle,"fingerprint:5") if (not fp1 or type(fp5)~="string") then fp5="-" end
  710. local pp=getElementData(vehicle,"paliwo")
  711. local paliwo=25
  712. local bak=25
  713. if (pp) then
  714. paliwo=tonumber(pp[1]) or 25
  715. bak=tonumber(pp[2]) or 25
  716. end
  717. local wheelstates=table.concat({getVehicleWheelStates(vehicle)},",")
  718. local panelstates={}
  719. for i=0,6 do
  720. table.insert(panelstates, getVehiclePanelState(vehicle,i))
  721. end
  722. panelstates=table.concat(panelstates,",")
  723. local przebieg=getElementData(vehicle,"przebieg") or 0
  724. local locked=isVehicleLocked(vehicle) and 1 or 0
  725. local frozen= isElementFrozen(vehicle) and 1 or 0
  726. local vm=getElementModel(vehicle)
  727. if (vm==510 or vm==509 or vm==481) then -- rowery
  728. locked=0
  729. frozen=0
  730. end
  731. local c11,c12,c13, c21,c22,c23, c31,c32,c33, c41,c42,c43 = getVehicleColor(vehicle,true)
  732. local opis=getElementData(vehicle,"opis")
  733. if (opis and string.len(opis)>=3) then
  734. opis='"' .. exports.DB:esc(opis) .. '"'
  735. else
  736. opis="NULL"
  737. end
  738. local vehUpgrades=getVehicleUpgrades(vehicle)
  739. if not vehUpgrades then vehUpgrades={} end
  740. local upgrades=exports.DB:esc(table.concat(vehUpgrades,","))
  741.  
  742. local query=string.format("UPDATE lss_vehicles SET przebieg='%.2f',upgrades='%s',loc='%.2f,%.2f,%.2f',rot='%.2f,%.2f,%.2f',hp=%d,locked=%d,frozen=%d,fprint1='%s',fprint2='%s',fprint3='%s',fprint4='%s',fprint5='%s',c1=%d,c2=%d,c3=%d,c4=%d,wheelstates='%s',panelstates='%s',opis=%s,paliwo=%.3f,bak=%d WHERE id=%d LIMIT 1",
  743. przebieg,upgrades,x,y,z,rx,ry,rz,hp,locked, frozen,
  744. exports.DB:esc(fp1), exports.DB:esc(fp2), exports.DB:esc(fp3), exports.DB:esc(fp4), exports.DB:esc(fp5),
  745. c13+c12*256+c11*256*256, c23+c22*256+c21*256*256, c33+c32*256+c31*256*256, c43+c42*256+c41*256*256,
  746. exports.DB:esc(wheelstates), exports.DB:esc(panelstates),
  747. opis,
  748. paliwo,bak,
  749. dbid)
  750. exports.DB:zapytanie(query)
  751. end
  752.  
  753. function veh_saveall()
  754. local pojazdy=getElementsByType("vehicle",resourceRoot)
  755. for i,v in ipairs(pojazdy) do
  756. veh_save(v)
  757. end
  758. end
  759.  
  760. function createVehicleEx(model,x,y,z,rx,ry,rz)
  761. local pojazd=createVehicle(model, x,y,z,rx,ry,rz) -- tablica nie dziala?
  762. setVehicleDamageProof(pojazd, true)
  763. local query=string.format("INSERT INTO lss_vehicles SET created=NOW(),model=%d,loc='%.2f,%.2f,%.2f',rot='%.2f,%.2f,%.2f',locked=1", model, x,y,z,rx,ry,rz)
  764. exports.DB:zapytanie(query)
  765. local dbid=exports.DB:insertID()
  766. setVehicleLocked(pojazd,true)
  767. if (dbid and dbid>0) then
  768. setElementData(pojazd,"dbid",dbid)
  769. setElementData(pojazd,"paliwo", { 0.5, 25})
  770. setElementData(pojazd,"przebieg", math.random(1,50)/10)
  771. return dbid,pojazd
  772. else
  773. return false
  774. end
  775. end
  776.  
  777. function unregisterVehicle(dbid)
  778. if not dbid then return false end
  779. local query=string.format("DELETE FROM lss_vehicles WHERE id=%d LIMIT 1", dbid)
  780. exports.DB:zapytanie(query)
  781. return true
  782. end
  783.  
  784. function assignVehicleToOwner(vehicle,owning_player,owning_faction)
  785. if (not vehicle or not isElement(vehicle)) then return end
  786. local dbid=getElementData(vehicle,"dbid")
  787. if (not dbid) then return end
  788.  
  789. if (owning_faction) then
  790. exports.DB:zapytanie(string.format("UPDATE lss_vehicles SET owning_faction=%d WHERE id=%d LIMIT 1", owning_faction, dbid))
  791. setElementData(vehicle,"owning_faction", tonumber(owning_faction))
  792. elseif (getElementData(vehicle,"owning_faction")) then
  793. exports.DB:zapytanie(string.format("UPDATE lss_vehicles SET owning_faction=NULL WHERE id=%d LIMIT 1", dbid))
  794. removeElementData(vehicle,"owning_faction")
  795. end
  796. if (owning_player) then
  797. exports.DB:zapytanie(string.format("UPDATE lss_vehicles SET owning_player=%d WHERE id=%d LIMIT 1", owning_player, dbid))
  798. else
  799. exports.DB:zapytanie(string.format("UPDATE lss_vehicles SET owning_player=NULL WHERE id=%d LIMIT 1", dbid))
  800. end
  801.  
  802. end
  803.  
  804. addEventHandler("onResourceStart",resourceRoot, veh_init)
  805. addEventHandler("onResourceStop",resourceRoot, veh_saveall)
  806.  
  807. addEventHandler("onVehicleEnter", resourceRoot, function(plr,seat)
  808. local vm=getElementModel(source)
  809. if (vm==481 or vm==509 or vm==510) then return end -- rowery
  810. if (seat~=0) then return end
  811. setVehicleEngineState ( source, false )
  812. end)
  813.  
  814. addEventHandler("onVehicleExit", resourceRoot, function(plr,seat)
  815. if (seat==0) then
  816. setVehicleEngineState ( source, false )
  817. setVehicleOverrideLights(source, 1)
  818. end
  819.  
  820.  
  821.  
  822. veh_save(source)
  823. end)
  824.  
  825. function e_setVehicleLocked(state)
  826. setVehicleLocked(source,state)
  827. if (state) then
  828. for i=0,5 do
  829. setVehicleDoorOpenRatio(source,i,0,1000)
  830. end
  831. end
  832. veh_save(source)
  833. end
  834. addEvent("setVehicleLocked", true)
  835. addEventHandler("setVehicleLocked", resourceRoot, e_setVehicleLocked)
  836.  
  837.  
  838. function e_setVehicleDoorOpenRatio(door, ratio, time)
  839. setVehicleDoorOpenRatio(source,door,ratio, time or 1000)
  840. end
  841. addEvent("setVehicleDoorOpenRatio", true)
  842. addEventHandler("setVehicleDoorOpenRatio", resourceRoot, e_setVehicleDoorOpenRatio)
  843.  
  844. addEvent("setVehicleEngineState", true)
  845. addEventHandler("setVehicleEngineState", resourceRoot, function(state)
  846. if (state) then
  847. local pp=getElementData(source,"paliwo")
  848. if (pp and pp[2] and pp[2]>0) then
  849. local paliwo,bak=unpack(pp)
  850. if (paliwo<0.01) then
  851. local kierowca=getVehicleController(source)
  852. if (kierowca) then
  853. setTimer( triggerEvent, 500, 1, "broadcastCaptionedEvent", kierowca, "Silnik pojazdu nie może odpalić.", 5, 5, true)
  854. end
  855. return false
  856. end
  857. end
  858.  
  859. end
  860. setVehicleEngineState(source,state)
  861. end)
  862.  
  863. addEvent("setVehicleFrozen", true)
  864. addEventHandler("setVehicleFrozen", resourceRoot, function(state)
  865. -- jezeli pojazd ma przyczepe, to najpierw zamrazamy tylko ją!
  866. local przyczepa=getVehicleTowedByVehicle(source)
  867. if przyczepa and state then
  868. detachTrailerFromVehicle(source, przyczepa)
  869. setElementFrozen(przyczepa,state)
  870. return
  871. end
  872.  
  873. -- w przeciwnym wypadku wszystko normalnie
  874. setElementFrozen(source,state)
  875. end)
  876.  
  877. -- todo spedycja
  878. --[[
  879. addEventHandler("onTrailerAttach", resourceRoot, function(pojazd)
  880. -- setElementFrozen(source, false)
  881. local kierowca=getVehicleController(pojazd)
  882. if kierowca then
  883. setElementSyncer( source, kierowca) nie dziala
  884. end
  885. end)
  886. ]]--
  887.  
  888. addEventHandler("onTrailerDetach", resourceRoot, function()
  889. -- setElementData(source,"lastDetach", math.floor(getTickCount()/1000),false) todo
  890. veh_save(source)
  891. end)
  892.  
  893.  
  894.  
  895.  
  896. addEvent("setVehicleOverrideLights", true)
  897. addEventHandler("setVehicleOverrideLights", resourceRoot, function(state)
  898. setVehicleOverrideLights(source, state)
  899. local przyczepa=getVehicleTowedByVehicle(source)
  900. if przyczepa then
  901. setVehicleOverrideLights(przyczepa,state)
  902. end
  903.  
  904. end)
  905.  
  906.  
  907. addEventHandler("onVehicleDamage", resourceRoot, function(loss)
  908. local hp=getElementHealth(source)
  909. if (hp<5) then
  910. setElementFrozen(source,false)
  911. end
  912. end)
  913.  
  914. local function silaGraczyWPoblizuPojazdu(element)
  915. local x,y,z=getElementPosition(element)
  916. local sumaSily=0
  917. local cs=createColSphere(x,y,z,7)
  918. local gracze=getElementsWithinColShape(cs)
  919. destroyElement(cs)
  920. for i,gracz in ipairs(gracze) do
  921. local c=getElementData(gracz,"character")
  922. if (c and c.energy) then
  923. sumaSily=sumaSily+tonumber(c.energy)
  924. end
  925. end
  926. return sumaSily
  927. end
  928.  
  929. addEvent("flipVehicle", true)
  930. addEventHandler("flipVehicle", root, function(plr)
  931. if (getElementType(source)~="vehicle") then return end
  932.  
  933. sila=silaGraczyWPoblizuPojazdu(source)
  934. if (sila<800) then
  935. outputChatBox("(( Osoby w pobliżu pojazdu nie posiadają odpowiednio dużej siły aby go obrócić. ))", plr)
  936. outputChatBox("(( Dostepne: " .. sila .. ", wymagane: 800 ))", plr)
  937. triggerEvent("broadcastCaptionedEvent", plr, "Osoby w pobliżu bezskutecznie próbują odwrócić pojazd na koła.", 5, 15, true)
  938. return
  939. end
  940.  
  941. local _,_,z = getElementRotation(source)
  942. setElementRotation(source, 0,0,z)
  943. triggerEvent("broadcastCaptionedEvent", plr, "Osoby w pobliżu pojazdu odwracają go na koła.", 5, 15, true)
  944. end)
  945.  
  946.  
  947. local plOffsets={
  948. [405]={-0.5,-0.1,0.76}, -- sentinel
  949. [426]={-0.5, -0.1, 0.88}, -- premier
  950. [525]={0, -0.5, 1.3}, -- holownik
  951. [554]={0, 0, 1.1}, -- yosemite
  952. [560]={-0.5, 0, 0.85}, -- sultan
  953. [426]={-0.5, 0, 0.85}, -- premier
  954. [574]={0, 0.45, 1.27}, -- sweeper
  955. [578]={-0.7, 3.5, 1.4}, -- laweta
  956. [602]={-0.4, -0.3, 0.73}, -- alpha
  957. [552]={0, 0.6, 1.39}, -- Utility Van
  958. [579]={-0.4, -0.1, 1.28}, -- huntley
  959. [408]={-0.4, 2.7, 1.05}, -- smieciarka
  960. [486]={0, -1.45, 1.45}, -- dozer
  961. -- [541]={-0.4, -0.2, 0.66}, -- bullet
  962.  
  963. }
  964.  
  965. -- triggerServerEvent("toggleVehiclePL", vehicle)
  966. addEvent("toggleVehiclePL", true)
  967. addEventHandler("toggleVehiclePL", root, function(plr)
  968. local kogut=getElementData(source,"kogut")
  969. if (type(kogut)=="userdata" and getElementType(kogut)=="object") then
  970. destroyElement(kogut)
  971. setElementData(source,"kogut", true)
  972. -- triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " zdejmuje koguta z dachu pojazdu.", 5, 25, true)
  973. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " odłącza kogut z pojazdu.", 5, 25, true)
  974. removeVehicleSirens(source)
  975. else
  976. local m = getElementModel(source)
  977. if not plOffsets[m] then
  978. outputChatBox("(( zakładanie koguta na ten model pojazdu nie jest oprogramowane, zglos to administracji ))", plr)
  979. return
  980. end
  981. kogut=createObject(3964,0,0,0)
  982. setElementData(source,"kogut", kogut)
  983. attachElements(kogut,source,unpack(plOffsets[m]))
  984. -- triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " zakłada koguta na dach pojazdu.", 5, 25, true)
  985. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " załącza kogut w pojeździe.", 5, 25, true)
  986. addVehicleSirens(source, 1, 2, true, true, true)
  987. end
  988. end)
  989.  
  990. local nlOffsets={
  991. [411]={-1,0,-0.6}, -- infernus
  992. [470]={-1,0,-0.4}, -- patriot
  993. [541]={-0.9,0,-0.4}, -- bulelt
  994. [549]={-0.9,0,-0.4}, -- tampa
  995. [587]={-1,0,-0.5}, -- euros
  996. }
  997.  
  998. local nlIDX={
  999. 3962,2113,1784,2054,2428,2352
  1000. }
  1001.  
  1002. addEvent("toggleVehicleNL", true)
  1003. addEventHandler("toggleVehicleNL", root, function(plr)
  1004. local rodzajneonu=tonumber(getElementData(source,"neony"))
  1005. if not rodzajneonu then return end
  1006. local zneony=getElementData(source,"zneony")
  1007. if (zneony and type(zneony)=="table") then
  1008. destroyElement(zneony[1])
  1009. destroyElement(zneony[2])
  1010. removeElementData(source,"zneony")
  1011.  
  1012. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " wciska przycisk przy kokpicie.", 5, 5, true)
  1013.  
  1014. else
  1015. local m = getElementModel(source)
  1016. local of
  1017. if not nlOffsets[m] then
  1018. of={-1,0,-0.5}
  1019. else
  1020. of=nlOffsets[m]
  1021. end
  1022. neon1=createObject(nlIDX[rodzajneonu] or 3962,0,0,0)
  1023. neon2=createObject(nlIDX[rodzajneonu] or 3962,0,0,0)
  1024. setElementData(source,"zneony", {neon1, neon2})
  1025. attachElements(neon1,source,of[1],of[2],of[3])
  1026. attachElements(neon2,source,-of[1],of[2],of[3])
  1027. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " wciska przycisk przy kokpicie.", 5, 25, true)
  1028. end
  1029. end)
  1030.  
  1031. addEvent("toggleVehicleRoof", true)
  1032. addEventHandler("toggleVehicleRoof", root, function(plr)
  1033. local v1,v2 = getVehicleVariant(source)
  1034. local engine = getVehicleEngineState(source)
  1035. if getElementModel(source)==555 then --windsor
  1036. if (v1==0) then --jest
  1037. setVehicleVariant(source, 1, 255)
  1038. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " otwiera dach.", 5, 5, true)
  1039. elseif (v1==1) then --nie ma
  1040. setVehicleVariant(source, 0, 255)
  1041. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " zamyka dach.", 5, 5, true)
  1042. end
  1043. elseif getElementModel(source)==439 then --stallion
  1044. if (v1==1) then --jest
  1045. setVehicleVariant(source, 2, 255)
  1046. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " otwiera dach.", 5, 5, true)
  1047. elseif (v1==2) then --nie ma
  1048. setVehicleVariant(source, 1, 255)
  1049. triggerEvent("broadcastCaptionedEvent", plr, getPlayerName(plr) .. " zamyka dach.", 5, 5, true)
  1050. end
  1051. end
  1052. setTimer(function(veh,engine)
  1053. if not engine then
  1054. setVehicleEngineState(veh,false)
  1055. end
  1056. end, 100, 1, source,engine)
  1057. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement