Lua INTELLIGENCY Project - Coord Master for ARZ - DRP - ERP

damag

Женюсь на официантке в моем любимом баре
Проверенный
1,152
1,191
Мог бы хотя бы такой сделать, а телепорт на 3-и метра
0_0

 

Madjestik

Известный
140
123
Lua:
local q = require 'lib.samp.events'
local samp = require 'lib.samp.events'
local vector = require 'vector3d'
local tp, sync = false, false
local tpCount, timer = 0, 0


function main()
    while not isSampAvailable() do wait(0) end
    sampAddChatMessage("{808080}[PustovalovTP]: {FFFFFF}Succesfull loaded.", 0xFFFFFF)
    sampAddChatMessage("{808080}[PustovalovTP]: {FFFFFF} Cmd: /ayetp - tp in mark; /acc - tp in checkВ", 0xFFFFFF)
    end
function tp()
sampRegisterChatCommand('ayetp')
    lua_thread.create(function()
        if tp then return sampAddChatMessage('уже телепортируемсІ§', -1) end
            blip, blipX, blipY, blipZ = getTargetBlipCoordinatesFixed()
            if blip then
                sync = true
                charPosX, charPosY, charPosZ = getCharCoordinates(playerPed)
                local distan = getDistanceBetweenCoords3d(blipX, blipY, charPosZ, charPosX, charPosY, charPosZ)
                if distan < 23 then return setCharCoordinates(playerPed, blipX, blipY, blipZ) end
                setCharCoordinates(playerPed, blipX, blipY, blipZ)
                lockPlayerControl(true)
                tp = true
                printStringNow('~y~iSetPlayerPos: ~p~true', 4000)
            end
        end)
    end)
    
function check()
    sampRegisterChatCommand('acc', function()
    lua_thread.create(function()
        if tp then return sampAddChatMessage('уже телепортируемсІ', -1) end
            blip, blipX, blipY, blipZ = SearchMarker(blipX, blipY, blipZ)
            if blip then
                sync = true
                charPosX, charPosY, charPosZ = getCharCoordinates(playerPed)
                local distan = getDistanceBetweenCoords3d(blipX, blipY, charPosZ, charPosX, charPosY, charPosZ)
                if distan < 23 then return setCharCoordinates(playerPed, blipX, blipY, blipZ) end
                setCharCoordinates(playerPed, blipX, blipY, blipZ)
                lockPlayerControl(true)
                tp = true
                wait(2000)
                printStringNow('~y~iSetPlayerPos: ~p~true', 4000)
            end
        end)
    end)
        while true do wait(225)
            if os.clock() - timer > 0 and sync then
              timer, tpCount = 0, 0
              sync = true
              sampForceOnfootSync()
              sync = true
            end
            if tp then
                if getDistanceBetweenCoords3d(blipX, blipY, blipZ, charPosX, charPosY, charPosZ) > 15 then
                    vectorX = blipX - charPosX
                    vectorY = blipY - charPosY
                    vectorZ = blipZ - charPosZ
                    local vec = vector(vectorX, vectorY, vectorZ)
                    vec:normalize()
                    charPosX = charPosX + vec.x * 15
                    charPosY = charPosY + vec.y * 15
                    charPosZ = charPosZ + vec.z * 15
                    sendOnfootSync(charPosX, charPosY, charPosZ)
                    sendOnfootSync(charPosX, charPosY, charPosZ)
                    
                    tpCount = tpCount + 1
                    if tpCount == 99 then
                    sampForceOnfootSync()
                    sendOnfootSync(charPosX, charPosY, charPosZ)
                    printStringNow('~y~iSetPlayerPos: ~g~true', 434)
                      sendOnfootSync(charPosX, charPosY + 25, charPosZ - 70)
                      wait(1828)
                       sampForceOnfootSync()
                       sendOnfootSync(charPosX, charPosY, charPosZ)
                       wait(2000)
                       sendOnfootSync(charPosX, charPosY, charPosZ)
                      sampForceOnfootSync()
                      wait(228)
                      tpCount = 0
                      printStringNow('~y~iSetPlayerPos: ~r~false', 434)
                      sendOnfootSync(charPosX, charPosY, charPosZ)
                    end
                else
                  sendOnfootSync(charPosX, charPosY, charPosZ + 2)
                  printStringNow('~y~iSetPlayerPos: ~b~false', 898)
                  sendOnfootSync(charPosX, charPosY + 55, charPosZ + 3)
                  sync = true
                  sendOnfootSync(charPosX, charPosY, charPosZ + 2)
                  wait(1000)
                  printStringNow("~>~ ~p~successful ~s~teleport ~<~",2500)
                  addOneOffSound(0.0, 0.0, 0.0, 1139)
                  sync = true
                  sendOnfootSync(charPosX, charPosY, charPosZ + 2)
                  sync = false
                  wait(75)
                  setCharCoordinates(playerPed, blipX, blipY, blipZ + 1)
                  tp = false
                  lockPlayerControl(false)
                  timer, tpCount = 0, 0
                end
            end
        end
    wait(-1)
end



function q.onSetPlayerPos(p)
    if sync then
        timer = os.clock()
        return false
    end
