код

Flufick

Известный
Автор темы
263
17
привет, помогите сделать чтобы в данном скрипте чат не открывался на т, сам делаю пытюсь, пропадает ряд функций
 

Вложения

  • InputHelper.lua
    4 KB · Просмотры: 0

mooh

Известный
169
49
Так?
Lua:
script_name('Input Helper')
script_version_number(1)
script_moonloader(020)
script_author('DonHomka')
script_description('Help to game in samp :)')

local ffi = require("ffi")
require 'lib.moonloader'
require 'lib.sampfuncs'
local mem = require "memory"
ffi.cdef[[
    short GetKeyState(int nVirtKey);
    bool GetKeyboardLayoutNameA(char* pwszKLID);
    int GetLocaleInfoA(int Locale, int LCType, char* lpLCData, int cchData);
]]
local BuffSize = 32
local KeyboardLayoutName = ffi.new("char[?]", BuffSize)
local LocalInfo = ffi.new("char[?]", BuffSize)
chars = {
    ["й"] = "q", ["ц"] = "w", ["у"] = "e", ["к"] = "r", ["е"] = "t", ["н"] = "y", ["г"] = "u", ["ш"] = "i", ["щ"] = "o", ["з"] = "p", ["х"] = "[", ["ъ"] = "]", ["ф"] = "a",
    ["ы"] = "s", ["в"] = "d", ["а"] = "f", ["п"] = "g", ["р"] = "h", ["о"] = "j", ["л"] = "k", ["д"] = "l", ["ж"] = ";", ["э"] = "'", ["я"] = "z", ["ч"] = "x", ["с"] = "c", ["м"] = "v",
    ["и"] = "b", ["т"] = "n", ["ь"] = "m", ["б"] = ",", ["ю"] = ".", ["Й"] = "Q", ["Ц"] = "W", ["У"] = "E", ["К"] = "R", ["Е"] = "T", ["Н"] = "Y", ["Г"] = "U", ["Ш"] = "I",
    ["Щ"] = "O", ["З"] = "P", ["Х"] = "{", ["Ъ"] = "}", ["Ф"] = "A", ["Ы"] = "S", ["В"] = "D", ["А"] = "F", ["П"] = "G", ["Р"] = "H", ["О"] = "J", ["Л"] = "K", ["Д"] = "L",
    ["Ж"] = ":", ["Э"] = "\"", ["Я"] = "Z", ["Ч"] = "X", ["С"] = "C", ["М"] = "V", ["И"] = "B", ["Т"] = "N", ["Ь"] = "M", ["Б"] = "<", ["Ю"] = ">"
}


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then
        return
    end
    while not isSampAvailable() do wait(100) end

    inputHelpText = renderCreateFont("Arial", 9, FCR_BORDER + FCR_BOLD)
    lua_thread.create(inputChat)
    lua_thread.create(showInputHelp)


    wait(-1)
end

function showInputHelp()
    while true do
        local chat = sampIsChatInputActive()
        if chat == true then
            local in1 = sampGetInputInfoPtr()
            local in1 = getStructElement(in1, 0x8, 4)
            local in2 = getStructElement(in1, 0x8, 4)
            local in3 = getStructElement(in1, 0xC, 4)
            fib = in3 + 41
            fib2 = in2 + 10
            local _, pID = sampGetPlayerIdByCharHandle(playerPed)
            local name = sampGetPlayerNickname(pID)
            local score = sampGetPlayerScore(pID)
            local color = sampGetPlayerColor(pID)
            local capsState = ffi.C.GetKeyState(20)
            local success = ffi.C.GetKeyboardLayoutNameA(KeyboardLayoutName)
            local errorCode = ffi.C.GetLocaleInfoA(tonumber(ffi.string(KeyboardLayoutName), 16), 0x00000002, LocalInfo, BuffSize)
            local localName = ffi.string(LocalInfo)
            local text = string.format(
                "%s :: {%0.6x}%s[%d] {ffffff}:: Капс: %s {FFFFFF}:: Язык: {ffeeaa}%s{ffffff}",
                os.date("%H:%M:%S"), bit.band(color,0xffffff), name, pID, getStrByState(capsState), string.match(localName, "([^%(]*)")
            )
            renderFontDrawText(inputHelpText, text, fib2, fib, 0xD7FFFFFF)
            end
        wait(0)
    end
end
function getStrByState(keyState)
    if keyState == 0 then
        return "{ffeeaa}Выкл{ffffff}"
    end
    return "{9EC73D}Вкл{ffffff}"
end
function translite(text)
    for k, v in pairs(chars) do
        text = string.gsub(text, k, v)
    end
    return text
end

