Луа скрипт при нажатии клавиш эмулирует на рабочий стол как это исправить

Kagacel Rik

Новичок
Автор темы
5
0
Версия SA-MP
  1. 0.3.7-R2
вот сам скрипт

---------------------------------------------------------------------------

require "lib.moonloader"
local ffi = require "ffi"
ffi.cdef[[
void keybd_event(int keycode, int scancode, int flags, int extra);
]]
local imgui = require 'imgui'
local game_keys = require 'game.keys'
local q = require 'lib.samp.events'
local imgui = require 'imgui'
local encoding = require 'encoding'
local inicfg = require 'inicfg'
local memory = require 'memory'
---------------------------------------------------------------------------

function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
sampRegisterChatCommand("razebpp", cmd_bot)

local saveX = {}
local saveY = {}
local saveZ = {}
while true do
wait(0)
if isPlayerPlaying(playerHandle) and enabled then
---------------------------------------------------------------------------
EmulateKey(VK_H, true)
wait(150)
EmulateKey(VK_H, false)
wait(100)
EmulateKey(VK_HOME, true)
wait(150)
EmulateKey(VK_HOME, false)
wait(55)
EmulateKey(VK_X, true)
wait(55)
EmulateKey(VK_X, false)
---------------------------------------------------------------------------
end
end
end



--------------------------- STANDART FUNCTIONS ---------------------------

function BeginToPoint(x, y, z, radius, move_code, isSprint)
repeat
local posX, posY, posZ = GetCoordinates()
SetAngle(x, y, z)
MovePlayer(move_code, isSprint)
local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
wait(0)
until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
setGameKeyState(1, move_code)
--[[255 - обычный бег назад
-255 - обычный бег вперед
65535 - идти шагом вперед
-65535 - идти шагом назад]]
if isSprint then setGameKeyState(16, 255) end
end

function SetAngle(x, y, z)
local posX, posY, posZ = GetCoordinates()
local pX = x - posX
local pY = y - posY
local zAngle = getHeadingFromVector2d(pX, pY)

if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
setCarHeading(car, zAngle)
else
setCharHeading(playerPed, zAngle)
end

restoreCameraJumpcut()
end

function GetCoordinates()
if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
return getCarCoordinates(car)
else
return getCharCoordinates(playerPed)
end
end

function cmd_bot(param)
enabled = not enabled
if enabled then
sampAddChatMessage(string.format("[%s]: Љктивирован", thisScript().name), 0x40FF40)
else
sampAddChatMessage(string.format("[%s]: ?еактивирован", thisScript().name), 0xFF4040)
end
end

-- Teleport from ClickWarp (by FYP)
function teleportPlayer(x, y, z)
if isCharInAnyCar(playerPed) then
setCharCoordinates(playerPed, x, y, z)
end
setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end

function setCharCoordinatesDontResetAnim(char, x, y, z)
if doesCharExist(char) then
local ptr = getCharPointer(char)
setEntityCoordinates(ptr, x, y, z)
end
end

function setEntityCoordinates(entityPtr, x, y, z)
if entityPtr ~= 0 then
local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
if matrixPtr ~= 0 then
local posPtr = matrixPtr + 0x30
writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
writeMemory(posPtr + 4, 4, representFloatAsInt:good:, false) --Y
writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
end
end
end
-- End Teleport code

--------------------------- ADDITIONAL FUNCTIONS ---------------------------



function EmulateKey(key, isDown)
if not isDown then
ffi.C.keybd_event(key, 0, 2, 0)
else
ffi.C.keybd_event(key, 0, 0, 0)
end
end
 

Похожие темы

  1. Ответы
    22
    Просмотры
    24K
  2. У
    Ответы
    65
    Просмотры
    41K