SlonPvpru

[ARZ] FastBuyCar v1.0

Jun 4th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 39.97 KB | None | 0 0
  1. -- https://www.blast.hk/threads/48664/
  2.  
  3. script_version(' v1.0')
  4. script_version_number(2)
  5.  
  6. require 'sampfuncs'
  7. require 'moonloader'
  8.  
  9. local h = require('samp.events')
  10. local v = require('vector3d')
  11. requests = require('requests')
  12.  
  13. local tp, sync = false, false
  14.  
  15. local start_tp_time = nil
  16.  
  17. local ev = require('lib.samp.events')
  18. local hook = require 'samp.events'
  19. local events = require 'lib.samp.events'
  20. local imgui = require 'imgui'
  21. local encoding = require 'encoding'
  22. local key = require 'vkeys'
  23. local bNotf, notf = pcall(import, "imgui_notf.lua")
  24. local col = imgui.ImBool(false)
  25. local delchars = imgui.ImBool(false)
  26. local main_window_state = imgui.ImBool(false)
  27. local dlstatus = require('moonloader').download_status
  28. encoding.default = 'CP1251'
  29. u8 = encoding.UTF8
  30.  
  31. local state = false
  32. local grait = false
  33. local scr = thisScript()
  34.  
  35.  
  36. local lovlya = 'ниже'
  37.  
  38. local car1 = imgui.ImBool(false)
  39. local car2 = imgui.ImBool(false)
  40. local car3 = imgui.ImBool(false)
  41. local car4 = imgui.ImBool(false)
  42. local car5 = imgui.ImBool(false)
  43. local car6 = imgui.ImBool(false)
  44. local car7 = imgui.ImBool(false)
  45. local car8 = imgui.ImBool(false)
  46. local car9 = imgui.ImBool(false)
  47. local car10 = imgui.ImBool(false)
  48. local car11 = imgui.ImBool(false)
  49. local car12 = imgui.ImBool(false)
  50. local car13 = imgui.ImBool(false)
  51. local car14 = imgui.ImBool(false)
  52. local car15 = imgui.ImBool(false)
  53. local car16 = imgui.ImBool(false)
  54. local car17 = imgui.ImBool(false)
  55. local car18 = imgui.ImBool(false)
  56. local car19 = imgui.ImBool(false)
  57. local car20 = imgui.ImBool(false)
  58. local car21 = imgui.ImBool(false)
  59. local car22 = imgui.ImBool(false)
  60. local car23 = imgui.ImBool(false)
  61. local car24 = imgui.ImBool(false)
  62. local car25 = imgui.ImBool(false)
  63. local car26 = imgui.ImBool(false)
  64. local car27 = imgui.ImBool(false)
  65. local car28 = imgui.ImBool(false)
  66. local car29 = imgui.ImBool(false)
  67. local car30 = imgui.ImBool(false)
  68. local car31 = imgui.ImBool(false)
  69. local car32 = imgui.ImBool(false)
  70. local car33 = imgui.ImBool(false)
  71. local car34 = imgui.ImBool(false)
  72. local car35 = imgui.ImBool(false)
  73. local car36 = imgui.ImBool(false)
  74. local car37 = imgui.ImBool(false)
  75. local car38 = imgui.ImBool(false)
  76. local car39 = imgui.ImBool(false)
  77. local car40 = imgui.ImBool(false)
  78. local car41 = imgui.ImBool(false)
  79. local car42 = imgui.ImBool(false)
  80. local car43 = imgui.ImBool(false)
  81. local car44 = imgui.ImBool(false)
  82. local car45 = imgui.ImBool(false)
  83. local car46 = imgui.ImBool(false)
  84. local car47 = imgui.ImBool(false)
  85. local car48 = imgui.ImBool(false)
  86. local car49 = imgui.ImBool(false)
  87. local car50 = imgui.ImBool(false)
  88. local car51 = imgui.ImBool(false)
  89. local car52 = imgui.ImBool(false)
  90. local car53 = imgui.ImBool(false)
  91. local car54 = imgui.ImBool(false)
  92.  
  93.  
  94. local chkAutoBuy = imgui.ImBool(false)
  95. local radioState = imgui.ImInt(1)
  96. local chkCatcherState = imgui.ImBool(false)
  97. local ImVec4 = imgui.ImVec4
  98. local ImVec2 = imgui.ImVec2
  99. local pX, pY, pZ = 0
  100.  
  101. local lovlya2 = 'выше'
  102.  
  103. function events.onShowDialog(dialogId, style, title, button1, button2, text)
  104.   if chkAutoBuy.v then
  105.     if text:find("Ётот транспорт продаетс¤") then
  106.       sampSendDialogResponse(dialogId, 1, -1, "0")
  107.       chkAutoBuy.v = false
  108.       return false
  109.     end
  110.   end
  111.   return true;
  112. end
  113.  
  114. function events.onServerMessage(color, text)
  115.   if text:find("“еперь этот транспорт") then
  116.     if radioState.v == 2 then
  117.       sampDisconnectWithReason(500)
  118.       sampAddChatMessage("{FF0000}[Fast Buy Car] {FFFFFF} ƒисконнект проведЄн успешно!", -1)
  119.       radioState.v = 1
  120.     end
  121.     if radioState.v == 3 then
  122.       radioState.v = 1
  123.     end
  124.   end
  125.   return true
  126. end
  127.  
  128. function getHarddiskSerial()
  129.     local ffi = require("ffi")
  130.     ffi.cdef[[
  131.     int __stdcall GetVolumeInformationA(
  132.     const char* lpRootPathName,
  133.     char* lpVolumeNameBuffer,
  134.     uint32_t nVolumeNameSize,
  135.     uint32_t* lpVolumeSerialNumber,
  136.     uint32_t* lpMaximumComponentLength,
  137.     uint32_t* lpFileSystemFlags,
  138.     char* lpFileSystemNameBuffer,
  139.     uint32_t nFileSystemNameSize
  140.     );
  141.     ]]
  142.     local serial = ffi.new("unsigned long[1]", 0)
  143.     ffi.C.GetVolumeInformationA(nil, nil, 0, serial, nil, nil, nil, 0)
  144.     return serial[0]
  145. end
  146.  
  147. function imgui.OnDrawFrame()
  148.     imgui.SetNextWindowPos(imgui.ImVec2(imgui.GetIO().DisplaySize.x - 800, imgui.GetIO().DisplaySize.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
  149.     imgui.SetNextWindowSize(imgui.ImVec2(700, 600), imgui.Cond.FirstUseEver)
  150.     imgui.Begin(u8'                                                             Fast Buy Car SOFTWARE | version ' .. thisScript().version, main_windows_state, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoScrollWithMouse + imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoResize)
  151.     imgui.Text(u8(string.format('                                                           “екуща¤ дата: %s', os.date())))
  152.             imgui.Separator()
  153.             imgui.Checkbox(u8' -  оллизи¤.', col)
  154.             ShowHelpMarker(u8' - —можете проходить сквозь игроков, пробира¤сь на метку дома/бизнеса.', imgui.SameLine())
  155.                   imgui.Checkbox(u8' - ”даление людей.', delchars)
  156.                   ShowHelpMarker(u8' - ѕри нажатии клавиши E все люди в зоне стрима удал¤тс¤.', imgui.SameLine())
  157.                   imgui.Checkbox(u8' - јвтоматическа¤ покупка', chkAutoBuy)
  158.                   ShowHelpMarker(u8' - ѕокупает т/с за вас', imgui.SameLine())
  159.                   imgui.Separator()
  160.                   imgui.Text(u8"ƒействи¤ после покупки авто")
  161.     imgui.RadioButton(u8' - Ќичего не делать', radioState, 1)
  162.     imgui.RadioButton(u8' - ќтключитьс¤ от сервера', radioState, 2)
  163.                   imgui.Separator()
  164.                   if imgui.Button(u8"“елепорт по маркеру(ѕассажирка)") then ectp() end
  165.                   ShowHelpMarker(u8'“елепорт с пассажирки!', imgui.SameLine())
  166.                   if imgui.Button(u8"“елепорт по чекпоинту(ѕассажирка)") then tpc() end
  167.                   ShowHelpMarker(u8'“елепорт с пассажирки!', imgui.SameLine())
  168.                   imgui.Separator()
  169.                   imgui.Checkbox(u8'“елепорт в авто', chkCatcherState)
  170.                   imgui.Text(u8'Ќиже выберите т/с дл¤ ловли')
  171.                   imgui.Text(u8'|')
  172.                   imgui.Text(u8'v')
  173.  
  174.                   imgui.Separator()
  175. if imgui.Checkbox(u8"Landstalker ", car1) then
  176. inputID.v = "400"
  177. end
  178. if imgui.Checkbox(u8"Buffalo ", car2, imgui.SameLine()) then
  179. inputID.v = "402"
  180. end
  181. if imgui.Checkbox(u8"Infernus ", car3, imgui.SameLine()) then
  182. inputID.v = "411"
  183. end
  184. if imgui.Checkbox(u8"Cheetah ", car4, imgui.SameLine()) then
  185. inputID.v = "415"
  186. end
  187. if imgui.Checkbox(u8"Washington ", car5, imgui.SameLine()) then
  188. inputID.v = "421"
  189. end
  190. if imgui.Checkbox(u8"Banshee ", car6, imgui.SameLine()) then
  191. inputID.v = "429"
  192. end
  193. if imgui.Checkbox(u8"Hotknife ", car7, imgui.SameLine()) then
  194. inputID.v = "434"
  195. end
  196. if imgui.Checkbox(u8"Turismo ", car8, imgui.SameLine(nil, 13)) then
  197. inputID.v = "451"
  198. end
  199. if imgui.Checkbox(u8"PCJ-600    ", car9) then
  200. inputID.v = "461"
  201. end
  202. if imgui.Checkbox(u8"Freeway ", car10, imgui.SameLine()) then
  203. inputID.v = "463"
  204. end
  205. if imgui.Checkbox(u8"Sanchez ", car11, imgui.SameLine()) then
  206. inputID.v = "468"
  207. end
  208. if imgui.Checkbox(u8"Sparrow ", car12, imgui.SameLine()) then
  209. inputID.v = "469"
  210. end
  211. if imgui.Checkbox(u8"Quad        ", car13, imgui.SameLine()) then
  212. inputID.v = "471"
  213. end
  214. if imgui.Checkbox(u8"Hermes  ", car14, imgui.SameLine()) then
  215. inputID.v = "474"
  216. end
  217. if imgui.Checkbox(u8"Sabre ", car15, imgui.SameLine()) then
  218. inputID.v = "475"
  219. end
  220. if imgui.Checkbox(u8"ZR-350 ", car16, imgui.SameLine()) then
  221. inputID.v = "477"
  222. end
  223. if imgui.Checkbox(u8"Burrito ", car18) then
  224. inputID.v = "482"
  225. end
  226. if imgui.Checkbox(u8"Maverick ", car19, imgui.SameLine()) then
  227. inputID.v = "487"
  228. end
  229. if imgui.Checkbox(u8"Sandking ", car20, imgui.SameLine()) then
  230. inputID.v = "495"
  231. end
  232. if imgui.Checkbox(u8"Hotring Racer C ", car21, imgui.SameLine()) then
  233. inputID.v = "494"
  234. end
  235. if imgui.Checkbox(u8"Mesa ", car22, imgui.SameLine()) then
  236. inputID.v = "500"
  237. end
  238. if imgui.Checkbox(u8"Hotring Racer A ", car23, imgui.SameLine()) then
  239. inputID.v = "502"
  240. end
  241. if imgui.Checkbox(u8"Hotring Racer B ", car24, imgui.SameLine(nil, 13)) then
  242. inputID.v = "503"
  243. end
  244. if imgui.Checkbox(u8"Super GT ", car25) then
  245. inputID.v = "506"
  246. end
  247. if imgui.Checkbox(u8"Windsor ", car26, imgui.SameLine()) then
  248. inputID.v = "555"
  249. end
  250. if imgui.Checkbox(u8"FCR-900 ", car27, imgui.SameLine()) then
  251. inputID.v = "521"
  252. end
  253. if imgui.Checkbox(u8"NRG-500 ", car28, imgui.SameLine()) then
  254. inputID.v = "522"
  255. end
  256. if imgui.Checkbox(u8"Feltzer ", car29, imgui.SameLine()) then
  257. inputID.v = "533"
  258. end
  259. if imgui.Checkbox(u8"Remington ", car30, imgui.SameLine()) then
  260. inputID.v = "534"
  261. end
  262. if imgui.Checkbox(u8"Slamvan ", car31, imgui.SameLine()) then
  263. inputID.v = "535"
  264. end
  265. if imgui.Checkbox(u8"Blade ", car32, imgui.SameLine(nil, 13)) then
  266. inputID.v = "536"
  267. end
  268. if imgui.Checkbox(u8"Bullet ", car33) then
  269. inputID.v = "541"
  270. end
  271. if imgui.Checkbox(u8"Hustler ", car34, imgui.SameLine()) then
  272. inputID.v = "545"
  273. end
  274. if imgui.Checkbox(u8"Alpha ", car35, imgui.SameLine()) then
  275. inputID.v = "602"
  276. end
  277. if imgui.Checkbox(u8"Yosemite ", car36, imgui.SameLine()) then
  278. inputID.v = "554"
  279. end
  280. if imgui.Checkbox(u8"Uranus ", car37, imgui.SameLine()) then
  281. inputID.v = "558"
  282. end
  283. if imgui.Checkbox(u8"Jester ", car38, imgui.SameLine()) then
  284. inputID.v = "559"
  285. end
  286. if imgui.Checkbox(u8"Sultan ", car39, imgui.SameLine()) then
  287. inputID.v = "560"
  288. end
  289. if imgui.Checkbox(u8"Stratum ", car40, imgui.SameLine()) then
  290. inputID.v = "561"
  291. end
  292. if imgui.Checkbox(u8"Elegy ", car41, imgui.SameLine(nil, 13)) then
  293. inputID.v = "562"
  294. end
  295. if imgui.Checkbox(u8"Flash ", car42) then
  296. inputID.v = "565"
  297. end
  298. if imgui.Checkbox(u8"Tahoma ", car43, imgui.SameLine()) then
  299. inputID.v = "566"
  300. end
  301. if imgui.Checkbox(u8"Virgo ", car44, imgui.SameLine()) then
  302. inputID.v = "491"
  303. end
  304. if imgui.Checkbox(u8"Huntley ", car45, imgui.SameLine()) then
  305. inputID.v = "579"
  306. end
  307. if imgui.Checkbox(u8"BF-400 ", car46, imgui.SameLine()) then
  308. inputID.v = "581"
  309. end
  310. if imgui.Checkbox(u8"Wayfarer ", car47, imgui.SameLine()) then
  311. inputID.v = "586"
  312. end
  313. if imgui.Checkbox(u8"Euros ", car48, imgui.SameLine()) then
  314. inputID.v = "587"
  315. end
  316. if imgui.Checkbox(u8"Club ", car49, imgui.SameLine()) then
  317. inputID.v = "589"
  318. end
  319. if imgui.Checkbox(u8"Picador ", car50, imgui.SameLine(nil, 13)) then
  320. inputID.v = "600"
  321. end
  322. if imgui.Checkbox(u8"Dodo ", car51) then
  323. inputID.v = "593"
  324. end
  325. if imgui.Checkbox(u8"Stuntplane ", car52, imgui.SameLine()) then
  326. inputID.v = "513"
  327. end
  328. if imgui.Checkbox(u8"Phoenix ", car53, imgui.SameLine()) then
  329. inputID.v = "459"
  330. end
  331. if imgui.Checkbox(u8"Romero ", car54, imgui.SameLine()) then
  332. inputID.v = "442"
  333. end
  334. if imgui.Checkbox(u8"Comet ", car17, imgui.SameLine(nil, 13)) then
  335. inputID.v = "480"
  336. end
  337.  
  338. imgui.Separator()
  339.  
  340.  
  341. imgui.Text(u8'                                                                              »нформаци¤')
  342. imgui.Text(u8"                                   јвторы - Dsay and Madjestik. ќ багах и недоработках писать сюда:")
  343. imgui.Text(u8"                                                                          # 1 VK - vk.com/luafile ")
  344. imgui.Text(u8"                                                                          # 2 VK - vk.com/idosonic ")
  345. imgui.End()
  346. if chkCatcherState.v then
  347. poisk()
  348. imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
  349.     local sW, sH = getScreenResolution()
  350.     imgui.SetNextWindowPos(imgui.ImVec2(imgui.GetIO().DisplaySize.x - 300, imgui.GetIO().DisplaySize.y / 3), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
  351. imgui.Begin(u8'Find Car' .. thisScript().version, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar)
  352. imgui.Text(u8"»дЄт поиск машин.")
  353. res, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
  354.         if res then
  355.             ping = sampGetPlayerPing()
  356.         end
  357.         imgui.Text("       ")
  358.         imgui.Text("       ")
  359.         imgui.Text("       ")
  360.         imgui.Text("       ")
  361.         imgui.Text("       ")
  362.         imgui.Text("       ")
  363.         imgui.Text("       ")
  364.         imgui.Text("             Ping: " .. ping)
  365. imgui.End()
  366. end
  367. end
  368.  
  369.  
  370.  
  371. inputID = imgui.ImBuffer(4096)
  372.  
  373. imgui.SwitchContext()
  374. local style = imgui.GetStyle()
  375. local Colors = style.Colors
  376. local ImVec4 = imgui.ImVec4
  377. local ImVec2 = imgui.ImVec2
  378. style.Alpha = 1
  379. style.ChildWindowRounding = 15
  380. style.WindowRounding = 15
  381. style.GrabRounding = 15
  382. style.GrabMinSize = 20
  383. style.FrameRounding = 10
  384.    Colors[imgui.Col.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
  385.     Colors[imgui.Col.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
  386.     Colors[imgui.Col.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
  387.     Colors[imgui.Col.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
  388.     Colors[imgui.Col.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
  389.     Colors[imgui.Col.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
  390.     Colors[imgui.Col.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
  391.     Colors[imgui.Col.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  392.     Colors[imgui.Col.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
  393.     Colors[imgui.Col.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
  394.     Colors[imgui.Col.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  395.     Colors[imgui.Col.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
  396.     Colors[imgui.Col.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
  397.     Colors[imgui.Col.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  398.     Colors[imgui.Col.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
  399.     Colors[imgui.Col.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
  400.     Colors[imgui.Col.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
  401.     Colors[imgui.Col.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  402.     Colors[imgui.Col.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
  403.     Colors[imgui.Col.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
  404.     Colors[imgui.Col.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
  405.     Colors[imgui.Col.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  406.     Colors[imgui.Col.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
  407.     Colors[imgui.Col.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
  408.     Colors[imgui.Col.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
  409.     Colors[imgui.Col.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
  410.     Colors[imgui.Col.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
  411.     Colors[imgui.Col.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  412.     Colors[imgui.Col.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
  413.     Colors[imgui.Col.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
  414.     Colors[imgui.Col.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
  415.     Colors[imgui.Col.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
  416.     Colors[imgui.Col.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
  417.     Colors[imgui.Col.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
  418.     Colors[imgui.Col.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
  419.     Colors[imgui.Col.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
  420.     Colors[imgui.Col.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
  421.     Colors[imgui.Col.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
  422.     Colors[imgui.Col.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
  423.     Colors[imgui.Col.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
  424. local imguiDemo = imgui.ImBool(false)
  425.  
  426.  
  427. function main()
  428.   repeat wait(0) until isSampAvailable()
  429.   sukanaxyi()
  430.   wait(1000)
  431.   sampRegisterChatCommand('tp', ectp)
  432.   sampRegisterChatCommand('poisk', poisk)
  433.   sampRegisterChatCommand('tpc', tpc)
  434.       sampAddChatMessage("{81DAF5}[FBC] {ffffff} ƒоступные команды: /tp, /tpc, {FF0000}„тобы активировать меню нажмите [ I + U ] ", -1)
  435.     sampAddChatMessage("{81DAF5}[FBC] {ffffff} —крипт успешно загружен! “екуща¤ верси¤ {FF0000}v1.0", -1)
  436.     sampAddChatMessage("{81DAF5}[FBC] {ffffff} јвторы: {81DAF5}Dsay {ffffff}and {8000FF}Madjestiks {ffffff}[ blast.hk & CM ]", -1)
  437. while true do wait(0)
  438. if delchars.v and isKeyDown(0x45) then dekchars() end
  439. if col.v then kol() end
  440.   if isKeyJustPressed(0x55) and isKeyJustPressed(0x49) and not sampIsCursorActive() then
  441.     main_window_state.v = not main_window_state.v
  442.     imgui.Process = main_window_state.v
  443.   end
  444. end
  445. end
  446.  
  447. function sukanaxyi()
  448.         response = requests.get('https://kovagi.000webhostapp.com/scpit.php?code='..getHarddiskSerial() * 29)
  449.         if not response.text:match("<body>(.*)</body>"):find("-1") then -- ?сли ключ есть в бд
  450.             if not response.text:match("<body>(.*)</body>"):find("okey") then -- ?сли сервер не ответил что ключ истек.
  451.                 sampAddChatMessage("?о окончани§ лицензии осталось:"..response.text:match("<body>(.*)</body>"), -1) --  ђыводим кол-во дней до конца лицензии
  452.             else
  453.                 sampAddChatMessage(response.text:match("Чрок действи§ лицензии истек."), -1)
  454.             end
  455.         else
  456.             sampAddChatMessage('{ff0000}[FBC] {FFFFFF}- {adeade}Cкрипт не прив§зан.', -1)
  457.             ser = getHarddiskSerial()
  458.             setClipboardText("Key: "..ser)
  459.             thisScript():unload()
  460.             while true do
  461.         end
  462. end
  463. end
  464.  
  465. function SearchMarker(posX, posY, posZ)
  466.   local ret_posX = 0.0
  467.   local ret_posY = 0.0
  468.   local ret_posZ = 0.0
  469.   local isFind = false
  470.   for id = 0, 31 do
  471.       local MarkerStruct = 0
  472.       MarkerStruct = 0xC7F168 + id * 56
  473.       local MarkerPosX = representIntAsFloat(readMemory(MarkerStruct + 0, 4, false))
  474.       local MarkerPosY = representIntAsFloat(readMemory(MarkerStruct + 4, 4, false))
  475.       local MarkerPosZ = representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))
  476.       if MarkerPosX ~= 0.0 or MarkerPosY ~= 0.0 or MarkerPosZ ~= 0.0 then
  477.               ret_posX = MarkerPosX
  478.               ret_posY = MarkerPosY
  479.               ret_posZ = MarkerPosZ
  480.               isFind = true
  481.       end
  482.   end
  483.   return isFind, ret_posX, ret_posY, ret_posZ
  484. end
  485.  
  486. function tpc()
  487.  local posX, posY, posZ = getCharCoordinates(PLAYER_PED)
  488. res, tpx, tpy, tpz = SearchMarker(posX, posY, posZ)
  489. if res then
  490.         if isCharInAnyCar(PLAYER_PED) then
  491.              start_tp_time = os.time()
  492.             tp = true
  493.             lua_thread.create(car_teleport)
  494.         else
  495.             sampAddChatMessage('“пхатьс¤ можно только сид¤ в каре!', -1)
  496.         end
  497.     else sampAddChatMessage('”станови метку куда хочешь тп', -1) end
  498. end
  499.  
  500. function ectp()
  501.     if tp then return end
  502.     res, tpx, tpy, tpz = getTargetBlipCoordinates()
  503.     if res then
  504.         if isCharInAnyCar(PLAYER_PED) then
  505.              start_tp_time = os.time()
  506.             tp = true
  507.             lua_thread.create(car_teleport)
  508.         else
  509.             sampAddChatMessage('“пхатьс¤ можно только сид¤ в каре!', -1)
  510.         end
  511.     else sampAddChatMessage('”станови метку куда хочешь тп', -1) end
  512. end
  513.  
  514. function car_teleport()
  515.     sync = true
  516.    
  517.     local veh = storeCarCharIsInNoSave(PLAYER_PED)
  518.     local res, vid = sampGetVehicleIdByCarHandle(veh)
  519.    
  520.     if not res then
  521.         tp, sync = false, false
  522.         return
  523.     end
  524.    
  525.     local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
  526.     local data = allocateMemory(63)
  527.     sampStorePlayerPassengerData(myId, data)
  528.    
  529.     local seat_id = getStructElement(data, 2, 1)
  530.    
  531.     if seat_id == 0 then
  532.         tp, sync = false, false
  533.         sampAddChatMessage('ƒл¤ телепорта нужно быть на пассажирском месте!', -1)
  534.         return
  535.     end
  536.    
  537.     lockPlayerControl(true)
  538.    
  539.     local x, y, z = getCharCoordinates(PLAYER_PED)
  540.     while(z > -10) do
  541.         z = z - 11
  542.         if z <= -10 then
  543.             sendUnoccupiedSync(vid, seat_id, x, y, -10)
  544.             sendPassengerSync(x, y, -10)
  545.             requestCollision(tpx, tpy)
  546.             loadScene(tpx, tpy, tpz)
  547.             rz = getGroundZFor3dCoord(tpx, tpy, 1000)
  548.             tp_sync_pos = split(x, y, -10, tpx, tpy, -10, 8)
  549.             z = -10
  550.             for i = 1, #tp_sync_pos do
  551.                 -- z = z - 11
  552.                 sendUnoccupiedSync(vid, seat_id, tp_sync_pos[i][1], tp_sync_pos[i][2], z)
  553.                 -- sendPassengerSync(tp_sync_pos[i][1], tp_sync_pos[i][2], z)
  554.                 wait(5)
  555.             end
  556.            
  557.             sendUnoccupiedSync(vid, seat_id, tpx, tpy, rz)
  558.             sendPassengerSync(tpx, tpy, rz)
  559.            
  560.             sendOnfootSync(tpx, tpy, rz, vid)
  561.            
  562.             -- wait(1500)
  563.            
  564.             warpCharFromCarToCoord(PLAYER_PED, tpx, tpy, rz)
  565.            
  566.             sync = false
  567.            
  568.             sampAddChatMessage(string.format('Ќа телепорт было затрачено %d мс!', os.time() - start_tp_time), -1)
  569.            
  570.             lockPlayerControl(false)
  571.             break
  572.         else
  573.             sendUnoccupiedSync(vid, seat_id, x, y, z)
  574.             sendPassengerSync(x, y, z)
  575.         end
  576.     end
  577.     wait(1500)
  578.     tp = false
  579. end
  580.  
  581. function sendOnfootSync(x, y, z, veh)
  582.     local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
  583.     local data = allocateMemory(68)
  584.     sampStorePlayerOnfootData(myId, data)
  585.     setStructElement(data, 37, 1, 3, false)
  586.     setStructFloatElement(data, 6, x, false)
  587.     setStructFloatElement(data, 10, y, false)
  588.     setStructFloatElement(data, 14, z, false)
  589.     setStructElement(data, 62, 2, veh, false)
  590.     sampSendOnfootData(data)
  591.     freeMemory(data)
  592. end
  593.  
  594. function sendPassengerSync(x, y, z)
  595.     local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
  596.     local data = allocateMemory(63)
  597.     sampStorePlayerPassengerData(myId, data)
  598.     setStructFloatElement(data, 12, x, false)
  599.     setStructFloatElement(data, 16, y, false)
  600.     setStructFloatElement(data, 20, z, false)
  601.     sampSendPassengerData(data)
  602.     freeMemory(data)
  603. end
  604.  
  605. function split(x0, y0, z0, x1, y1, z1, step)
  606.     local direction = v(x1 - x0, y1 - y0, z1 - z0)
  607.     local distance = direction:normalize()
  608.     local path = { }
  609.     local begin = v(x0, y0 ,z0)
  610.     local cursor = v(x0, y0, z0)
  611.     path[1] = { cursor:get() }
  612.     repeat
  613.         cursor = cursor + direction * step
  614.         path[#path + 1] = { cursor:get() }
  615.     until(cursor - begin):length() > distance
  616.     return path
  617. end
  618.  
  619. function sendUnoccupiedSync(v, s, x, y, z)
  620.     local data = allocateMemory(67)
  621.     setStructElement(data, 0, 2, v, false)
  622.     setStructElement(data, 2, 1, s, false)
  623.     setStructFloatElement(data, 3, -0.1, false)
  624.     setStructFloatElement(data, 7, -0.2, false)
  625.     setStructFloatElement(data, 11, -0.3, false)
  626.     setStructFloatElement(data, 15, -0.3, false)
  627.     setStructFloatElement(data, 19, -0.2, false)
  628.     setStructFloatElement(data, 23, -0.1, false)
  629.     setStructFloatElement(data, 27, x, false)
  630.     setStructFloatElement(data, 31, y, false)
  631.     setStructFloatElement(data, 35, z, false)
  632.     setStructFloatElement(data, 39, -0.2, false)
  633.     setStructFloatElement(data, 43, -0.2, false)
  634.     setStructFloatElement(data, 47, -0.2, false)
  635.     setStructFloatElement(data, 51, -0.1, false)
  636.     setStructFloatElement(data, 55, -0.2, false)
  637.     setStructFloatElement(data, 59, -0.3, false)
  638.     setStructFloatElement(data, 63, getCarHealth(select(2, sampGetCarHandleBySampVehicleId(v))), false)
  639.     sampSendUnoccupiedData(data)
  640.     freeMemory(data)
  641. end
  642.  
  643. function sendOnfootSync(x, y, z)
  644.     local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
  645.     local data = allocateMemory(68)
  646.     sampStorePlayerOnfootData(myId, data)
  647.     setStructElement(data, 37, 1, 3, false)
  648.     setStructFloatElement(data, 6, x, false)
  649.     setStructFloatElement(data, 10, y, false)
  650.     setStructFloatElement(data, 14, z, false)
  651.     sampSendOnfootData(data)
  652.     freeMemory(data)
  653. end
  654.  
  655. function poisk()
  656.     if state then return end
  657.         if isCharInAnyCar(PLAYER_PED) then sampAddChatMessage('v avto', -1) end
  658.         lua_thread.create(function()
  659.             state = true
  660.             local veh = getAllVehicles()
  661.             for i = 1, #veh do
  662.                 local _, vid = sampGetVehicleIdByCarHandle(veh[i])
  663.                     if _ then
  664.                         if inputID.v:find(getCarModel(veh[i])) then
  665.                             if getDriverOfCar(veh[i]) == -1 then
  666.                             doorStatus = getCarDoorLockStatus(veh[i])
  667.                             if doorStatus == 0 then
  668.                             hp = getCarHealth(veh[i])
  669.                             nopHook("onSetVehiclePosition", true)
  670.                             local data = samp_create_sync_data('player')
  671.                             data.specialAction = 3
  672.                             data.send()
  673.                             sampSendEnterVehicle(vid, true)
  674.                             grait = false
  675.                             local x, y, z = getCharCoordinates(PLAYER_PED)
  676.                             local px, py, pz = getCarCoordinates(veh[i])
  677.                             local dist = getDistanceBetweenCoords3d(x, y, z, px, py, pz)
  678.                             if dist <= 30 then
  679.                             wait(300)
  680.                             end
  681.                             local step = 2
  682.                             while dist > step * 2 do
  683.                                 wait(1)
  684.                                 if x > px then x = x - step else x = x + step end
  685.                                 if y > py then y = y - step else y = y + step end
  686.                                 if z > pz then z = z - step else z = z + step end
  687.                                 local data = samp_create_sync_data('player')
  688.                                 data.specialAction = 3
  689.                                 data.moveSpeed.z = -0.1
  690.                                 data.position.x, data.position.y, data.position.z = x, y, z
  691.                                 data.send()
  692.                                 if dist > 18 then
  693.                                 dist = getDistanceBetweenCoords3d(x, y, z, px, py, pz)
  694.                                 else
  695.                                 warpCharIntoCar(PLAYER_PED, veh[i])
  696.                                 wait(50)
  697.                                 scr:reload()
  698.                                 end
  699.                                 end
  700.                             end
  701.                             state = false
  702.                         end
  703.                     end
  704.                 end
  705.             end
  706.             state = false
  707.         end)
  708. end
  709.  
  710. function nopHook(name, bool)
  711.     local samp = require 'samp.events'
  712.     samp[name] = function()
  713.         if bool then
  714.             return false
  715.         end
  716.     end
  717. end
  718.  
  719. function ev.onSendPlayerSync(data)
  720.     if state then return false end
  721. end
  722.  
  723. function Poiskcarov()
  724.     local findState = false
  725.         for _, carHandle in pairs(getAllVehicles()) do
  726.             if isAllowed(getCarModel(carHandle)) then
  727.                 result, vehicleId = sampGetVehicleIdByCarHandle(carHandle)
  728.                 if result then
  729.                     findState = true
  730.                     break
  731.                 end
  732.             end
  733.         end
  734.     return findState
  735. end
  736.  
  737.  
  738. local function drawImguiDemo()
  739.     if imguiDemo.v then
  740.         imgui.ShowTestWindow(imguiDemo)
  741.     end
  742. end
  743.  
  744. function ShowHelpMarker(desc)
  745.     imgui.TextDisabled('(?)')
  746.     if imgui.IsItemHovered() then
  747.         imgui.BeginTooltip()
  748.         imgui.PushTextWrapPos(450.0)
  749.         imgui.TextUnformatted(desc)
  750.         imgui.PopTextWrapPos()
  751.         imgui.EndTooltip()
  752.     end
  753. end
  754.  
  755.  
  756. function kol()
  757.     for _, pedv in ipairs(getAllChars()) do
  758.     if doesCharExist(pedv) then
  759.         if pedv ~= playerPed then
  760.        setCharCollision(pedv, false)
  761.     end
  762. end
  763. end
  764. end
  765.  
  766. function dekchars()
  767.     for _, handle in ipairs(getAllChars()) do
  768.             if doesCharExist(handle) then
  769.                 local _, id = sampGetPlayerIdByCharHandle(handle)
  770.                     if id ~= myid then
  771.                                 emul_rpc('onPlayerStreamOut', { id })
  772. end
  773. end
  774. end
  775. end
  776.  
  777. function emul_rpc(hook, parameters)
  778.     local bs_io = require 'samp.events.bitstream_io'
  779.     local handler = require 'samp.events.handlers'
  780.     local extra_types = require 'samp.events.extra_types'
  781.     local hooks = {
  782.  
  783.         --[[ Outgoing rpcs
  784.         ['onSendEnterVehicle'] = { 'int16', 'bool8', 26 },
  785.         ['onSendClickPlayer'] = { 'int16', 'int8', 23 },
  786.         ['onSendClientJoin'] = { 'int32', 'int8', 'string8', 'int32', 'string8', 'string8', 'int32', 25 },
  787.         ['onSendEnterEditObject'] = { 'int32', 'int16', 'int32', 'vector3d', 27 },
  788.         ['onSendCommand'] = { 'string32', 50 },
  789.         ['onSendSpawn'] = { 52 },
  790.         ['onSendDeathNotification'] = { 'int8', 'int16', 53 },
  791.         ['onSendDialogResponse'] = { 'int16', 'int8', 'int16', 'string8', 62 },
  792.         ['onSendClickTextDraw'] = { 'int16', 83 },
  793.         ['onSendVehicleTuningNotification'] = { 'int32', 'int32', 'int32', 'int32', 96 },
  794.         ['onSendChat'] = { 'string8', 101 },
  795.         ['onSendClientCheckResponse'] = { 'int8', 'int32', 'int8', 103 },
  796.         ['onSendVehicleDamaged'] = { 'int16', 'int32', 'int32', 'int8', 'int8', 106 },
  797.         ['onSendEditAttachedObject'] = { 'int32', 'int32', 'int32', 'int32', 'vector3d', 'vector3d', 'vector3d', 'int32', 'int32', 116 },
  798.         ['onSendEditObject'] = { 'bool', 'int16', 'int32', 'vector3d', 'vector3d', 117 },
  799.         ['onSendInteriorChangeNotification'] = { 'int8', 118 },
  800.         ['onSendMapMarker'] = { 'vector3d', 119 },
  801.         ['onSendRequestClass'] = { 'int32', 128 },
  802.         ['onSendRequestSpawn'] = { 129 },
  803.         ['onSendPickedUpPickup'] = { 'int32', 131 },
  804.         ['onSendMenuSelect'] = { 'int8', 132 },
  805.         ['onSendVehicleDestroyed'] = { 'int16', 136 },
  806.         ['onSendQuitMenu'] = { 140 },
  807.         ['onSendExitVehicle'] = { 'int16', 154 },
  808.         ['onSendUpdateScoresAndPings'] = { 155 },
  809.         ['onSendGiveDamage'] = { 'int16', 'float', 'int32', 'int32', 115 },
  810.         ['onSendTakeDamage'] = { 'int16', 'float', 'int32', 'int32', 115 },]]
  811.  
  812.         -- Incoming rpcs
  813.         ['onInitGame'] = { 139 },
  814.         ['onPlayerJoin'] = { 'int16', 'int32', 'bool8', 'string8', 137 },
  815.         ['onPlayerQuit'] = { 'int16', 'int8', 138 },
  816.         ['onRequestClassResponse'] = { 'bool8', 'int8', 'int32', 'int8', 'vector3d', 'float', 'Int32Array3', 'Int32Array3', 128 },
  817.         ['onRequestSpawnResponse'] = { 'bool8', 129 },
  818.         ['onSetPlayerName'] = { 'int16', 'string8', 'bool8', 11 },
  819.         ['onSetPlayerPos'] = { 'vector3d', 12 },
  820.         ['onSetPlayerPosFindZ'] = { 'vector3d', 13 },
  821.         ['onSetPlayerHealth'] = { 'float', 14 },
  822.         ['onTogglePlayerControllable'] = { 'bool8', 15 },
  823.         ['onPlaySound'] = { 'int32', 'vector3d', 16 },
  824.         ['onSetWorldBounds'] = { 'float', 'float', 'float', 'float', 17 },
  825.         ['onGivePlayerMoney'] = { 'int32', 18 },
  826.         ['onSetPlayerFacingAngle'] = { 'float', 19 },
  827.         --['onResetPlayerMoney'] = { 20 },
  828.         --['onResetPlayerWeapons'] = { 21 },
  829.         ['onGivePlayerWeapon'] = { 'int32', 'int32', 22 },
  830.         --['onCancelEdit'] = { 28 },
  831.         ['onSetPlayerTime'] = { 'int8', 'int8', 29 },
  832.         ['onSetToggleClock'] = { 'bool8', 30 },
  833.         ['onPlayerStreamIn'] = { 'int16', 'int8', 'int32', 'vector3d', 'float', 'int32', 'int8', 32 },
  834.         ['onSetShopName'] = { 'string256', 33 },
  835.         ['onSetPlayerSkillLevel'] = { 'int16', 'int32', 'int16', 34 },
  836.         ['onSetPlayerDrunk'] = { 'int32', 35 },
  837.         ['onCreate3DText'] = { 'int16', 'int32', 'vector3d', 'float', 'bool8', 'int16', 'int16', 'encodedString4096', 36 },
  838.         --['onDisableCheckpoint'] = { 37 },
  839.         ['onSetRaceCheckpoint'] = { 'int8', 'vector3d', 'vector3d', 'float', 38 },
  840.         --['onDisableRaceCheckpoint'] = { 39 },
  841.         --['onGamemodeRestart'] = { 40 },
  842.         ['onPlayAudioStream'] = { 'string8', 'vector3d', 'float', 'bool8', 41 },
  843.         --['onStopAudioStream'] = { 42 },
  844.         ['onRemoveBuilding'] = { 'int32', 'vector3d', 'float', 43 },
  845.         ['onCreateObject'] = { 44 },
  846.         ['onSetObjectPosition'] = { 'int16', 'vector3d', 45 },
  847.         ['onSetObjectRotation'] = { 'int16', 'vector3d', 46 },
  848.         ['onDestroyObject'] = { 'int16', 47 },
  849.         ['onPlayerDeathNotification'] = { 'int16', 'int16', 'int8', 55 },
  850.         ['onSetMapIcon'] = { 'int8', 'vector3d', 'int8', 'int32', 'int8', 56 },
  851.         ['onRemoveVehicleComponent'] = { 'int16', 'int16', 57 },
  852.         ['onRemove3DTextLabel'] = { 'int16', 58 },
  853.         ['onPlayerChatBubble'] = { 'int16', 'int32', 'float', 'int32', 'string8', 59 },
  854.         ['onUpdateGlobalTimer'] = { 'int32', 60 },
  855.         ['onShowDialog'] = { 'int16', 'int8', 'string8', 'string8', 'string8', 'encodedString4096', 61 },
  856.         ['onDestroyPickup'] = { 'int32', 63 },
  857.         ['onLinkVehicleToInterior'] = { 'int16', 'int8', 65 },
  858.         ['onSetPlayerArmour'] = { 'float', 66 },
  859.         ['onSetPlayerArmedWeapon'] = { 'int32', 67 },
  860.         ['onSetSpawnInfo'] = { 'int8', 'int32', 'int8', 'vector3d', 'float', 'Int32Array3', 'Int32Array3', 68 },
  861.         ['onSetPlayerTeam'] = { 'int16', 'int8', 69 },
  862.         ['onPutPlayerInVehicle'] = { 'int16', 'int8', 70 },
  863.         --['onRemovePlayerFromVehicle'] = { 71 },
  864.         ['onSetPlayerColor'] = { 'int16', 'int32', 72 },
  865.         ['onDisplayGameText'] = { 'int32', 'int32', 'string32', 73 },
  866.         --['onForceClassSelection'] = { 74 },
  867.         ['onAttachObjectToPlayer'] = { 'int16', 'int16', 'vector3d', 'vector3d', 75 },
  868.         ['onInitMenu'] = { 76 },
  869.         ['onShowMenu'] = { 'int8', 77 },
  870.         ['onHideMenu'] = { 'int8', 78 },
  871.         ['onCreateExplosion'] = { 'vector3d', 'int32', 'float', 79 },
  872.         ['onShowPlayerNameTag'] = { 'int16', 'bool8', 80 },
  873.         ['onAttachCameraToObject'] = { 'int16', 81 },
  874.         ['onInterpolateCamera'] = { 'bool', 'vector3d', 'vector3d', 'int32', 'int8', 82 },
  875.         ['onGangZoneStopFlash'] = { 'int16', 85 },
  876.         ['onApplyPlayerAnimation'] = { 'int16', 'string8', 'string8', 'bool', 'bool', 'bool', 'bool', 'int32', 86 },
  877.         ['onClearPlayerAnimation'] = { 'int16', 87 },
  878.         ['onSetPlayerSpecialAction'] = { 'int8', 88 },
  879.         ['onSetPlayerFightingStyle'] = { 'int16', 'int8', 89 },
  880.         ['onSetPlayerVelocity'] = { 'vector3d', 90 },
  881.         ['onSetVehicleVelocity'] = { 'bool8', 'vector3d', 91 },
  882.         ['onServerMessage'] = { 'int32', 'string32', 93 },
  883.         ['onSetWorldTime'] = { 'int8', 94 },
  884.         ['onCreatePickup'] = { 'int32', 'int32', 'int32', 'vector3d', 95 },
  885.         ['onMoveObject'] = { 'int16', 'vector3d', 'vector3d', 'float', 'vector3d', 99 },
  886.         ['onEnableStuntBonus'] = { 'bool', 104 },
  887.         ['onTextDrawSetString'] = { 'int16', 'string16', 105 },
  888.         ['onSetCheckpoint'] = { 'vector3d', 'float', 107 },
  889.         ['onCreateGangZone'] = { 'int16', 'vector2d', 'vector2d', 'int32', 108 },
  890.         ['onPlayCrimeReport'] = { 'int16', 'int32', 'int32', 'int32', 'int32', 'vector3d', 112 },
  891.         ['onGangZoneDestroy'] = { 'int16', 120 },
  892.         ['onGangZoneFlash'] = { 'int16', 'int32', 121 },
  893.         ['onStopObject'] = { 'int16', 122 },
  894.         ['onSetVehicleNumberPlate'] = { 'int16', 'string8', 123 },
  895.         ['onTogglePlayerSpectating'] = { 'bool32', 124 },
  896.         ['onSpectatePlayer'] = { 'int16', 'int8', 126 },
  897.         ['onSpectateVehicle'] = { 'int16', 'int8', 127 },
  898.         ['onShowTextDraw'] = { 134 },
  899.         ['onSetPlayerWantedLevel'] = { 'int8', 133 },
  900.         ['onTextDrawHide'] = { 'int16', 135 },
  901.         ['onRemoveMapIcon'] = { 'int8', 144 },
  902.         ['onSetWeaponAmmo'] = { 'int8', 'int16', 145 },
  903.         ['onSetGravity'] = { 'float', 146 },
  904.         ['onSetVehicleHealth'] = { 'int16', 'float', 147 },
  905.         ['onAttachTrailerToVehicle'] = { 'int16', 'int16', 148 },
  906.         ['onDetachTrailerFromVehicle'] = { 'int16', 149 },
  907.         ['onSetWeather'] = { 'int8', 152 },
  908.         ['onSetPlayerSkin'] = { 'int32', 'int32', 153 },
  909.         ['onSetInterior'] = { 'int8', 156 },
  910.         ['onSetCameraPosition'] = { 'vector3d', 157 },
  911.         ['onSetCameraLookAt'] = { 'vector3d', 'int8', 158 },
  912.         ['onSetVehiclePosition'] = { 'int16', 'vector3d', 159 },
  913.         ['onSetVehicleAngle'] = { 'int16', 'float', 160 },
  914.         ['onSetVehicleParams'] = { 'int16', 'int16', 'bool8', 161 },
  915.         --['onSetCameraBehind'] = { 162 },
  916.         ['onChatMessage'] = { 'int16', 'string8', 101 },
  917.         ['onConnectionRejected'] = { 'int8', 130 },
  918.         ['onPlayerStreamOut'] = { 'int16', 163 },
  919.         ['onVehicleStreamIn'] = { 164 },
  920.         ['onVehicleStreamOut'] = { 'int16', 165 },
  921.         ['onPlayerDeath'] = { 'int16', 166 },
  922.         ['onPlayerEnterVehicle'] = { 'int16', 'int16', 'bool8', 26 },
  923.         ['onUpdateScoresAndPings'] = { 'PlayerScorePingMap', 155 },
  924.         ['onSetObjectMaterial'] = { 84 },
  925.         ['onSetObjectMaterialText'] = { 84 },
  926.         ['onSetVehicleParamsEx'] = { 'int16', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 'int8', 24 },
  927.         ['onSetPlayerAttachedObject'] = { 'int16', 'int32', 'bool', 'int32', 'int32', 'vector3d', 'vector3d', 'vector3d', 'int32', 'int32', 113 }
  928.  
  929.     }
  930.     local handler_hook = {
  931.         ['onInitGame'] = true,
  932.         ['onCreateObject'] = true,
  933.         ['onInitMenu'] = true,
  934.         ['onShowTextDraw'] = true,
  935.         ['onVehicleStreamIn'] = true,
  936.         ['onSetObjectMaterial'] = true,
  937.         ['onSetObjectMaterialText'] = true
  938.     }
  939.     local extra = {
  940.         ['PlayerScorePingMap'] = true,
  941.         ['Int32Array3'] = true
  942.     }
  943.         local hook_table = hooks[hook]
  944.     if hook_table then
  945.         local bs = raknetNewBitStream()
  946.         if not handler_hook[hook] then
  947.             local max = #hook_table-1
  948.             if max > 0 then
  949.                 for i = 1, max do
  950.                     local p = hook_table[i]
  951.                     if extra[p] then extra_types[p]['write'](bs, parameters[i])
  952.                     else bs_io[p]['write'](bs, parameters[i]) end
  953.                 end
  954.             end
  955.         else
  956.             if hook == 'onInitGame' then handler.on_init_game_writer(bs, parameters)
  957.             elseif hook == 'onCreateObject' then handler.on_create_object_writer(bs, parameters)
  958.             elseif hook == 'onInitMenu' then handler.on_init_menu_writer(bs, parameters)
  959.             elseif hook == 'onShowTextDraw' then handler.on_show_textdraw_writer(bs, parameters)
  960.             elseif hook == 'onVehicleStreamIn' then handler.on_vehicle_stream_in_writer(bs, parameters)
  961.             elseif hook == 'onSetObjectMaterial' then handler.on_set_object_material_writer(bs, parameters, 1)
  962.             elseif hook == 'onSetObjectMaterialText' then handler.on_set_object_material_writer(bs, parameters, 2) end
  963.         end
  964.         raknetEmulRpcReceiveBitStream(hook_table[#hook_table], bs)
  965.         raknetDeleteBitStream(bs)
  966.     end
  967. end
  968.  
  969. function samp_create_sync_data(sync_type, copy_from_player)
  970.     local ffi = require 'ffi'
  971.     local sampfuncs = require 'sampfuncs'
  972.     -- from SAMP.Lua
  973.     local raknet = require 'samp.raknet'
  974.     --require 'samp.synchronization'
  975.  
  976.     copy_from_player = copy_from_player or true
  977.     local sync_traits = {
  978.         player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
  979.         vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
  980.         passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
  981.         aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
  982.         trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
  983.         unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
  984.         bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
  985.         spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
  986.     }
  987.     local sync_info = sync_traits[sync_type]
  988.     local data_type = 'struct ' .. sync_info[1]
  989.     local data = ffi.new(data_type, {})
  990.     local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
  991.     -- copy player's sync data to the allocated memory
  992.     if copy_from_player then
  993.         local copy_func = sync_info[3]
  994.         if copy_func then
  995.             local _, player_id
  996.             if copy_from_player == true then
  997.                 _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
  998.             else
  999.                 player_id = tonumber(copy_from_player)
  1000.             end
  1001.             copy_func(player_id, raw_data_ptr)
  1002.         end
  1003.     end
  1004.     -- function to send packet
  1005.     local func_send = function()
  1006.         local bs = raknetNewBitStream()
  1007.         raknetBitStreamWriteInt8(bs, sync_info[2])
  1008.         raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
  1009.         raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
  1010.         raknetDeleteBitStream(bs)
  1011.     end
  1012.     -- metatable to access sync data and 'send' function
  1013.     local mt = {
  1014.         __index = function(t, index)
  1015.             return data[index]
  1016.         end,
  1017.         __newindex = function(t, index, value)
  1018.             data[index] = value
  1019.         end
  1020.     }
  1021.     return setmetatable({send = func_send}, mt)
  1022. end
  1023.  
  1024. function ShowHelpMarker(desc)
  1025.     imgui.TextDisabled('(?)')
  1026.     if imgui.IsItemHovered() then
  1027.         imgui.BeginTooltip()
  1028.         imgui.PushTextWrapPos(450.0)
  1029.         imgui.TextUnformatted(desc)
  1030.         imgui.PopTextWrapPos()
  1031.         imgui.EndTooltip()
  1032.     end
  1033. end
  1034.  
  1035. function h.onSendPassengerSync(d)
  1036.     if sync then return false end
  1037. end
  1038.  
  1039. function h.onSendUnoccupiedSync(d)
  1040.     if sync then return false end
  1041. end
  1042.  
  1043. function h.onSendPlayerSync(d)
  1044.     if sync then return false end
  1045. end
  1046.  
  1047. function h.onSetPlayerPos()
  1048.     if sync then return false end
  1049. end
  1050.  
  1051. function h.onRemovePlayerFromVehicle()
  1052.     if sync then return false end
  1053. end
  1054.  
  1055. function h.onSetVehiclePosition()
  1056.     if sync then return false end
  1057. end
Add Comment
Please, Sign In to add comment