Вопросы по Lua скриптингу

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:

XRLM

Известный
2,550
867
Твое тоже не работает)
Lua:
local sampev = require 'lib.samp.events'
local id = 0
function sampev.onSendCommand(text)
    if text:find('/eject (%d+)') then
        lua_thread.create(function()
            local id = text:match('/eject (%d+)')
            sampSendChat('/me схватил человека за одежду') wait(1000)
            sampSendChat('/do Рука держит человека.') wait(1000)
            sampSendChat('/me резким движением руки открыл двери, затем выкинул игрока') wait(1000)
            sampSendChat('/eject'..id)
        end)
        return false
       end
end
 

ewin

Известный
675
369
почему не работает Imgui.SetNextWindowSize?

Lua:
if imgui.BeginPopupModal(u8'Создание бинда') then
    imgui.SetNextWindowSize(imgui.ImVec2(500, 500))
    if imgui.Button(u8' Закрыть', imgui.ImVec2(200, 20)) then
        imgui.CloseCurrentPopup()
    end
end
 

Sadow

Известный
1,438
590
Попробуй задержку поставить перед отправкой сообщения. В потоке только.
И скинь строчку, если не сработает всё равно..
Lua:
function sampev.onServerMessage(color, text)
    lua_thread.create(function()
    local id = text:match('%[Жалоба%] от (.+)[(%d+)]: (.+)')
    if id then
        if text:find("Апельсин")
        wait(2000)
        sampSendChat("/mute " .. id .. "60 сам апельсин")
          end
        if text:find("Мандарин")
        wait(2000)
        sampSendChat("/mute " .. id .. "60 сам мандарин")
        end
    end
end)
end
 

XRLM

Известный
2,550
867
Lua:
function sampev.onServerMessage(color, text)
    lua_thread.create(function()
    local id = text:match('%[Жалоба%] от (.+)[(%d+)]: (.+)')
    if id then
        if text:find("Апельсин")
        wait(2000)
        sampSendChat("/mute " .. id .. "60 сам апельсин")
          end
        if text:find("Мандарин")
        wait(2000)
        sampSendChat("/mute " .. id .. "60 сам мандарин")
        end
    end
end)
end
в смысле ты ставишь условие, если id, то чему оно ровно? если нет условия, то вроде как принимается nil, то есть 0. у тебя идет text:find, оно ищет конкретную строчку, в которой будет только "Апельсин", не "Жалоба от кого-то там: Апельсин", то же самое мандарин. убери if id и вместо text:find поставь text:match. у тебя будет искать жалобу, из которой будет копироваться id игрока, а потом если кто то напишет в чат Апельсин, то мут дастся не тому, кто написал "Апельсин", а тому, кто последний раз отправлял жалобу. еще одна ошибка, если ты отлавливаешь id, то не надо ставить скобки в "(.+)". уже много раз тебе отправлял код, отправлял гайды на регулярные и text:find, text:match, чтобы ты понял как это работает все.
я исправил код:
Lua:
function sampev.onServerMessage(color, text)
    if text:match('%[Жалоба%] от .+[(%d+)]:.+Апельсин.+') then
        local id = text:match('%[Жалоба%] от .+[(%d+)]:.+Апельсин.+')
        lua_thread.create(function() wait(150)
            sampSendChat('/mute '..id..'60 сам апельсин')
        end)
    end
end
 

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,776
11,224
почему не работает Imgui.SetNextWindowSize?

Lua:
if imgui.BeginPopupModal(u8'Создание бинда') then
    imgui.SetNextWindowSize(imgui.ImVec2(500, 500))
    if imgui.Button(u8' Закрыть', imgui.ImVec2(200, 20)) then
        imgui.CloseCurrentPopup()
    end
end
потому что надо юзать imgui.SetWindowSize(imgui.ImVec2(500, 500))
 
  • Нравится
Реакции: ewin

KOLBASKA@

Участник
35
0
Проблема скрипт запускается, но не работает можете найти проблему.

Lua:
script_name("uStats")
script_author("Pasha")
script_description("View your Stats in game")
require "lib.moonloader"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.dafault = 'CP1251'
u8 = encoding.UTF8

local keys = require "vkeys"
local tag = "{03f4fc} [Your Stats]:"
local colr = 0xad1717
local green_colr = "{17ad1e}"
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

