- 7
- 0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
- Версия MoonLoader
- Другое
У меня вот есть код как зделать что бы на чекбокс под названием 'Авто альт' срабатывал авто альт тоесть функцыя function Auto()
Хелпер ферма:
require 'lib.moonloader'
local imgui = require 'mimgui'
local ffi = require('ffi')
local encoding = require 'encoding'
sampev = require "samp.events"
local status = false
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new = imgui.new
local rend = new.bool(false)
local texttorend = new.char[256]()
local WinState = new.bool()
local checkboxone = new.bool()
local checkboxone1 = new.bool()
local font = renderCreateFont("Arial", 10, 14)
local inicfg = require 'inicfg'
function Auto()
repeat wait(0) until isSampAvailable()
while true do
wait(450) -- задержка
if status then
local x, y, z = getCharCoordinates(PLAYER_PED)
local result, _, _, _, _, _, _, _, _, _ = Search3Dtext(x, y, z, 3, "{73B461}Для")
if result then
setGameKeyState(21, 255)
wait(5)
setGameKeyState(21, 0)
result = false
end
end
end
end
function Search3Dtext(x, y, z, radius, patern)
local color = 0
local posX = 0.0
local posY = 0.0
local posZ = 0.0
local distance = 0.0
local ignoreWalls = false
local player = -1
local vehicle = -1
local result = false
for id = 0, 2048 do
if sampIs3dTextDefined(id) then
local text2, color2, posX2, posY2, posZ2, distance2, ignoreWalls2, player2, vehicle2 = sampGet3dTextInfoById(id)
if getDistanceBetweenCoords3d(x, y, z, posX2, posY2, posZ2) < radius then
if string.len(patern) ~= 0 then
if string.match(text2, patern, 0) ~= nil then result = true end
else
result = true
end
if result then
text = text2
color = color2
posX = posX2
posY = posY2
posZ = posZ2
distance = distance2
ignoreWalls = ignoreWalls2
player = player2
vehicle = vehicle2
radius = getDistanceBetweenCoords3d(x, y, z, posX, posY, posZ)
end
end
end
end
return result, text, color, posX, posY, posZ, distance, ignoreWalls, player, vehicle
end
imgui.OnFrame(function() return WinState[0] end,
function(player)
imgui.SetNextWindowPos(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(200, 200), imgui.Cond.Always)
imgui.Begin(u8'Рендер', WinState, imgui.WindowFlags.NoResize)
imgui.Checkbox(u8'Авто альт',checkboxone1)
local changed, checked = imgui.Checkbox(u8'Включить', checkboxone)
if changed then
if checked then
rend[0] = true
ffi.copy(texttorend, u8:encode('Для сбора'))
else
rend[0] = false
ffi.fill(texttorend, ffi.sizeof(texttorend), 0)
end
end
imgui.End()
end)
function main()
sampRegisterChatCommand('cmd', function() WinState[0] = not WinState[0] end)
while true do
wait(0)
for id = 0, 2048 do
local result = sampIs3dTextDefined(id)
if result then
local text, color, posX, posY, posZ, distance, ignoreWalls, playerId, vehicleId = sampGet3dTextInfoById(id)
if checkboxone[0] and text:find(u8:decode(ffi.string(texttorend))) and rend[0] then
local wposX, wposY = convert3DCoordsToScreen(posX, posY, posZ)
x2, y2, z2 = getCharCoordinates(PLAYER_PED)
x10, y10 = convert3DCoordsToScreen(x2, y2, z2)
local resX, resY = getScreenResolution()
if wposX < resX and wposY < resY and isPointOnScreen(posX, posY, posZ, 1) then
renderFontDrawText(font, text, wposX, wposY, -1)
end
end
end
end
end
end
function go()
while true do
wait(0)
if checkboxone1[0] and text:find(u8:decode(ffi.string(texttorend))) and rend[0] then
local wposX, wposY = convert3DCoordsToScreen(posX, posY, posZ)
x2, y2, z2 = getCharCoordinates(PLAYER_PED)
x10, y10 = convert3DCoordsToScreen(x2, y2, z2)
local resX, resY = getScreenResolution()
end
end
end