SA:MP Скрипт

JokerEnergy

Новичок
Автор темы
11
0
Версия SA-MP
  1. Любая
Здравствуйте!
Нужна помощь в небольшой доработке скрипта
Суть: Нужно в скрипт добавить ВХ на кости игроков
(Пример на фото)
Lua:
local mem = require("memory")
local wh_active = false

local pref = "wh{ff0000} » {ffffff}"
function log(text) sampAddChatMessage(pref..tostring(text), -1) end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do
        wait(100)
    end
    sampRegisterChatCommand("wh", function()
        wh_active = not wh_active

        sSp = sampGetServerSettingsPtr()

        if wh_active then
            mem.setfloat(sSp + 39, 1200)
            mem.setint8(sSp + 47, 0)
            mem.setint8(sSp + 56, 1)
            log("Включён")
        else
            mem.setfloat(sSp + 39, 25.5)
            mem.setint8(sSp + 47, 1)
            mem.setint8(sSp + 56, 1)
            log("Выключен")
        end

    end)
    log("Скрипт загружен")
    wait(-1)
end
 

Вложения

  • sa-mp-045.png
    sa-mp-045.png
    264.3 KB · Просмотры: 6
  • sa-mp-046.png
    sa-mp-046.png
    250 KB · Просмотры: 6

JokerEnergy

Новичок
Автор темы
11
0

Вложения

  • sa-mp-045.png
    sa-mp-045.png
    264.3 KB · Просмотры: 10
  • sa-mp-046.png
    sa-mp-046.png
    250 KB · Просмотры: 7

алферов

Новичок
1
0
Привет, доработал скрипт. Активация /wh, проверь и отпиши пожалуйста, работает или нет :)
Lua:
local mem = require("memory")
local wh_active = false
local PLAYER_POOL_OFFSET = 0x212E68
local PLAYER_STRUCT_SIZE = 0x1C60
local RENDER_FLAGS_OFFSET = 0x5A4
local AUTHOR_TAG = "{FF69B4}Сделал Алферов, {FF0000}с любовью!"
local TG_LINK = "{00FF00}t.me/alfer0vv"
local SHOW_ON_STARTUP = true         
local pref = "wh{ff0000} » {ffffff}"
function log(text)
    sampAddChatMessage(pref..tostring(text), -1)
end
function togglePlayerRender(enable)
    local playerPool = mem.getint32(PLAYER_POOL_OFFSET)
    if playerPool == 0 then return end
    local count = mem.getint32(playerPool + 0x18)
    for i = 0, count-1 do
        local player = mem.getint32(playerPool + 0x4 + i*4)
        if player ~= 0 then
            mem.setint32(player + RENDER_FLAGS_OFFSET, enable and 0x08000000 or 0x00000000)
        end
    end
end
function showCopyright()
    sampAddChatMessage(AUTHOR_TAG, -1)
    sampAddChatMessage(TG_LINK, -1)
end
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    if SHOW_ON_STARTUP then
        showCopyright()
    end
    sampRegisterChatCommand("wh", function()
        wh_active = not wh_active
        local sSp = sampGetServerSettingsPtr()
        if sSp ~= 0 then
            mem.setfloat(sSp + 39, wh_active and 1200 or 25.5)
            mem.setint8(sSp + 47, wh_active and 0 or 1)
            mem.setint8(sSp + 56, 1)
        end
        togglePlayerRender(wh_active)
        log(wh_active and "Включен (кости+ВХ)" or "Выключен")
    end)
    sampRegisterChatCommand("author", function()
        showCopyright()
    end)
    log("Скрипт успешно инициализирован")
    wait(-1)
end
 
  • Bug
Реакции: Нейросеть

Нейросеть

