Активация по команде

Compich

Известный
Автор темы
236
43
Версия MoonLoader
.027.0-preview
Как сделать в этом скрипте активацию по команде?
Lua:
script_name("anti-gastritis")
script_authors("Howl1337")
script_description("Анти-гастрит для дрп")
script_version("1.0")
require 'game.keys'
local sampev = require 'lib.samp.events'

function sampev.onApplyPlayerAnimation(playerId, animLib, animName)
    local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
    if playerId == myId then
        if sampFindAnimationIdByNameAndFile(animName, animLib) == 539 then taskPlayAnim(playerPed, "HANDSUP", "PED", 1.0, false, false, false, false, 1)  end
    end
end
 
Решение
Lua:
script_name("anti-gastritis")
script_authors("Howl1337")
script_description("Анти-гастрит для дрп")
script_version("1.0")
require 'game.keys'
local sampev = require 'lib.samp.events'
local act = false

function main()
    sampRegisterChatCommand("act", function()
        act = not act
    end)
    wait(-1)
end
function sampev.onApplyPlayerAnimation(playerId, animLib, animName)
    if act then
        local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if playerId == myId then
            if sampFindAnimationIdByNameAndFile(animName, animLib) == 539 then taskPlayAnim(playerPed, "HANDSUP", "PED", 1.0, false, false, false, false, 1)  end
        end
    end
end

damag

Женюсь на официантке в моем любимом баре
Проверенный
1,152
1,192
Lua:
script_name("anti-gastritis")
script_authors("Howl1337")
script_description("Анти-гастрит для дрп")
script_version("1.0")
require 'game.keys'
local sampev = require 'lib.samp.events'
local act = false

function main()
    sampRegisterChatCommand("act", function()
        act = not act
    end)
    wait(-1)
end
function sampev.onApplyPlayerAnimation(playerId, animLib, animName)
    if act then
        local _, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if playerId == myId then
            if sampFindAnimationIdByNameAndFile(animName, animLib) == 539 then taskPlayAnim(playerPed, "HANDSUP", "PED", 1.0, false, false, false, false, 1)  end
        end
    end
end