- 459
- 88
- Версия MoonLoader
- Другое
Lua:
local key = require "vkeys"
local sampev = require 'samp.events'
require 'lib.moonloader'
function msg(arg)
sampAddChatMessage("{FF0000}[Taranka]: ".. arg, -1)
end
local rabota = false
local skor = false
function main()
while not isSampAvailable() do wait(100) end
while true do
wait(0)
if isKeyDown(VK_X) and isKeyJustPressed(VK_Z) then
if isCharInAnyCar(PLAYER_PED) then
if getDriverOfCar(storeCarCharIsInNoSave(1)) ~= 1 then
msg("За руль!")
else
sampSendChat("/limit 30")
rabota = false
skor = true
wait(100)
sendVelo()
wait(100)
if rabota then
printStringNow("Send RPC", 1000)
sendtaran()
wait(100)
sendtaran()
end
wait(1000)
sampSendChat("/limit 0")
rabota = false
skor = false
end
else
msg("Нужно сидеть в машине!")
end
end
end
end
function sendtaran()
local move = 150
local data = samp_create_sync_data('vehicle')
data.keysData = data.keysData + 8
data.moveSpeed = {move, 0, 0}
data.send()
end
function sendVelo() -- длЯ сбива лимита скорости ГошАшов))
local pX,pY,pZ = getCharCoordinates(PLAYER_PED)
local x,y,z = pX+5,pY-5,pZ
local move = 0.1
local data = samp_create_sync_data('vehicle')
data.position = {x, y, z-0.3}
data.keysData = data.keysData + 8
data.moveSpeed = {move, move, move}
data.send()
end
function sampev.onSetVehicleVelocity(turn, pos) --пакет от сервера на установку скорости
if skor then
rabota = true
return false
end
end
function sampev.onRemovePlayerFromVehicle()
if rabota then return false end
end
function sampev.onSetVehiclePos(vid, pos)
if rabota then return false end
end
function sampev.onSendVehicleSync(data)
if rabota then return false end
end
function sampev.onSetPlayerPos(pos)
if rabota then return false end
end
function sampev.onSendPlayerSync(data)
if rabota then return false end
end
function samp_create_sync_data(sync_type, copy_from_player)
local ffi = require 'ffi'
local sampfuncs = require 'sampfuncs'
-- from SAMP.Lua
local raknet = require 'samp.raknet'
require 'samp.synchronization'
copy_from_player = copy_from_player or true
local sync_traits = {
player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
}
local sync_info = sync_traits[sync_type]
local data_type = 'struct ' .. sync_info[1]
local data = ffi.new(data_type, {})
local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
-- copy player's sync data to the allocated memory
if copy_from_player then
local copy_func = sync_info[3]
if copy_func then
local _, player_id
if copy_from_player == true then
_, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
else
player_id = tonumber(copy_from_player)
end
copy_func(player_id, raw_data_ptr)
end
end
-- function to send packet
local func_send = function()
local bs = raknetNewBitStream()
raknetBitStreamWriteInt8(bs, sync_info[2])
raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
raknetDeleteBitStream(bs)
end
-- metatable to access sync data and 'send' function
local mt = {
__index = function(t, index)
return data[index]
end,
__newindex = function(t, index, value)
data[index] = value
end
}
return setmetatable({send = func_send}, mt)
end
По задумки, должно с большой скоростью врезаться в кого-нибудь