Автоотыгровки

Demmy

Участник
Автор темы
121
22
Версия MoonLoader
.026-beta
Сделал костыльную версию автоотыгровки тазера и дубинки, но когда беру оружие игра просто намертво виснет, а лог пуст, нужна помощь.
Lua:
weapont = getCurrentCharWeapon(PLAYER_PED)
          while weapont == 23 or weapont == 3 do
          weapon = getCurrentCharWeapon(playerPed)
          lastweap = weapon
            while weapon == 23 do
                wait(1000)
                sampSendChat("/me взял тазер")
                while true do
                  wait(0)
                  weaponc = getCurrentCharWeapon(playerPed)
                  if weaponc ~= 23 then
                    break
                  end
                end
                break
            end
            while weapon == 3 do
                wait(1000)
                sampSendChat("/me взял дубинку")
                while true do
                  wait(0)
                  weaponc = getCurrentCharWeapon(playerPed)
                  if weaponc ~= 3 then
                    break
                  end
                end
                break
            end
          end
          while lastweap == 3 or lastweap == 23 do
            while lastweap == 3 do
                wait(1000)
                sampSendChat("/me убрал дубинку")
                while true do
                  wait(0)
                  weaponc = getCurrentCharWeapon(playerPed)
                  if weaponc == 3 then
                    break
                  end
                end
                break
            end
            while lastweap == 23 do
                wait(1000)
                sampSendChat("/me убрал тазер")
                while true do
                  wait(0)
                  weaponc = getCurrentCharWeapon(playerPed)
                  if weaponc == 23 then
                    break
                  end
                end
                break
            end
          end
 

CaJlaT

Овощ
Модератор
2,809
2,620
Lua:
script_name('RP GUN') -- название скрипта
script_author('FORMYS') -- автор скрипта
script_description('RP GUN true function') -- описание скрипта

require "lib.moonloader" -- подключение библиотеки
local weapons = require 'lib.game.weapons'
local inicfg = require 'inicfg'
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

rpgun = false -- изначально выключен
sex = 1 -- 0 женский, 1 мужской

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

    sampRegisterChatCommand("rpgun", cmd_rpgun)
    rp_thread = lua_thread.create_suspended(rp_weapons)

    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
    
    while true do
        wait(0)

    end
end

function cmd_rpgun()
    rpgun = not rpgun
    if rpgun then
        sampAddChatMessage("РП оружие включено", -1)
        rp_thread:run()
    else
        sampAddChatMessage("РП оружие выключено", -1)
        rp_thread:terminate()
    end
end

function rp_weapons()
    local gunOn = {}
    local gunOff = {}
    local gunPartOn = {}
    local gunPartOff = {}
    local oldGun = nil
    local nowGun = getCurrentCharWeapon(PLAYER_PED)
    local rpTakeNames = {{"из-за спины", "за спину"}, {"из кармана", "в карман"}, {"из пояса", "на пояс"}, {"из кобуры", "в кобуру"}}
    local rpTake = {
        [2]=1, [5]=1, [6]=1, [7]=1, [8]=1, [9]=1, [14]=1, [15]=1, [25]=1, [26]=1, [27]=1, [28]=1, [29]=1, [30]=1, [31]=1, [32]=1, [33]=1, [34]=1, [35]=1, [36]=1, [37]=1, [38]=1, [42]=1, -- спина
        [1]=2, [4]=2, [10]=2, [11]=2, [12]=2, [13]=2, [41]=2, [43]=2, [44]=2, [45]=2, [46]=2, -- карман
        [3]=3, [16]=3, [17]=3, [18]=3, [39]=3, [40]=3, -- пояс
        [22]=4, [23]=4, [24]=4 -- кобура
    }
    
    for id, weapon in pairs(weapons.names) do
        --sampAddChatMessage(id .. " - " .. weapon, -1)

        if (id == 3 or (id > 15 and id < 19)) then -- 3 16 17 18 (for gunOn)
            gunOn[id] = sex and 'снял' or 'сняла'
        else
            gunOn[id] = sex and 'достал' or 'достала'
        end

        if (id == 3 or (id > 15 and id < 19) or (id > 38 and id < 41)) then -- 3 16 17 18 39 40 (for gunOff)
            gunOff[id] = sex and 'повесил' or 'повесила'
        else
            gunOff[id] = sex and 'убрал' or 'убрала'
        end

        if id > 0 then
            gunPartOn[id] = rpTakeNames[rpTake[id]][1]
            gunPartOff[id] = rpTakeNames[rpTake[id]][2]
        end
    end

    while true do
        wait(0)
        if nowGun ~= getCurrentCharWeapon(PLAYER_PED) then
            oldGun = nowGun
            nowGun = getCurrentCharWeapon(PLAYER_PED)
            if oldGun == 0 then
                sampAddChatMessage("/me " .. gunOn[nowGun] .. " " .. weapons.get_name(nowGun) .. " " .. gunPartOn[nowGun], -1)
            else
                if nowGun == 0 then
                    sampAddChatMessage("/me " .. gunOff[oldGun] .. " " .. weapons.get_name(oldGun) .. " " .. gunPartOff[oldGun], -1)
                else
                    sampAddChatMessage("/me " .. gunOff[oldGun] .. " " .. weapons.get_name(oldGun) .. " " .. gunPartOff[oldGun] .. ", после чего " .. gunOn[nowGun] .. " " .. weapons.get_name(nowGun) .. " " .. gunPartOn[nowGun], -1)
                end
            end
        end
    end
end
Ошибка твоей версии в том, что в ней слишком много циклов, и они накладываются друг на друга
 

Вложения

  • rp_gun.lua
    3.1 KB · Просмотры: 27
  • Нравится
Реакции: yufFKa и Demmy