function inputChat()
    while true do
        if(sampIsChatInputActive())then
            local getInput = sampGetChatInputText()
            if(oldText ~= getInput and #getInput > 0)then
                local firstChar = string.sub(getInput, 1, 1)
                if(firstChar == "." or firstChar == "/")then
                    local cmd, text = string.match(getInput, "^([^ ]+)(.*)")
                    local nText = "/" .. translite(string.sub(cmd, 2)) .. text
                    local chatInfoPtr = sampGetInputInfoPtr()
                    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
                    local lastPos = mem.getint8(chatBoxInfo + 0x11E)
                    sampSetChatInputText(nText)
                    mem.setint8(chatBoxInfo + 0x11E, lastPos)
                    mem.setint8(chatBoxInfo + 0x119, lastPos)
                    oldText = nText
                end
            end
        end
        wait(0)
    end
end
 

Flufick

Известный
Автор темы
263
17
Так?
Lua:
script_name('Input Helper')
script_version_number(1)
script_moonloader(020)
script_author('DonHomka')
script_description('Help to game in samp :)')

local ffi = require("ffi")
require 'lib.moonloader'
require 'lib.sampfuncs'
local mem = require "memory"
ffi.cdef[[
    short GetKeyState(int nVirtKey);
    bool GetKeyboardLayoutNameA(char* pwszKLID);
    int GetLocaleInfoA(int Locale, int LCType, char* lpLCData, int cchData);
]]
local BuffSize = 32
local KeyboardLayoutName = ffi.new("char[?]", BuffSize)
local LocalInfo = ffi.new("char[?]", BuffSize)
chars = {
    ["й"] = "q", ["ц"] = "w", ["у"] = "e", ["к"] = "r", ["е"] = "t", ["н"] = "y", ["г"] = "u", ["ш"] = "i", ["щ"] = "o", ["з"] = "p", ["х"] = "[", ["ъ"] = "]", ["ф"] = "a",
    ["ы"] = "s", ["в"] = "d", ["а"] = "f", ["п"] = "g", ["р"] = "h", ["о"] = "j", ["л"] = "k", ["д"] = "l", ["ж"] = ";", ["э"] = "'", ["я"] = "z", ["ч"] = "x", ["с"] = "c", ["м"] = "v",
    ["и"] = "b", ["т"] = "n", ["ь"] = "m", ["б"] = ",", ["ю"] = ".", ["Й"] = "Q", ["Ц"] = "W", ["У"] = "E", ["К"] = "R", ["Е"] = "T", ["Н"] = "Y", ["Г"] = "U", ["Ш"] = "I",
    ["Щ"] = "O", ["З"] = "P", ["Х"] = "{", ["Ъ"] = "}", ["Ф"] = "A", ["Ы"] = "S", ["В"] = "D", ["А"] = "F", ["П"] = "G", ["Р"] = "H", ["О"] = "J", ["Л"] = "K", ["Д"] = "L",
    ["Ж"] = ":", ["Э"] = "\"", ["Я"] = "Z", ["Ч"] = "X", ["С"] = "C", ["М"] = "V", ["И"] = "B", ["Т"] = "N", ["Ь"] = "M", ["Б"] = "<", ["Ю"] = ">"
}


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then
        return
    end
    while not isSampAvailable() do wait(100) end

    inputHelpText = renderCreateFont("Arial", 9, FCR_BORDER + FCR_BOLD)
    lua_thread.create(inputChat)
    lua_thread.create(showInputHelp)


    wait(-1)
end

function showInputHelp()
    while true do
        local chat = sampIsChatInputActive()
        if chat == true then
            local in1 = sampGetInputInfoPtr()
            local in1 = getStructElement(in1, 0x8, 4)
            local in2 = getStructElement(in1, 0x8, 4)
            local in3 = getStructElement(in1, 0xC, 4)
            fib = in3 + 41
            fib2 = in2 + 10
            local _, pID = sampGetPlayerIdByCharHandle(playerPed)
            local name = sampGetPlayerNickname(pID)
            local score = sampGetPlayerScore(pID)
            local color = sampGetPlayerColor(pID)
            local capsState = ffi.C.GetKeyState(20)
            local success = ffi.C.GetKeyboardLayoutNameA(KeyboardLayoutName)
            local errorCode = ffi.C.GetLocaleInfoA(tonumber(ffi.string(KeyboardLayoutName), 16), 0x00000002, LocalInfo, BuffSize)
            local localName = ffi.string(LocalInfo)
            local text = string.format(
                "%s :: {%0.6x}%s[%d] {ffffff}:: Капс: %s {FFFFFF}:: Язык: {ffeeaa}%s{ffffff}",
                os.date("%H:%M:%S"), bit.band(color,0xffffff), name, pID, getStrByState(capsState), string.match(localName, "([^%(]*)")
            )
            renderFontDrawText(inputHelpText, text, fib2, fib, 0xD7FFFFFF)
            end
        wait(0)
    end
end
function getStrByState(keyState)
    if keyState == 0 then
        return "{ffeeaa}Выкл{ffffff}"
    end
    return "{9EC73D}Вкл{ffffff}"
end
function translite(text)
    for k, v in pairs(chars) do
        text = string.gsub(text, k, v)
    end
    return text
end

function inputChat()
    while true do
        if(sampIsChatInputActive())then
            local getInput = sampGetChatInputText()
            if(oldText ~= getInput and #getInput > 0)then
                local firstChar = string.sub(getInput, 1, 1)
                if(firstChar == "." or firstChar == "/")then
                    local cmd, text = string.match(getInput, "^([^ ]+)(.*)")
                    local nText = "/" .. translite(string.sub(cmd, 2)) .. text
                    local chatInfoPtr = sampGetInputInfoPtr()
                    local chatBoxInfo = getStructElement(chatInfoPtr, 0x8, 4)
                    local lastPos = mem.getint8(chatBoxInfo + 0x11E)
                    sampSetChatInputText(nText)
                    mem.setint8(chatBoxInfo + 0x11E, lastPos)
                    mem.setint8(chatBoxInfo + 0x119, lastPos)
                    oldText = nText
                end
            end
        end
        wait(0)
    end
end
в чате пишет ироглифы и не работате замена русских букв на английские
 

mooh

Известный
169
49

Вложения

  • inputHelper.lua
    4.3 KB · Просмотры: 2
  • Нравится
Реакции: Flufick