Advertisement
Zmajk0

Untitled

Oct 24th, 2020 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. script_name("EnterCrasher (bypass)")
  2. script_author("seven.eXe")
  3.  
  4. local samp = require "samp.events"
  5. local act = false
  6.  
  7. function main()
  8. repeat wait(0) until isSampAvailable()
  9. sampAddChatMessage("SKY CRASHER| {FFFFFF}Loaded. Author: S E V E N", 0xFFFF00)
  10. sampRegisterChatCommand("sky", function()
  11. act = not act
  12. sampAddChatMessage(act and "Sky crasher (Bypass) | {FFFFFF}Activated." or "Sky crasher (Bypass) | {FFFFFF}Deactivated", 0xFFFF00)
  13. end)
  14. end
  15.  
  16. function samp.onPlayerEnterVehicle(playerId, enterId, passenger)
  17. lua_thread.create(function()
  18. if act then
  19. local _, crashedVehicle = sampGetCarHandleBySampVehicleId(enterId)
  20. local vehPos = {getCarCoordinates(crashedVehicle)}
  21. wait(200)
  22. local data = samp_create_sync_data('player')
  23. data.position = {vehPos[1], vehPos[2], vehPos[3]}
  24. data.moveSpeed = {0.4999, 0.4999, 0.4999}
  25. data.send()
  26. local data = samp_create_sync_data('unoccupied')
  27. data.vehicleId = enterId
  28. data.seatId = 0
  29. data.position = {vehPos[1], vehPos[2], vehPos[3] - 0.5}
  30. data.send()
  31. sampAddChatMessage("Sky crasher (Bypass) | [" .. playerId .. "] Crashed.", 0xFFFF00)
  32. end
  33. end)
  34. end
  35.  
  36. function samp_create_sync_data(sync_type, copy_from_player)
  37. local ffi = require 'ffi'
  38. local sampfuncs = require 'sampfuncs'
  39. -- from SAMP.Lua
  40. local raknet = require 'samp.raknet'
  41. require 'samp.synchronization'
  42.  
  43. copy_from_player = copy_from_player or true
  44. local sync_traits = {
  45. player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
  46. vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
  47. passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
  48. aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
  49. trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
  50. unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
  51. bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
  52. spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
  53. }
  54. local sync_info = sync_traits[sync_type]
  55. local data_type = 'struct ' .. sync_info[1]
  56. local data = ffi.new(data_type, {})
  57. local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
  58. -- copy player's sync data to the allocated memory
  59. if copy_from_player then
  60. local copy_func = sync_info[3]
  61. if copy_func then
  62. local _, player_id
  63. if copy_from_player == true then
  64. _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
  65. else
  66. player_id = tonumber(copy_from_player)
  67. end
  68. copy_func(player_id, raw_data_ptr)
  69. end
  70. end
  71. -- function to send packet
  72. local func_send = function()
  73. local bs = raknetNewBitStream()
  74. raknetBitStreamWriteInt8(bs, sync_info[2])
  75. raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
  76. raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
  77. raknetDeleteBitStream(bs)
  78. end
  79. -- metatable to access sync data and 'send' function
  80. local mt = {
  81. __index = function(t, index)
  82. return data[index]
  83. end,
  84. __newindex = function(t, index, value)
  85. data[index] = value
  86. end
  87. }
  88. return setmetatable({send = func_send}, mt)
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement