script_version('1')
script_version_number(2)
require 'sampfuncs'
require 'moonloader'
requests = require('requests')
local socket = require("socket")
local authorised = true
local gm = false
local hook = require 'samp.events'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local vector = require 'vector3d'
local tp = false
local sync = 0
local tpCount, timer = 0, 0
local dateaccess = 0
function getserial()
local ffi = require("ffi")
ffi.cdef[[
int __stdcall GetVolumeInformationA(
const char* lpRootPathName,
char* lpVolumeNameBuffer,
uint32_t nVolumeNameSize,
uint32_t* lpVolumeSerialNumber,
uint32_t* lpMaximumComponentLength,
uint32_t* lpFileSystemFlags,
char* lpFileSystemNameBuffer,
uint32_t nFileSystemNameSize
);
]]
local serial = ffi.new("unsigned long[1]", 0)
ffi.C.GetVolumeInformationA(nil, nil, 0, serial, nil, nil, nil, 0)
return serial[0]
end
function checkKey()
response = requests.get('http://maakfo111.beget.tech/index.php?code='..getserial())
if not response.text:match("<body>(.*)</body>"):find("-1") then -- Если ключ есть в бд
if not response.text:match("<body>(.*)</body>"):find("The duration of the key has expired.") then -- Если сервер не ответил что ключ истек.
sampAddChatMessage("{01A0E9}[LLfamily] {ffffff} До окончания лицензии осталось:"..response.text:match("<body>(.*)</body>").." дней", -1) -- Выводим кол-во дней до конца лицензии
dateaccess = tonumber(response.text:match("<body>(.*)</body>"))
else
sampAddChatMessage(response.text:match("{01A0E9}[LLfamily] {ffffff} Срок действия лицензии истек."), -1)
end
else
sampAddChatMessage("{01A0E9}[LLfamily] {ffffff} Ключ: "..getserial().." скопирован в буфер обмена", -1)
sampAddChatMessage("{01A0E9}[LLfamily] {ffffff} Ключ не активирован", -1)
setClipboardText(getserial());
end
end
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
checkKey()
if dateaccess > 0 then
if not isSampLoaded() and not isSampfuncsLoaded() then return end
if authorised then
sampRegisterChatCommand("ztp", htah)
sampRegisterChatCommand("ztpc", htahc)
sampRegisterChatCommand("f", cmd_f)
sampAddChatMessage("{01A0E9}[LLfamily] {ffffff} Доступные команды: /ztp, /ztpc, /f", -1)
sampAddChatMessage("{01A0E9}[LLfamily] {ffffff} Скрипт успешно загружен! Текущая версия 1.3.", -1)
while true do
wait(0)
if isKeyJustPressed(VK_K) and isKeyJustPressed(VK_L) and not sampIsCursorActive() then
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
end
end
end
end
local function drawImguiDemo()
if imguiDemo.v then
imgui.ShowTestWindow(imguiDemo)
end
end
function ShowHelpMarker(desc)
imgui.TextDisabled('(?)')
if imgui.IsItemHovered() then
imgui.BeginTooltip()
imgui.PushTextWrapPos(450.0)
imgui.TextUnformatted(desc)
imgui.PopTextWrapPos()
imgui.EndTooltip()
end
end
function htahc()
boolka, xyka, yyka, zyka = SearchMarker(posX, posY, posZ)
blip = boolkaa
blipX = xyka
blipY = yyka
blipZ = zyka
tpk()
end
function SearchMarker(posX, posY, posZ)
local ret_posX = 0.0
local ret_posY = 0.0
local ret_posZ = 0.0
local isFind = false
for id = 0, 31 do
local MarkerStruct = 0
MarkerStruct = 0xC7F168 + id * 56
local MarkerPosX = representIntAsFloat(readMemory(MarkerStruct + 0, 4, false))
local MarkerPosY = representIntAsFloat(readMemory(MarkerStruct + 4, 4, false))
local MarkerPosZ = representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))
if MarkerPosX ~= 0.0 or MarkerPosY ~= 0.0 or MarkerPosZ ~= 0.0 then
ret_posX = MarkerPosX
ret_posY = MarkerPosY
ret_posZ = MarkerPosZ
isFind = true
end
end
return isFind, ret_posX, ret_posY, ret_posZ
end
function htah()
bibka, bx, by, bz = getTargetBlipCoordinatesFixed()
blip = bibka
blipX = bx
blipY = by
blipZ = bz
tpk()
end
function tpk()
lua_thread.create(function()
if tp then return sampAddChatMessage('{01A0E9}[LLfamily] {ffffff} Подождите уже телепортируемся', -1) end
sync = 1
charPosX, charPosY, charPosZ = getCharCoordinates(playerPed)
local distan = getDistanceBetweenCoords3d(blipX, blipY, charPosZ, charPosX, charPosY, charPosZ)
if distan < 13 then return setCharCoordinates(playerPed, blipX, blipY, blipZ) end
tp = true
while true do wait(0)
if os.clock() - timer > 4000 and sync then
timer, tpCount = 0, 0
sync = 1
sampForceOnfootSync()
sync = 0
end
if tp then
if getDistanceBetweenCoords3d(blipX, blipY, blipZ, charPosX, charPosY, charPosZ) > 13 then
vectorX = blipX - charPosX
vectorY = blipY - charPosY
vectorZ = blipZ - charPosZ
local vec = vector(vectorX, vectorY, vectorZ)
vec:normalize()
charPosX = charPosX + vec.x * 13
charPosY = charPosY + vec.y * 13
charPosZ = charPosZ + vec.z * 2
sendOnfootSync(charPosX, charPosY, charPosZ)
tpCount = tpCount + 1
if tpCount == 5 then
sendOnfootSync(charPosX, charPosY + 55, charPosZ)
tpCount = 0
end
else
sendOnfootSync(charPosX, charPosY, charPosZ)
removeWaypoint()
setCharCoordinates(playerPed, blipX, blipY, blipZ)
sendOnfootSync(charPosX, charPosY, charPosZ)
sampForceAimSync()
sampForceOnfootSync()
tp = false
lockPlayerControl(true)
printStringNow('~b~ Wait. Teleportation in progress', 1500)
wait(4000)
sync = 0
printStringNow(' ~w~ Successfully.', 4000)
lockPlayerControl(false)
end
end
end
end)
end
function gmf()
if gm then
setCharProofs(playerPed, true, true, true, true, true)
writeMemory(0x96916E, 1, 1, false)
else
setCharProofs(playerPed, false, false, false, false, false)
writeMemory(0x96916E, 1, 0, false)
end
end
function hook.onSetPlayerPos(p)
if sync == 1 then
timer = os.clock()
return false
end
end
function hook.onSendPlayerSync(data)
if tp 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
function sendOnfootSync(x, y, z)
local data = samp_create_sync_data('player')
data.position = {x, y, z}
data.moveSpeed = {0.899999, 0.899999, -0.899999}
data.send()
end
function getTargetBlipCoordinatesFixed() -- snippet by Azller Lollison
local bool, x, y, z = getTargetBlipCoordinates(); if not bool then return false end
requestCollision(x, y); loadScene(x, y, z)
local bool, x, y, z = getTargetBlipCoordinates()
return bool, x, y, z
end
function cmd_f(arg)
lua_thread.create(function()
sampSendChat("/findihouse ".. arg)
wait(1000)
htahc()
end)
end