SA:MP Пишет что попало

Pampers5

Участник
Автор темы
46
4
ребят, помогите, сделал скрипт, чтобы при команде /cord писали мои корды. Решил сделать, чтобы сразу в буфер обмена копировалось. я чет не понимаю.
lua:
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
     sampRegisterChatCommand("cord", cord)
    while true do
     wait(0)
   end
end

function cord(cord)
  x, y, z = getCharCoordinates(1)
  print('X = '..x.. ' | Y = '..y.. ' | Z = '..z)
  local cord = setClipboardText("Скопированый текст")
end
Когда вставляю пишет это
1771175584271.png
 

tygodym

Известный
49
8
123:
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("cord", cord)

    while true do
        wait(0)
   end
end

function cord()
    x, y, z = getCharCoordinates(1)
    local cord = ('X = ' .. x .. ' | Y = ' .. y .. ' | Z = ' .. z)
    print(cord)
    setClipboardText(cord)
end
 
  • Эм
Реакции: minxty
используй это
Lua:
function _setClipboardText(text)
    local ffi = require('ffi')
    ffi.cdef [[
    intptr_t LoadKeyboardLayoutA(const char* pwszKLID, unsigned int Flags);
    int PostMessageA(intptr_t hWnd, unsigned int Msg, unsigned int wParam, long lParam);
    intptr_t GetActiveWindow();
    /**/
    intptr_t GetForegroundWindow(void);
    int GetWindowThreadProcessId(intptr_t hWnd, void* lpdwProcessId);
    intptr_t GetKeyboardLayout(intptr_t idThread);
]]
    local hwnd = ffi.C.GetForegroundWindow()
    local dword = ffi.C.GetWindowThreadProcessId(hwnd, nil)
    --
    local flang = ffi.C.GetKeyboardLayout(dword)
    local rulang = ffi.C.LoadKeyboardLayoutA('00000419', 1) -- https://www.blast.hk/threads/13380/post-553247
    ffi.C.PostMessageA(ffi.C.GetActiveWindow(), 0x50, 1, rulang)
    setClipboardText(text)
    ffi.C.PostMessageA(ffi.C.GetActiveWindow(), 0x50, 1, flang)
end
 
Последнее редактирование:

Pampers5

Участник
Автор темы
46
4
используй это
Lua:
function _setClipboardText(text)
    local ffi = require('ffi')
    ffi.cdef [[
    intptr_t LoadKeyboardLayoutA(const char* pwszKLID, unsigned int Flags);
    int PostMessageA(intptr_t hWnd, unsigned int Msg, unsigned int wParam, long lParam);
    intptr_t GetActiveWindow();
    /**/
    intptr_t GetForegroundWindow(void);
    int GetWindowThreadProcessId(intptr_t hWnd, void* lpdwProcessId);
    intptr_t GetKeyboardLayout(intptr_t idThread);
]]
    local hwnd = ffi.C.GetForegroundWindow()
    local dword = ffi.C.GetWindowThreadProcessId(hwnd, nil)
    --
    local flang = ffi.C.GetKeyboardLayout(dword)
    local rulang = ffi.C.LoadKeyboardLayoutA('00000419', 1) -- https://www.blast.hk/threads/13380/post-553247
    ffi.C.PostMessageA(ffi.C.GetActiveWindow(), 0x50, 1, rulang)
    setClipboardText(text)
    ffi.C.PostMessageA(ffi.C.GetActiveWindow(), 0x50, 1, flang)
end
бро, выше помогли <3