end

function q.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.499999, -0.499999, -0.499999}
    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 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 = 0xC7F248 + 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
 

cheremuxa

Известный
Автор темы
430
200
Lua:
local q = require 'lib.samp.events'
local samp = require 'lib.samp.events'
local vector = require 'vector3d'
local tp, sync = false, false
local tpCount, timer = 0, 0


function main()
    while not isSampAvailable() do wait(0) end
    sampAddChatMessage("{808080}[PustovalovTP]: {FFFFFF}Succesfull loaded.", 0xFFFFFF)
    sampAddChatMessage("{808080}[PustovalovTP]: {FFFFFF} Cmd: /ayetp - tp in mark; /acc - tp in checkВ", 0xFFFFFF)
    end
function tp()
sampRegisterChatCommand('ayetp')
    lua_thread.create(function()
        if tp then return sampAddChatMessage('уже телепортируемсІ§', -1) end
            blip, blipX, blipY, blipZ = getTargetBlipCoordinatesFixed()
            if blip then
                sync = true
                charPosX, charPosY, charPosZ = getCharCoordinates(playerPed)
                local distan = getDistanceBetweenCoords3d(blipX, blipY, charPosZ, charPosX, charPosY, charPosZ)
                if distan < 23 then return setCharCoordinates(playerPed, blipX, blipY, blipZ) end
                setCharCoordinates(playerPed, blipX, blipY, blipZ)
                lockPlayerControl(true)
                tp = true
                printStringNow('~y~iSetPlayerPos: ~p~true', 4000)
            end
        end)
    end)
   
function check()
    sampRegisterChatCommand('acc', function()
    lua_thread.create(function()
        if tp then return sampAddChatMessage('уже телепортируемсІ', -1) end
            blip, blipX, blipY, blipZ = SearchMarker(blipX, blipY, blipZ)
            if blip then
                sync = true
                charPosX, charPosY, charPosZ = getCharCoordinates(playerPed)
                local distan = getDistanceBetweenCoords3d(blipX, blipY, charPosZ, charPosX, charPosY, charPosZ)
                if distan < 23 then return setCharCoordinates(playerPed, blipX, blipY, blipZ) end
                setCharCoordinates(playerPed, blipX, blipY, blipZ)
                lockPlayerControl(true)
                tp = true
                wait(2000)
                printStringNow('~y~iSetPlayerPos: ~p~true', 4000)
            end
        end)
    end)
        while true do wait(225)
            if os.clock() - timer > 0 and sync then
              timer, tpCount = 0, 0
              sync = true
              sampForceOnfootSync()
              sync = true
            end
            if tp then
                if getDistanceBetweenCoords3d(blipX, blipY, blipZ, charPosX, charPosY, charPosZ) > 15 then
                    vectorX = blipX - charPosX
                    vectorY = blipY - charPosY
                    vectorZ = blipZ - charPosZ
                    local vec = vector(vectorX, vectorY, vectorZ)
                    vec:normalize()
                    charPosX = charPosX + vec.x * 15
                    charPosY = charPosY + vec.y * 15
                    charPosZ = charPosZ + vec.z * 15
                    sendOnfootSync(charPosX, charPosY, charPosZ)
                    sendOnfootSync(charPosX, charPosY, charPosZ)
                   
                    tpCount = tpCount + 1
                    if tpCount == 99 then
                    sampForceOnfootSync()
                    sendOnfootSync(charPosX, charPosY, charPosZ)
                    printStringNow('~y~iSetPlayerPos: ~g~true', 434)
                      sendOnfootSync(charPosX, charPosY + 25, charPosZ - 70)
                      wait(1828)
                       sampForceOnfootSync()
                       sendOnfootSync(charPosX, charPosY, charPosZ)
                       wait(2000)
                       sendOnfootSync(charPosX, charPosY, charPosZ)
                      sampForceOnfootSync()
                      wait(228)
                      tpCount = 0
                      printStringNow('~y~iSetPlayerPos: ~r~false', 434)
                      sendOnfootSync(charPosX, charPosY, charPosZ)
                    end
                else
                  sendOnfootSync(charPosX, charPosY, charPosZ + 2)
                  printStringNow('~y~iSetPlayerPos: ~b~false', 898)
                  sendOnfootSync(charPosX, charPosY + 55, charPosZ + 3)
                  sync = true
                  sendOnfootSync(charPosX, charPosY, charPosZ + 2)
                  wait(1000)
                  printStringNow("~>~ ~p~successful ~s~teleport ~<~",2500)
                  addOneOffSound(0.0, 0.0, 0.0, 1139)
                  sync = true
                  sendOnfootSync(charPosX, charPosY, charPosZ + 2)
                  sync = false
                  wait(75)
                  setCharCoordinates(playerPed, blipX, blipY, blipZ + 1)
                  tp = false
                  lockPlayerControl(false)
                  timer, tpCount = 0, 0
                end
            end
        end
    wait(-1)
end



function q.onSetPlayerPos(p)
    if sync then
        timer = os.clock()
        return false
    end
end

function q.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.499999, -0.499999, -0.499999}
    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 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 = 0xC7F248 + 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
и че это