SA:MP переделайте на биндик, прошу

schengen

Новичок
Автор темы
3
0
Версия SA-MP
  1. 0.3.7-R3
Просьба переделать sampRegisterChatCommand на то, чтобы скрипт можно было открывать по нажатию клавиши (либо PAUSE/BREAK, либо XBUTTON1 либо XBUTTON2), буду весьма благодарен. Также было бы славно если при заходе на сервер будет надпись "AFK without ESC loaded".


Lua:
require 'lib.moonloader'
require 'sampfuncs'
require 'vkeys'
local memory = require 'memory'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local svWork = false
local arr = {}

function main()
    if not isSampLoaded() and not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('sv', sv)
    wait(-1)
end

function sv()
    svWork = not svWork
    lockPlayerControl(svWork)
    if svWork then
        memory.write(0x747FB6, 0x1, 1, true)
        memory.write(0x74805A, 0x1, 1, true)
        memory.fill(0x74542B, 0x90, 8, true)
        memory.fill(0x53EA88, 0x90, 6, true)
        sampAddChatMessage('AFK on', -1)
    else
        memory.write(0x747FB6, 0x0, 1, true)
        memory.write(0x74805A, 0x0, 1, true)
        arr = { 0x50, 0x51, 0xFF, 0x15, 0x00, 0x83, 0x85, 0x00 }
        memset(0x74542B)
        arr = { 0x0F, 0x84, 0x7B, 0x01, 0x00, 0x00 }
        memset(0x53EA88)
        sampAddChatMessage('AFK off', -1)
    end
end

function memset(addr)
    for i = 1, #arr do
        memory.write(addr + i - 1, arr[i], 1, true)
    end
end
 

Вложения

  • sv.lua
    1.1 KB · Просмотры: 0

Улиточка

Потрачен
582
189
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Не думаю что это поможет, там либо сам код перекраивать чтобы функции работали по другому, либо правильно бинд кнопки воткнуть
тебе любая нейронка это с первого раза переделает.
 

менталейшн

Известный
1,037
186
Не думаю что это поможет, там либо сам код перекраивать чтобы функции работали по другому, либо правильно бинд кнопки воткнуть
даст больше строк коде чем человек но сделает в разы быстрее т.к не каждый будет открывать тему и переделывать твой код за тебя
 

minxty

Известный
1,262
1,120
Lua:
local memory = require 'memory'

local svWork = false
local arr = {}

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('sv', sv)
    while true do wait(0)
        if isKeyJustPressed(0x05) and not sampIsCursorActive() then
            -- 0x05 - VK_XBUTTON1
            -- 0x06 - VK_XBUTTON2
            -- 0x13 - VK_PAUSE
            sv()
        end
    end
end

function sv()
    svWork = not svWork
    lockPlayerControl(svWork)
    if svWork then
        memory.write(0x747FB6, 0x1, 1, true)
        memory.write(0x74805A, 0x1, 1, true)
        memory.fill(0x74542B, 0x90, 8, true)
        memory.fill(0x53EA88, 0x90, 6, true)
        sampAddChatMessage('AFK on', -1)
    else
        memory.write(0x747FB6, 0x0, 1, true)
        memory.write(0x74805A, 0x0, 1, true)
        arr = { 0x50, 0x51, 0xFF, 0x15, 0x00, 0x83, 0x85, 0x00 }
        memset(0x74542B)
        arr = { 0x0F, 0x84, 0x7B, 0x01, 0x00, 0x00 }
        memset(0x53EA88)
        sampAddChatMessage('AFK off', -1)
    end
end

function memset(addr)
    for i = 1, #arr do
        memory.write(addr + i - 1, arr[i], 1, true)
    end
end
 
  • Нравится
Реакции: schengen