Участник
72
45
Окей сделал (можешь оставить отзыв обо мне - https://www.blast.hk/threads/233836/)

1746827233825.png

активация /wh вкл/выкл каркас /bones

lua:
script_name("Bones WallHack")
script_version("1.0")
script_author("Нейросеть")

local mem = require("memory")
local ffi = require("ffi")
local vkeys = require("vkeys")
local getBonePosition = ffi.cast("int (__thiscall*)(void*, float*, int, bool)", 0x5E4280)

local wh_active = false
local bones_active = true

local pref = "wh{ff0000} » {ffffff}"
function log(text) sampAddChatMessage(pref..tostring(text), -1) end

local BONE_IDS = {
    {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 8},
    {4, 51}, {51, 52}, {52, 53}, {53, 54},
    {4, 41}, {41, 42}, {42, 43}, {43, 44},
    {5, 31}, {31, 32}, {32, 33}, {33, 34},
    {5, 21}, {21, 22}, {22, 23}, {23, 24}
}

local bone_colors = {
    [1] = 0xFFFF0000,
    [2] = 0xFFFF7F00,
    [3] = 0xFFFFFF00,
    [4] = 0xFF00FF00,
    [5] = 0xFF00FFFF,
    [6] = 0xFF0000FF,
    [7] = 0xFF8B00FF,
    [8] = 0xFFFF00FF,
    [0] = 0xFFFFFFFF
}

function renderDrawPoint(x, y, size, color)
    renderDrawBox(x - size/2, y - size/2, size, size, color)
end

function getBodyPartCoordinates(id, handle)
    local pedptr = getCharPointer(handle)
    if pedptr ~= 0 then
        local bone_pos = ffi.new("float[3]")
        local res = getBonePosition(ffi.cast("void*", pedptr), bone_pos, id, true)
        if res then
            return bone_pos[0], bone_pos[1], bone_pos[2]
        end
    end
    return 0, 0, 0
end

function getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2)
    return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2)
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do
        wait(100)
    end
  
    sampRegisterChatCommand("wh", function()
        wh_active = not wh_active
        sSp = sampGetServerSettingsPtr()

        if wh_active then
            mem.setfloat(sSp + 39, 1200)
            mem.setint8(sSp + 47, 0)
            mem.setint8(sSp + 56, 1)
            log("Включён")
        else
            mem.setfloat(sSp + 39, 25.5)
            mem.setint8(sSp + 47, 1)
            mem.setint8(sSp + 56, 1)
            log("Выключен")
        end
    end)
  
    sampRegisterChatCommand("bones", function()
        bones_active = not bones_active
        if bones_active then
            log("Каркас игроков включён")
        else
            log("Каркас игроков выключен")
        end
    end)
  
    log("Скрипт загружен | /wh - переключить ВХ | /bones - переключить каркас")
  
    renderFont = renderCreateFont("Arial", 10, 4)
  
    while true do
        wait(0)
      
        if wh_active and bones_active then
            for i = 0, sampGetMaxPlayerId() do
                if sampIsPlayerConnected(i) and i ~= select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)) then
                    local result, ped = sampGetCharHandleBySampPlayerId(i)
                  
                    if result and doesCharExist(ped) and isCharOnScreen(ped) then
                        local blueColor = 0x9000FFFF
                        local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
                        local pedX, pedY, pedZ = getCharCoordinates(ped)
                      
                        local processedPoints = {}
                      
                        local extremityBones = {8, 24, 34, 44, 54}
                      
                        for _, bonePair in ipairs(BONE_IDS) do
                            local bone1, bone2 = bonePair[1], bonePair[2]
                            local x1, y1, z1 = getBodyPartCoordinates(bone1, ped)
                            local x2, y2, z2 = getBodyPartCoordinates(bone2, ped)
                          
                            local sx1, sy1 = convert3DCoordsToScreen(x1, y1, z1)
                            local sx2, sy2 = convert3DCoordsToScreen(x2, y2, z2)
                          
                            if sx1 and sy1 and sx2 and sy2 then
                                renderDrawLine(sx1, sy1, sx2, sy2, 1.5, blueColor)
                              
                                for _, extremityBone in ipairs(extremityBones) do
                                    if bone1 == extremityBone and not processedPoints[bone1] then
                                        renderDrawPoint(sx1, sy1, 4, blueColor)
                                        processedPoints[bone1] = true
                                    end
                                  
                                    if bone2 == extremityBone and not processedPoints[bone2] then
                                        renderDrawPoint(sx2, sy2, 4, blueColor)
                                        processedPoints[bone2] = true
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        local sSp = sampGetServerSettingsPtr()
        mem.setfloat(sSp + 39, 25.5)
        mem.setint8(sSp + 47, 1)
        mem.setint8(sSp + 56, 1)
    end
end

function join_argb(a, r, g, b)
    local argb = b
    argb = bit.bor(argb, bit.lshift(g, 8))
    argb = bit.bor(argb, bit.lshift(r, 16))
    argb = bit.bor(argb, bit.lshift(a, 24))
    return argb
end

function explode_argb(argb)
    local a = bit.band(bit.rshift(argb, 24), 0xFF)
    local r = bit.band(bit.rshift(argb, 16), 0xFF)
    local g = bit.band(bit.rshift(argb, 8), 0xFF)
    local b = bit.band(argb, 0xFF)
    return a, r, g, b
end

Привет, доработал скрипт. Активация /wh, проверь и отпиши пожалуйста, работает или нет :)
Lua:
local mem = require("memory")
local wh_active = false
local PLAYER_POOL_OFFSET = 0x212E68
local PLAYER_STRUCT_SIZE = 0x1C60
local RENDER_FLAGS_OFFSET = 0x5A4
local AUTHOR_TAG = "{FF69B4}Сделал Алферов, {FF0000}с любовью!"
local TG_LINK = "{00FF00}t.me/alfer0vv"
local SHOW_ON_STARTUP = true        
local pref = "wh{ff0000} » {ffffff}"
function log(text)
    sampAddChatMessage(pref..tostring(text), -1)
end
function togglePlayerRender(enable)
    local playerPool = mem.getint32(PLAYER_POOL_OFFSET)
    if playerPool == 0 then return end
    local count = mem.getint32(playerPool + 0x18)
    for i = 0, count-1 do
        local player = mem.getint32(playerPool + 0x4 + i*4)
        if player ~= 0 then
            mem.setint32(player + RENDER_FLAGS_OFFSET, enable and 0x08000000 or 0x00000000)
        end
    end
end
function showCopyright()
    sampAddChatMessage(AUTHOR_TAG, -1)
    sampAddChatMessage(TG_LINK, -1)
end
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    if SHOW_ON_STARTUP then
        showCopyright()
    end
    sampRegisterChatCommand("wh", function()
        wh_active = not wh_active
        local sSp = sampGetServerSettingsPtr()
        if sSp ~= 0 then
            mem.setfloat(sSp + 39, wh_active and 1200 or 25.5)
            mem.setint8(sSp + 47, wh_active and 0 or 1)
            mem.setint8(sSp + 56, 1)
        end
        togglePlayerRender(wh_active)
        log(wh_active and "Включен (кости+ВХ)" or "Выключен")
    end)
    sampRegisterChatCommand("author", function()
        showCopyright()
    end)
    log("Скрипт успешно инициализирован")
    wait(-1)
end
С своим нерабочим скриптом лезет в луа, иди лечись 🤣
 
Последнее редактирование:
  • Клоун
Реакции: алферов