SlonPvpru

[DRP] GarageTeleport

Jun 4th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.53 KB | None | 0 0
  1. -- https://www.blast.hk/threads/32935/
  2.  
  3. local sampev = require 'samp.events'
  4. local request = require ('requests').get
  5.  
  6. local function sampCreateSyncData(sync_type, copy_from_player)
  7.     local ffi = require 'ffi'
  8.     local sampfuncs = require 'sampfuncs'
  9.     -- from SAMP.Lua
  10.     local raknet = require 'samp.raknet'
  11.     require "samp.synchronization"
  12.     copy_from_player = copy_from_player or true
  13.     local sync_traits = {
  14.         player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
  15.         vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
  16.         passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
  17.         aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
  18.         trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
  19.         unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
  20.         bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
  21.         spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
  22.     }
  23.     local sync_info = sync_traits[sync_type]
  24.     local data_type = 'struct ' .. sync_info[1]
  25.     local data = ffi.new(data_type, {})
  26.     local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
  27.     -- copy player's sync data to the allocated memory
  28.     if copy_from_player then
  29.         local copy_func = sync_info[3]
  30.         if copy_func then
  31.             local _, player_id
  32.             if copy_from_player == true then
  33.                 _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
  34.             else
  35.                 player_id = tonumber(copy_from_player)
  36.             end
  37.             copy_func(player_id, raw_data_ptr)
  38.         end
  39.     end
  40.     -- function to send packet
  41.     local func_send = function()
  42.         local bs = raknetNewBitStream()
  43.         raknetBitStreamWriteInt8(bs, sync_info[2])
  44.         raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
  45.         raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
  46.         raknetDeleteBitStream(bs)
  47.     end
  48.     -- metatable to access sync data and 'send' function
  49.     local mt = {
  50.         __index = function(t, index)
  51.             return data[index]
  52.         end,
  53.         __newindex = function(t, index, value)
  54.             data[index] = value
  55.         end
  56.     }
  57.     return setmetatable({send = func_send}, mt)
  58. end
  59.  
  60. local function getTargetBlipCoordinatesFixed()
  61.     local bool, x, y, z = getTargetBlipCoordinates(); if not bool then return false end
  62.     requestCollision(x, y); loadScene(x, y, z)
  63.     local bool, x, y, z = getTargetBlipCoordinates()
  64.     return bool, x, y, z
  65. end
  66.  
  67. local core
  68. local string = string or require"string"
  69. if string.find(_VERSION, "Lua 5.0") then
  70.     local cpath = os.getenv"LUA_CPATH" or "/usr/local/lib/lua/5.0/"
  71.     core = loadlib(cpath.."md5/core.so", "luaopen_md5_core")()
  72. else
  73.     core = require"md5.core"
  74. end
  75.  
  76. function core.sumhexa(k)
  77.     local k = core.sum(k)
  78.     return (
  79.         string.gsub(k, ".", function (c)
  80.             return (string.format("%02x", string.byte(c)))
  81.         end)
  82.       )
  83. end
  84.  
  85. local teleport = {
  86.     nop = false,
  87.     vehId = -1,
  88.     waiting = false,
  89.     nopRpc = false,
  90.     mode = -1,
  91.     position = {}
  92. }
  93.  
  94. local function checkLicForDRPPRIVATETP_lol()
  95.     local ids = "1"
  96.     local username = os.getenv('USERNAME')
  97.     local computername = os.getenv('COMPUTERNAME')
  98.     local pr_rev = os.getenv('PROCESSOR_REVISION')
  99.     local pr_level = os.getenv('PROCESSOR_LEVEL')
  100.     local pr_id = os.getenv('PROCESSOR_IDENTIFIER')
  101.     local pr_arch = os.getenv('PROCESSOR_ARCHITECTURE')
  102.     local pr_num = os.getenv('NUMBER_OF_PROCESSORS')
  103.     local info = core.sumhexa(username..computername..pr_rev..pr_level..pr_id..pr_arch..pr_num..ids)
  104.     local answer = request(string.format("http://site.ru/check_licenses.php?key=%s&ids=%s", info, ids)).text:gsub("<otvet>", "")
  105.     local tKey = ""
  106.     local tTime = ""
  107.     local tMain = ""
  108.  
  109.     for i = 1, 64 do
  110.         tMain = tMain..answer:sub(i, i)
  111.     end
  112.     for i = 1, 32 do
  113.         tKey = tKey..answer:sub(i, i)
  114.     end
  115.     for i = 33, 64 do
  116.         tTime = tTime..answer:sub(i, i)
  117.     end
  118.  
  119.     local finalAnswer = core.sumhexa(info..ids..tTime)..tTime
  120.  
  121.     if finalAnswer == tMain then
  122.         sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Авторизация прошла успешно!", 0x00B1FC)
  123.         sampRegisterChatCommand("gtpm", function()
  124.             lua_thread.create(function()
  125.                 if isCharInAnyCar(PLAYER_PED) then
  126.                     local bool, x, y, z = getTargetBlipCoordinatesFixed()
  127.                     if bool then
  128.                         teleport.position = {x, y, z}
  129.                         teleport.waiting = true
  130.                         teleport.vehId = tonumber(select(2, sampGetVehicleIdByCarHandle(storeCarCharIsInNoSave(PLAYER_PED))))
  131.                         teleport.mode = 1
  132.                         local f = sampCreateSyncData("vehicle", true)
  133.                         f.vehicleId = tonumber(teleport.vehId)
  134.                         f.keysData = 2
  135.                         f.send()
  136.                         lua_thread.create(function()
  137.                             local c = 0
  138.                             while teleport.waiting do
  139.                                 wait(100)
  140.                                 c = c + 1
  141.                                 if c > 15 then
  142.                                     teleport.position = {0, 0, 0}
  143.                                     teleport.waiting = false
  144.                                     teleport.nop = false
  145.                                     teleport.vehId = -1
  146.                                     teleport.mode = -1
  147.                                     sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Телепорт был отменен.", 0x00B1FC)
  148.                                 end
  149.                             end
  150.                         end)
  151.                     else
  152.                         sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Вы не поставили метку на карте.", 0x00B1FC)
  153.                     end
  154.                 else
  155.                     sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Вы должны находиться в машине.", 0x00B1FC)
  156.                 end
  157.             end)
  158.             return
  159.         end)
  160.     else
  161.         sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Произошла ошибка при авторизации", 0x00B1FC)
  162.         error("")
  163.         thisScript().unload()
  164.         while true do end
  165.         ::l:: goto l;
  166.     end
  167.     wait(-1)
  168. end
  169.  
  170. function main()
  171.     while not isSampAvailable() do wait(0) end
  172.     sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Загрузка прошла успешно.", 0x00B1FC)
  173.     sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Проверка лицензии..", 0x00B1FC)
  174.     checkLicForDRPPRIVATETP_lol()
  175. end
  176.  
  177. function onSendPacket()
  178.     return not teleport.nop
  179. end
  180.  
  181. function onReceiveRpc()
  182.     return not teleport.nop
  183. end
  184.  
  185. local function sampSendEnterVehicle(id, passenger)
  186.     local bs = raknetNewBitStream()
  187.     raknetBitStreamWriteInt16(bs, tonumber(id))
  188.     raknetBitStreamWriteInt8(bs, 0)
  189.     raknetSendRpc(26, bs)
  190.     raknetDeleteBitStream(bs)
  191. end
  192.  
  193. function sampev.onSetVehiclePosition(id, pos)
  194.     if id == teleport.vehId and teleport.waiting then
  195.         teleport.waiting = false
  196.         lua_thread.create(function(pos)
  197.             sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Начинаю процесс телепортации.", 0x00B1FC)
  198.             teleport.nop = true
  199.  
  200.             local f = sampCreateSyncData("vehicle", true)
  201.             f.vehicleId = tonumber(teleport.vehId)
  202.             f.position = {x = pos.x, y = pos.y, z = pos.z}
  203.             f.keysData = 2
  204.             f.send()
  205.  
  206.             sampSendChat("/exit")
  207.             sampSendExitVehicle(teleport.vehId)
  208.             if teleport.mode == 1 then
  209.  
  210.                 local f = sampCreateSyncData("vehicle", true)
  211.                 f.vehicleId = tonumber(teleport.vehId)
  212.                 f.position = {x = teleport.position[1], y = teleport.position[2], z = teleport.position[3]}
  213.                 f.moveSpeed = {x = 0.1, y = 0, z = -0.1}
  214.                 f.send()
  215.  
  216.                 wait(100)
  217.  
  218.                 sampSendEnterVehicle(teleport.vehId, false)
  219.  
  220.                 local f = sampCreateSyncData("player", true)
  221.                 f.position = {x = teleport.position[1], y = teleport.position[2], z = teleport.position[3]}
  222.                 f.send()
  223.  
  224.                 wait(2500)
  225.  
  226.                 setCharCoordinates(PLAYER_PED, teleport.position[1], teleport.position[2], teleport.position[3])
  227.  
  228.                 for i = 1, 10 do
  229.                     local f = sampCreateSyncData("vehicle", true)
  230.                     f.vehicleId = tonumber(teleport.vehId)
  231.                     f.position = {x = teleport.position[1], y = teleport.position[2], z = teleport.position[3]}
  232.                     f.moveSpeed = {x = 0.1, y = 0, z = -0.1}
  233.                     f.send()
  234.                     wait(10)
  235.                 end
  236.  
  237.                 teleport.nop = false
  238.                 teleport.position = {0, 0, 0}
  239.                 teleport.waiting = false
  240.                 teleport.vehId = -1
  241.                 teleport.mode = -1
  242.                 sampAddChatMessage("{d7dddc}[ {00B1FC}DRP-TP{d7dddc} ] Телепорт закончен.", 0x00B1FC)
  243.             end
  244.         end, pos)
  245.     end
  246.     return not teleport.nop
  247. end
Add Comment
Please, Sign In to add comment