function main()
    if not isSampLoaded() or not  isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("stat", cmd_stat)
    
    
    while true do wait(0)
        if main_window_state.v == false then 
            imgui.Process = false 
        end
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
        money = getPlayerMoney(id)
        ping = sampGetPlayerPing(id)
        score = sampGetPlayerScore(id)
        armor = sampGetPlayerArmor(id)
        health = sampGetPlayerHealth(id)
        animid = sampGetPlayerAnimationId(int, id)
        count = sampGetPlayerCount(bool, true)
        interior = getActiveInterior()
    end
end
function cmd_stat(arg)
    main_window_state.v = not main_window_state.v 
    imgui.Process = main_window_state.v
end
function comma_value(n)
    local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
    return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end
function separator(text)
    if text:find("$") then
        for S in string.gmatch(text, "%$%d+") do
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
        for S in string.gmatch(text, "%d+%$") do
            S = string.sub(S, 0, #S-1)
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
    end
    return text
end
function command_state()
  state = not state
  if state then
    imgui.Process = true
  else
    imgui.Process = false
  end
end
function imgui.OnDrawFrame()
  if state then
    imgui.Begin('Hello World!')
    imgui.Text('Money: '..separator(money))
    imgui.Text("You write Command:(/stat) ")
    imgui.Text("Your nick: " .. nick .. (";"))
    imgui.Text("Your ID: " .. id .. (";"))
    imgui.Text("Your money: " .. money .. (";"))
    imgui.Text("Your ping: " .. ping .. (";"))
    imgui.Text("Your LVL: " .. score .. (";"))
    imgui.Text("Your armour: " .. armor .. (";"))
    imgui.Text("Your health: " .. health .. (";"))
    imgui.Text("Player in server: " .. count .. (";"))
    imgui.Text("Interior: " .. interior .. (";"))
      
    imgui.End()
  end
end
 

XRLM

Известный
2,550
867
Проблема скрипт запускается, но не работает можете найти проблему.

Lua:
script_name("uStats")
script_author("Pasha")
script_description("View your Stats in game")
require "lib.moonloader"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.dafault = 'CP1251'
u8 = encoding.UTF8

local keys = require "vkeys"
local tag = "{03f4fc} [Your Stats]:"
local colr = 0xad1717
local green_colr = "{17ad1e}"
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

function main()
    if not isSampLoaded() or not  isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("stat", cmd_stat)
   
   
    while true do wait(0)
        if main_window_state.v == false then
            imgui.Process = false
        end
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
        money = getPlayerMoney(id)
        ping = sampGetPlayerPing(id)
        score = sampGetPlayerScore(id)
        armor = sampGetPlayerArmor(id)
        health = sampGetPlayerHealth(id)
        animid = sampGetPlayerAnimationId(int, id)
        count = sampGetPlayerCount(bool, true)
        interior = getActiveInterior()
    end
end
function cmd_stat(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end
function comma_value(n)
    local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
    return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end
function separator(text)
    if text:find("$") then
        for S in string.gmatch(text, "%$%d+") do
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
        for S in string.gmatch(text, "%d+%$") do
            S = string.sub(S, 0, #S-1)
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
    end
    return text
end
function command_state()
  state = not state
  if state then
    imgui.Process = true
  else
    imgui.Process = false
  end
end
function imgui.OnDrawFrame()
  if state then
    imgui.Begin('Hello World!')
    imgui.Text('Money: '..separator(money))
    imgui.Text("You write Command:(/stat) ")
    imgui.Text("Your nick: " .. nick .. (";"))
    imgui.Text("Your ID: " .. id .. (";"))
    imgui.Text("Your money: " .. money .. (";"))
    imgui.Text("Your ping: " .. ping .. (";"))
    imgui.Text("Your LVL: " .. score .. (";"))
    imgui.Text("Your armour: " .. armor .. (";"))
    imgui.Text("Your health: " .. health .. (";"))
    imgui.Text("Player in server: " .. count .. (";"))
    imgui.Text("Interior: " .. interior .. (";"))
     
    imgui.End()
  end
end
мунлог в студию.
 

KOLBASKA@

Участник
35
0
Скрипт с которым проблема uStats


[22:34:41.461801] (system) Session started.
[22:34:41.464802] (debug) Module handle: 64C40000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
https://www.blast.hk/moonloader/

[22:34:41.464802] (info) Working directory: D:\Games\Samp\moonloader
[22:34:41.464802] (debug) FP Control: 0009001F
[22:34:41.464802] (debug) Game: GTA SA 1.0.0.0 US
[22:34:41.464802] (system) Installing pre-game hooks...
[22:34:41.468802] (system) Hooks installed.
[22:34:42.782708] (debug) Initializing opcode handler table
[22:34:42.783712] (debug) package.path = D:\Games\Samp\moonloader\lib\?.lua;D:\Games\Samp\moonloader\lib\?\init.lua;D:\Games\Samp\moonloader\?.lua;D:\Games\Samp\moonloader\?\init.lua;.\?.lua;D:\Games\Samp\moonloader\lib\?.luac;D:\Games\Samp\moonloader\lib\?\init.luac;D:\Games\Samp\moonloader\?.luac;D:\Games\Samp\moonloader\?\init.luac;.\?.luac
[22:34:42.783712] (debug) package.cpath = D:\Games\Samp\moonloader\lib\?.dll;
[22:34:42.783712] (system) Loading script 'D:\Games\Samp\moonloader\AimAssist by Scar v0.7.1 Beta - Free Version.lua'...
[22:34:42.783712] (debug) New script: 0EE951AC
[22:34:42.813710] (system) AimAssist by Scar v0.7.1 Beta - Free Version.lua: Loaded successfully.
[22:34:42.814711] (system) Loading script 'D:\Games\Samp\moonloader\AutoBikeMotoRunSwimOnMaxSpeed.lua'...
[22:34:42.814711] (debug) New script: 0EE9969C
[22:34:42.815711] (system) AutoBicycleRunSwimOnMaxSpeed: Loaded successfully.
[22:34:42.815711] (system) Loading script 'D:\Games\Samp\moonloader\AutoReboot.lua'...
[22:34:42.815711] (debug) New script: 0EE99824
[22:34:42.823714] (system) ML-AutoReboot: Loaded successfully.
[22:34:42.823714] (system) Loading script 'D:\Games\Samp\moonloader\CaptchaTraining.lua'...
[22:34:42.823714] (debug) New script: 0EE99BB4
[22:34:42.827710] (system) CaptchaTraining: Loaded successfully.
[22:34:42.827710] (system) Loading script 'D:\Games\Samp\moonloader\clickwarp (1).lua'...
[22:34:42.827710] (debug) New script: 0EE9AB9C
[22:34:42.831710] (system) Click Warp: Loaded successfully.
[22:34:42.831710] (system) Loading script 'D:\Games\Samp\moonloader\Driver.lua'...
[22:34:42.831710] (debug) New script: 0EEA2EAC
[22:34:42.831710] (error) Driver.lua: D:\Games\Samp\moonloader\Driver.lua:1: '=' expected near 'moonloader'
[22:34:42.831710] (error) Driver.lua: Script died due to an error. (0EEA2EAC)
[22:34:42.831710] (system) Loading script 'D:\Games\Samp\moonloader\dsscript.lua'...
[22:34:42.831710] (debug) New script: 0EEA2EAC
[22:34:42.831710] (error) dsscript.lua: D:\Games\Samp\moonloader\dsscript.lua:45: unfinished long comment near '<eof>'
[22:34:42.832712] (error) dsscript.lua: Script died due to an error. (0EEA2EAC)
[22:34:42.832712] (system) Loading script 'D:\Games\Samp\moonloader\Pilot_Helper_by_Mixail (1).lua'...
[22:34:42.832712] (debug) New script: 0EEA2EAC
[22:34:42.846713] (system) Pilot_Helper_by_Mixail (1).lua: Loaded successfully.
[22:34:42.846713] (system) Loading script 'D:\Games\Samp\moonloader\reload_all.lua'...
[22:34:42.847712] (debug) New script: 0EEAB244
[22:34:42.848716] (system) ML-ReloadAll: Loaded successfully.
[22:34:42.848716] (system) Loading script 'D:\Games\Samp\moonloader\rvanka.lua'...
[22:34:42.848716] (debug) New script: 0EEAB3CC
[22:34:42.857714] (system) rvanka.lua: Loaded successfully.
[22:34:42.857714] (system) Loading script 'D:\Games\Samp\moonloader\sampevent.lua'...
[22:34:42.857714] (debug) New script: 0EEB5424
[22:34:42.864734] (system) sampevent.lua: Loaded successfully.
[22:34:42.865728] (system) Loading script 'D:\Games\Samp\moonloader\script.lua'...
[22:34:42.865728] (debug) New script: 0EEB67BC
[22:34:42.865728] (error) script.lua: D:\Games\Samp\moonloader\script.lua:14: unexpected symbol near '['
[22:34:42.865728] (error) script.lua: Script died due to an error. (0EEB67BC)
[22:34:42.865728] (system) Loading script 'D:\Games\Samp\moonloader\Script1.lua'...
[22:34:42.865728] (debug) New script: 0EEB67BC
[22:34:42.880717] (system) Script1.lua: Loaded successfully.
[22:34:42.880717] (system) Loading script 'D:\Games\Samp\moonloader\Script2.lua'...
[22:34:42.880717] (debug) New script: 0EEC2774
[22:34:42.889714] (system) Puff: Loaded successfully.
[22:34:42.889714] (system) Loading script 'D:\Games\Samp\moonloader\SF_Integration.lua'...
[22:34:42.889714] (debug) New script: 0EEC2924
[22:34:42.892716] (system) SF Integration: Loaded successfully.
[22:34:42.892716] (system) Loading script 'D:\Games\Samp\moonloader\SilentAim.luac'...
[22:34:42.892716] (debug) New script: 0EEC30CC
[22:34:42.906718] (system) SilentAim: Loaded successfully.
[22:34:42.907731] (system) Loading script 'D:\Games\Samp\moonloader\ssscript.lua'...
[22:34:42.907731] (debug) New script: 0EEC2AAC
[22:34:42.907731] (error) ssscript.lua: D:\Games\Samp\moonloader\ssscript.lua:50: unfinished long comment near '<eof>'
[22:34:42.907731] (error) ssscript.lua: Script died due to an error. (0EEC2AAC)
[22:34:42.907731] (system) Loading script 'D:\Games\Samp\moonloader\test.lua'...
[22:34:42.907731] (debug) New script: 0EEC33DC
[22:34:42.907731] (error) test.lua: D:\Games\Samp\moonloader\test.lua:61: unfinished long comment near '<eof>'
[22:34:42.907731] (error) test.lua: Script died due to an error. (0EEC33DC)
[22:34:42.907731] (system) Loading script 'D:\Games\Samp\moonloader\TrainingCaptchi.lua'...
[22:34:42.907731] (debug) New script: 0EEC36EC
[22:34:42.908716] (system) TrainingCaptchi.lua: Loaded successfully.
[22:34:42.908716] (system) Loading script 'D:\Games\Samp\moonloader\UnLockFPS by Ssid.lua'...
[22:34:42.908716] (debug) New script: 0EEC2AAC
[22:34:42.910731] (system) LEGAL C-BUG: Loaded successfully.
[22:34:42.910731] (system) Loading script 'D:\Games\Samp\moonloader\uStats.lua'...
[22:34:42.910731] (debug) New script: 0EEC2C34
[22:34:42.918719] (system) uStats: Loaded successfully.
[22:34:42.919736] (system) TrainingCaptchi.lua: Script terminated. (0EEC36EC)
[22:34:48.364739] (system) Installing post-load hooks...
[22:34:48.365741] (system) Hooks installed.
[22:35:23.502628] (system) AimAssist by Scar v0.7.1 Beta - Free Version.lua: Script terminated. (0EE951AC)
[22:35:23.512631] (system) AutoBicycleRunSwimOnMaxSpeed: Script terminated. (0EE9969C)
[22:35:23.514629] (system) ML-AutoReboot: Script terminated. (0EE99824)
[22:35:23.518631] (system) CaptchaTraining: Script terminated. (0EE99BB4)
[22:35:23.520629] (system) Click Warp: Script terminated. (0EE9AB9C)
[22:35:23.523633] (system) Pilot_Helper_by_Mixail (1).lua: Script terminated. (0EEA2EAC)
[22:35:23.529632] (system) ML-ReloadAll: Script terminated. (0EEAB244)
[22:35:23.531633] (system) rvanka.lua: Script terminated. (0EEAB3CC)
[22:35:23.534629] (system) sampevent.lua: Script terminated. (0EEB5424)
[22:35:23.538635] (system) Script1.lua: Script terminated. (0EEB67BC)
[22:35:23.544632] (system) Puff: Script terminated. (0EEC2774)
[22:35:23.549636] (system) SF Integration: Script terminated. (0EEC2924)
[22:35:23.551632] (system) SilentAim: Script terminated. (0EEC30CC)
[22:35:23.558633] (system) LEGAL C-BUG: Script terminated. (0EEC2AAC)
[22:35:23.560632] (system) uStats: Script terminated. (0EEC2C34)
[22:35:23.566636] (system) Loading script 'D:\Games\Samp\moonloader\AimAssist by Scar v0.7.1 Beta - Free Version.lua'...
[22:35:23.566636] (debug) New script: 0EEC2F44
[22:35:23.729642] (system) AimAssist by Scar v0.7.1 Beta - Free Version.lua: Loaded successfully.
[22:35:23.729642] (system) Loading script 'D:\Games\Samp\moonloader\AutoBikeMotoRunSwimOnMaxSpeed.lua'...
[22:35:23.730660] (debug) New script: 0EEC30CC
[22:35:23.737642] (system) AutoBicycleRunSwimOnMaxSpeed: Loaded successfully.
[22:35:23.737642] (system) Loading script 'D:\Games\Samp\moonloader\AutoReboot.lua'...
[22:35:23.738702] (debug) New script: 0EEC2C34
[22:35:23.778645] (system) ML-AutoReboot: Loaded successfully.
[22:35:23.778645] (system) Loading script 'D:\Games\Samp\moonloader\CaptchaTraining.lua'...
[22:35:23.779707] (debug) New script: 0EEC3254
[22:35:23.799646] (system) CaptchaTraining: Loaded successfully.
[22:35:23.799646] (system) Loading script 'D:\Games\Samp\moonloader\clickwarp (1).lua'...
[22:35:23.799646] (debug) New script: 0EEC33DC
[22:35:23.811667] (system) Click Warp: Loaded successfully.
[22:35:23.811667] (system) Loading script 'D:\Games\Samp\moonloader\Driver.lua'...
[22:35:23.811667] (debug) New script: 0EEC2924
[22:35:23.812663] (error) Driver.lua: D:\Games\Samp\moonloader\Driver.lua:1: '=' expected near 'moonloader'
[22:35:23.812663] (error) Driver.lua: Script died due to an error. (0EEC2924)
[22:35:23.812663] (system) Loading script 'D:\Games\Samp\moonloader\dsscript.lua'...
[22:35:23.812663] (debug) New script: 0EEC2924
[22:35:23.812663] (error) dsscript.lua: D:\Games\Samp\moonloader\dsscript.lua:45: unfinished long comment near '<eof>'
[22:35:23.812663] (error) dsscript.lua: Script died due to an error. (0EEC2924)
[22:35:23.812663] (system) Loading script 'D:\Games\Samp\moonloader\Pilot_Helper_by_Mixail (1).lua'...
[22:35:23.812663] (debug) New script: 0EEC2924
[22:35:23.824643] (system) Pilot_Helper_by_Mixail (1).lua: Loaded successfully.
[22:35:23.824643] (system) Loading script 'D:\Games\Samp\moonloader\reload_all.lua'...
[22:35:23.824643] (debug) New script: 0EEC2AAC
[22:35:23.825647] (system) ML-ReloadAll: Loaded successfully.
[22:35:23.825647] (system) Loading script 'D:\Games\Samp\moonloader\rvanka.lua'...
[22:35:23.825647] (debug) New script: 0ED15B3C
[22:35:23.831658] (system) rvanka.lua: Loaded successfully.
[22:35:23.831658] (system) Loading script 'D:\Games\Samp\moonloader\sampevent.lua'...
[22:35:23.831658] (debug) New script: 0ED1615C
[22:35:23.835659] (system) sampevent.lua: Loaded successfully.
[22:35:23.836661] (system) Loading script 'D:\Games\Samp\moonloader\script.lua'...
[22:35:23.836661] (debug) New script: 0ED15084
[22:35:23.836661] (error) script.lua: D:\Games\Samp\moonloader\script.lua:14: unexpected symbol near '['
[22:35:23.836661] (error) script.lua: Script died due to an error. (0ED15084)
[22:35:23.836661] (system) Loading script 'D:\Games\Samp\moonloader\Script1.lua'...
[22:35:23.836661] (debug) New script: 0ED159B4
[22:35:23.844663] (system) Script1.lua: Loaded successfully.
[22:35:23.844663] (system) Loading script 'D:\Games\Samp\moonloader\Script2.lua'...
[22:35:23.844663] (debug) New script: 0ED165F4
[22:35:23.850663] (system) Puff: Loaded successfully.
[22:35:23.850663] (system) Loading script 'D:\Games\Samp\moonloader\SF_Integration.lua'...
[22:35:23.850663] (debug) New script: 0ED1520C
[22:35:23.852662] (system) SF Integration: Loaded successfully.
[22:35:23.852662] (system) Loading script 'D:\Games\Samp\moonloader\SilentAim.luac'...
[22:35:23.852662] (debug) New script: 0ED156A4
[22:35:23.872646] (system) SilentAim: Loaded successfully.
[22:35:23.872646] (system) Loading script 'D:\Games\Samp\moonloader\ssscript.lua'...
[22:35:23.872646] (debug) New script: 0ED15CC4
[22:35:23.872646] (error) ssscript.lua: D:\Games\Samp\moonloader\ssscript.lua:50: unfinished long comment near '<eof>'
[22:35:23.872646] (error) ssscript.lua: Script died due to an error. (0ED15CC4)
[22:35:23.873646] (system) Loading script 'D:\Games\Samp\moonloader\test.lua'...
[22:35:23.873646] (debug) New script: 0ED14D74
[22:35:23.873646] (error) test.lua: D:\Games\Samp\moonloader\test.lua:61: unfinished long comment near '<eof>'
[22:35:23.873646] (error) test.lua: Script died due to an error. (0ED14D74)
[22:35:23.873646] (system) Loading script 'D:\Games\Samp\moonloader\TrainingCaptchi.lua'...
[22:35:23.873646] (debug) New script: 0ED1677C
[22:35:23.875646] (system) TrainingCaptchi.lua: Loaded successfully.
[22:35:23.875646] (system) Loading script 'D:\Games\Samp\moonloader\UnLockFPS by Ssid.lua'...
[22:35:23.875646] (debug) New script: 0ED15E4C
[22:35:23.878647] (system) LEGAL C-BUG: Loaded successfully.
[22:35:23.878647] (system) Loading script 'D:\Games\Samp\moonloader\uStats.lua'...
[22:35:23.878647] (debug) New script: 0ED15CC4
[22:35:23.893666] (system) uStats: Loaded successfully.
[22:35:23.903650] (system) TrainingCaptchi.lua: Script terminated. (0ED1677C)
 

XRLM

Известный
2,550
867
Проблема скрипт запускается, но не работает можете найти проблему.

Lua:
script_name("uStats")
script_author("Pasha")
script_description("View your Stats in game")
require "lib.moonloader"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.dafault = 'CP1251'
u8 = encoding.UTF8

local keys = require "vkeys"
local tag = "{03f4fc} [Your Stats]:"
local colr = 0xad1717
local green_colr = "{17ad1e}"
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

function main()
    if not isSampLoaded() or not  isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("stat", cmd_stat)
   
   
    while true do wait(0)
        if main_window_state.v == false then
            imgui.Process = false
        end
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
        money = getPlayerMoney(id)
        ping = sampGetPlayerPing(id)
        score = sampGetPlayerScore(id)
        armor = sampGetPlayerArmor(id)
        health = sampGetPlayerHealth(id)
        animid = sampGetPlayerAnimationId(int, id)
        count = sampGetPlayerCount(bool, true)
        interior = getActiveInterior()
    end
end
function cmd_stat(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end
function comma_value(n)
    local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
    return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end
function separator(text)
    if text:find("$") then
        for S in string.gmatch(text, "%$%d+") do
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
        for S in string.gmatch(text, "%d+%$") do
            S = string.sub(S, 0, #S-1)
            local replace = comma_value(S)
            text = string.gsub(text, S, replace)
        end
    end
    return text
end
function command_state()
  state = not state
  if state then
    imgui.Process = true
  else
    imgui.Process = false
  end
end
function imgui.OnDrawFrame()
  if state then
    imgui.Begin('Hello World!')
    imgui.Text('Money: '..separator(money))
    imgui.Text("You write Command:(/stat) ")
    imgui.Text("Your nick: " .. nick .. (";"))
    imgui.Text("Your ID: " .. id .. (";"))
    imgui.Text("Your money: " .. money .. (";"))
    imgui.Text("Your ping: " .. ping .. (";"))
    imgui.Text("Your LVL: " .. score .. (";"))
    imgui.Text("Your armour: " .. armor .. (";"))
    imgui.Text("Your health: " .. health .. (";"))
    imgui.Text("Player in server: " .. count .. (";"))
    imgui.Text("Interior: " .. interior .. (";"))
     
    imgui.End()
  end
end
ошибка в 70 строке, поменяй state на main_window_state