дополнить код

type o negative

Известный
Автор темы
527
170
кто может - сделайте, чтоб после 5 минут оно автоматически продолжало качать скиллы
(не в моих силах)
 

Вложения

  • fixfixed.lua
    5.9 KB · Просмотры: 2

alexroq

Участник
111
12
Lua:
local tirst = false
local sight = false
local targets = {}
local skillResetTimer = 0
local SKILL_RESET_TIME = 300000

function rand()
    return math.random(-50, 50) / 100
end

local gunsWait = {
    [24] = 700,
    [31] = 50,
    [30] = 50,
    [22] = 300,
    [23] = 300,
    [25] = 1050,
    [28] = 100,
    [29] = 100
}

function main()
    repeat wait(100) until isSampAvailable()

    sampRegisterChatCommand('ytir', function(CheckGun)
        if CheckGun == "help" then
            local weapon = {
                {24, "deagle"}, {31, "m4"}, {30, "ak47"},
                {22, "pistols"}, {23, "tazer"},
                {25, "shotgun"}, {28, "uzi"}, {29, "mp5"}
            }
            for _, v in ipairs(weapon) do
                sampAddChatMessage(("weapon = %s, id = %s"):format(v[2], v[1]), -1)
            end
            return
        elseif not tonumber(CheckGun) then
            return sampAddChatMessage("Нужно указать ID оружия", -1)
        end

        CheckGun = tonumber(CheckGun)
        if hasCharGotWeapon(1, CheckGun) then
            gun = CheckGun
            tirst = not tirst
            printStringNow(tirst and 'tir bot ~g~enabled' or 'tir bot ~r~disabled', 2000)

            if tirst then
                skillResetTimer = os.clock() * 1000
            end

            lua_thread.create(function()
                while tirst do
                    local currentTime = os.clock() * 1000
                    if currentTime - skillResetTimer > SKILL_RESET_TIME then
                        sampAddChatMessage("~g~Сброс позиции для качки скиллов", -1)
                        skillResetTimer = currentTime
                        setCharCoordinates(PLAYER_PED, getCharCoordinates(PLAYER_PED))
                    end

                    if CheckGun > 0 then
                        local myY = select(2, getCharCoordinates(PLAYER_PED))
                        local yMin, yMax = myY - 0.65, myY + 0.85
                        local brk = false

                        for id = 0, 1000 do
                            local handle = sampGetObjectHandleBySampId(id)
                            if doesObjectExist(handle) then
                                local result, x, y, z = getObjectCoordinates(handle)
                                if result then
                                    local model = getObjectModel(handle)
                                    for i = 1588, 1592 do
                                        if model == i and y < yMax and y > yMin then
                                            printString("Shot!", 500)
                                            brk = true
                                            sent(id, x, y, z, CheckGun)
                                            break
                                        end
                                    end
                                end
                            end
                            if brk then break end
                        end
                    end
                    wait(gunsWait[CheckGun] or 1500)
                end
            end)
        else
            sampAddChatMessage("У тебя нет этого оружия!", -1)
        end
    end)

    wait(-1)
end

function sent(id, x, y, z, gun)
    setCurrentCharWeapon(1, gun)

    local sync = samp_create_sync_data("player")
    sync.animationId = 1167
    sync.animationFlags = 32776
    sync.keysData = 128
    sync.weapon = gun
    sync.send()

    local sync = samp_create_sync_data("aim")
    sync.camMode = 53
    sync.camFront = {0, 0, -1}
    sync.camPos = {x, y, z}
    sync.aimZ = -0.55
    sync.camExtZoom = 63
    sync.weaponState = 2
    sync.send()

    sync = samp_create_sync_data("bullet")
    sync.targetType = 3
    sync.targetId = id
    sync.center = {rand(), rand(), rand()}
    sync.origin = {getActiveCameraCoordinates()}
    sync.target = {x, y, z}
    sync.weaponId = gun
    sync.send()

    setCharAmmo(1, gun, getAmmoInCharWeapon(1, gun) - 1)
end

function samp_create_sync_data(sync_type, copy_from_player)
    local ffi = require 'ffi'
    local sampfuncs = require 'sampfuncs'
    local raknet = require 'samp.raknet'
    require 'samp.synchronization'

    copy_from_player = copy_from_player or true

    local sync_traits = {
        player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
        vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
        passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
        aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
        trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
        unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
        bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
        spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
    }

    local sync_info = sync_traits[sync_type]
    local data_type = 'struct ' .. sync_info[1]
    local data = ffi.new(data_type, {})
    local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))

    if copy_from_player then
        local copy_func = sync_info[3]
        if copy_func then
            local _, player_id
            if copy_from_player == true then
                _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
            else
                player_id = tonumber(copy_from_player)
            end
            copy_func(player_id, raw_data_ptr)
        end
    end

    local func_send = function()
        local bs = raknetNewBitStream()
        raknetBitStreamWriteInt8(bs, sync_info[2])
        raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
        raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
        raknetDeleteBitStream(bs)
    end

    local mt = {
        __index = function(t, index)
            return data[index]
        end,
        __newindex = function(t, index, value)
            data[index] = value
        end
    }
    return setmetatable({send = func_send}, mt)
end
наверное так