Вопросы по 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
 
Последнее редактирование:

checkdasound

Известный
Проверенный
963
406
Спасибо, огромное, за роспись всего, но у меня вопрос


onSendGiveDamage и onSendtakeDamage разве не для тебя самого? он вроде для других игроков не идет
А на скрине как раз-таки для одного, эксперта.
 
  • Нравится
Реакции: mixeq

mixeq

Известный
66
8
А на скрине как раз-таки для одного, эксперта.
Либо я не догоняю, либо хер знает
Попробую объяснить внятнее
Есть игрок А, он стреляет в игрока Б, а ты сам игрок В, который просто в зоне стрима вместе с ребятками А и Б
Мне нужно инфу то что на скрине, то есть
Эксперт, это игрок А, Смокер игрок Б
Ты в перестрелке участие вообще не принимаешь, понял что нужно?
Если все таки эти функи, что ты назвал, объясни поподробнее, ибо я не догоняю как их использовать
Они же вроде возвращают ид игрока, в которого ТЫ стреляешь или получаешь от него урон ТЫ
 

checkdasound

Известный
Проверенный
963
406
Либо я не догоняю, либо хер знает
Попробую объяснить внятнее
Есть игрок А, он стреляет в игрока Б, а ты сам игрок В, который просто в зоне стрима вместе с ребятками А и Б
Мне нужно инфу то что на скрине, то есть
Эксперт, это игрок А, Смокер игрок Б
Ты в перестрелке участие вообще не принимаешь, понял что нужно?
Если все таки эти функи, что ты назвал, объясни поподробнее, ибо я не догоняю как их использовать
Они же вроде возвращают ид игрока, в которого ТЫ стреляешь или получаешь от него урон ТЫ
Я не знаю точно, https://blast.hk/wiki/samp:rpc_givetakedamage.
Для всех или только для тебя, попробуй.
 
  • Нравится
Реакции: mixeq

dmitri4

Известный
452
79
Вопрос, сделал дамаг информер который выводит наносимый мне дамаг в чат но после смерти камера и персонаж просто застывают на месте до перезагрузки скрипта. Как можно исправить.
1Jy285l.png
 

ShuffleBoy

Известный
Друг
754
429
Вопрос, сделал дамаг информер который выводит наносимый мне дамаг в чат но после смерти камера и персонаж просто застывают на месте до перезагрузки скрипта. Как можно исправить.
1Jy285l.png
код скинуть для начала
Lua:
local coordinates =
{
    X = {[0] = -2647.952, -2624.108},
    Y = {[0] = 616.588, 616.737},
    Z = {[0] = 14.453, 14.453}
}

function main()
    if not isSampLoaded() and not isSampfuncsLoaded then return end
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('tp', teleport)
    wait(-1)
end

function teleport(number)
    setCharCoordinates(PLAYER_PED, coordinates.X[number], coordinates.Y[number], coordinates.Z[number])
end

подскажите как будет правильно
Lua:
local coordinates = {
    {-2467.952, 616.588, 14.453},
    {-2624.108, 616.737, 14.453}
}

function main()
    if not isSampLoaded() and not isSampfuncsLoaded then return end
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('tp', teleport)
    wait(-1)
end

function teleport(number)
    setCharCoordinates(PLAYER_PED, coordinates[number][1], coordinates[number][2], coordinates[number][3])
end
лично мне кажется такое структурирование более правильнее, сделал по своим идеалам
 

clenz

Участник
42
1
Что здесь нужно убрать, чтобы цвет костей был только белым, не менялся в зависимости от цвета клиста?
Код:
script_name("Skeletal WallHack")
script_version_number(1)
script_description("thx to Valdan666 and FYP")
script_author("AppleThe & hnnssy")

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

--// *** // *** //--
whVisible = "bones" -- Мод ВХ по умолчанию. Моды написаны в комментарии ниже
optionsCommand = "bones" -- Моды ВХ: bones - только кости / names - только ники, all - всё сразу
KEY = VK_F5 -- Кнопка активации ВХ
defaultState = false -- Запуск ВХ при старте игры
--// *** // *** //--

function main()
    if not isSampLoaded() or not isCleoLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand(optionsCommand, function(param)
        if param == "bones" then whVisible = param; nameTagOff()
        elseif param == "names" or param == "all" then whVisible = param if not nameTag then nameTagOn() end
        else sampAddChatMessage("Введите корректный режим: {CCCCFF}names{4444FF}/{CCCCFF}bones{4444FF}/{CCCCFF}all", 0xFF4444FF) end
    end)
    while not sampIsLocalPlayerSpawned() do wait(100) end
    if defaultState and not nameTag then nameTagOn() end
    while true do
        wait(0)
        if wasKeyPressed(KEY) then;
            if defaultState then
                defaultState = false;
                nameTagOff();
                while isKeyDown(KEY) do wait(100) end
            else
                defaultState = true;
                if whVisible ~= "bones" and not nameTag then nameTagOn() end
                while isKeyDown(KEY) do wait(100) end
            end
        end
        if defaultState and whVisible ~= "names" then
            if not isPauseMenuActive() and not isKeyDown(VK_F8) then
                for i = 0, sampGetMaxPlayerId() do
                if sampIsPlayerConnected(i) then
                    local result, cped = sampGetCharHandleBySampPlayerId(i)
                    local color = sampGetPlayerColor(i)
                    local aa, rr, gg, bb = explode_argb(color)
                    local color = join_argb(255, rr, gg, bb)
                    if result then
                        if doesCharExist(cped) and isCharOnScreen(cped) then
                            local t = {3, 4, 5, 51, 52, 41, 42, 31, 32, 33, 21, 22, 23, 2}
                            for v = 1, #t do
                                pos1X, pos1Y, pos1Z = getBodyPartCoordinates(t[v], cped)
                                pos2X, pos2Y, pos2Z = getBodyPartCoordinates(t[v] + 1, cped)
                                pos1, pos2 = convert3DCoordsToScreen(pos1X, pos1Y, pos1Z)
                                pos3, pos4 = convert3DCoordsToScreen(pos2X, pos2Y, pos2Z)
                                renderDrawLine(pos1, pos2, pos3, pos4, 1, color)
                            end
                            for v = 4, 5 do
                                pos2X, pos2Y, pos2Z = getBodyPartCoordinates(v * 10 + 1, cped)
                                pos3, pos4 = convert3DCoordsToScreen(pos2X, pos2Y, pos2Z)
                                renderDrawLine(pos1, pos2, pos3, pos4, 1, color)
                            end
                            local t = {53, 43, 24, 34, 6}
                            for v = 1, #t do
                                posX, posY, posZ = getBodyPartCoordinates(t[v], cped)
                                pos1, pos2 = convert3DCoordsToScreen(posX, posY, posZ)
                            end
                        end
                    end
                end
            end
            else
                nameTagOff()
                while isPauseMenuActive() or isKeyDown(VK_F8) do wait(0) end
                nameTagOn()
            end
        end
    end
end

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

function nameTagOn()
    local pStSet = sampGetServerSettingsPtr();
    NTdist = mem.getfloat(pStSet + 39)
    NTwalls = mem.getint8(pStSet + 47)
    NTshow = mem.getint8(pStSet + 56)
    mem.setfloat(pStSet + 39, 1488.0)
    mem.setint8(pStSet + 47, 0)
    mem.setint8(pStSet + 56, 1)
    nameTag = true
end

function nameTagOff()
    local pStSet = sampGetServerSettingsPtr();
    mem.setfloat(pStSet + 39, NTdist)
    mem.setint8(pStSet + 47, NTwalls)
    mem.setint8(pStSet + 56, NTshow)
    nameTag = false
end

function join_argb(a, r, g, b)
  local argb = b  -- b
  argb = bit.bor(argb, bit.lshift(g, 8))  -- g
  argb = bit.bor(argb, bit.lshift(r, 16)) -- r
  argb = bit.bor(argb, bit.lshift(a, 24)) -- a
  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
От сюда ВХ - https://blast.hk/threads/15507/
 
Последнее редактирование:

dmitri4

Известный
452
79
код скинуть для начала
Код:
require "lib.moonloader"
local sampev = require 'lib.samp.events'
local weapons = require 'game.weapons'

function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
while true do
wait(0)
function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
local color = sampGetPlayerColor(playerId)
sampAddChatMessage('<DamageInfo> От '..sampGetPlayerNickname(playerId)..'['..playerId..']. Оружие: '..weapons.get_name(weapon)..' ['..math.floor(damage)..']', color)
end

end
end

function getweaponname(weapon)
local namegun
if weapon == 0 then
namegun = "Fist"
end
if weapon == 1 then
namegun = "Brass Knuckles"
end
if weapon == 2 then
namegun = "Golf Club"
end
if weapon == 3 then
namegun = "Nightstick"
end
if weapon == 4 then
namegun = "Knife"
end
if weapon == 5 then
namegun = "Baseball Bat"
end
if weapon == 6 then
namegun = "Shovel"
end
if weapon == 7 then
namegun = "Pool Cue"
end
if weapon == 8 then
namegun = "Katana"
end
if weapon == 9 then
namegun = "Chainsaw"
end
if weapon == 10 then
namegun = "Purple Dildo"
end
if weapon == 11 then
namegun = "Dildo"
end
if weapon == 12 then
namegun = "Vibrator"
end
if weapon == 13 then
namegun = "Silver Vibrator"
end
if weapon == 14 then
namegun = "Flowers"
end
if weapon == 15 then
namegun = "Cane"
end
if weapon == 16 then
namegun = "Grenade"
end
if weapon == 17 then
namegun = "Tear Gas"
end
if weapon == 18 then
namegun = "Molotov Cocktail"
end
if weapon == 22 then
namegun = "9mm"
end
if weapon == 23 then
namegun = "Silenced 9mm"
end
if weapon == 24 then
namegun = "Desert Eagle"
end
if weapon == 25 then
namegun = "Shotgun"
end
if weapon == 26 then
namegun = "Sawnoff Shotgun"
end
if weapon == 27 then
namegun = "Combat Shotgun"
end
if weapon == 28 then
namegun = "Micro SMG/Uzi"
end
if weapon == 29 then
namegun = "MP5"
end
if weapon == 30 then
namegun = "AK-47"
end
if weapon == 31 then
namegun = "M4"
end
if weapon == 32 then
namegun = "Tec-9"
end
if weapon == 33 then
namegun = "Country Rifle"
end
if weapon == 34 then
namegun = "Sniper Rifle"
end
if weapon == 35 then
namegun = "RPG"
end
if weapon == 36 then
namegun = "HS Rocket"
end
if weapon == 37 then
namegun = "Flamethrower"
end
if weapon == 38 then
namegun = "Minigun"
end
if weapon == 39 then
namegun = "Satchel Charge"
end
if weapon == 40 then
namegun = "Detonator"
end
if weapon == 41 then
namegun = "Spraycan"
end
if weapon == 42 then
namegun = "Fire Extinguisher"
end
if weapon == 43 then
namegun = "Camera"
end
if weapon == 44 then
namegun = "Night Vis Goggles"
end
if weapon == 45 then
namegun = "Thermal Goggles"
end
if weapon == 46 then
namegun = "Parachute"
end
return namegun
end
 

vlads250

Известный
27
0
Есть у кого-нибудь код на проверку и скачку обновления для скрипта? Скиньте, если не сложно.
 

ShuffleBoy

Известный
Друг
754
429
[ML] (error) test.lua: C:\Games\GTA San Andreas\moonloader\test.lua:14: attempt to index a nil value
stack traceback:
Lua:
local number = tonumber(number)
вставь под строчкой объявления функции телепорт
Код:
require "lib.moonloader"
local sampev = require 'lib.samp.events'
local weapons = require 'game.weapons'

function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
while true do
wait(0)
function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
local color = sampGetPlayerColor(playerId)
sampAddChatMessage('<DamageInfo> От '..sampGetPlayerNickname(playerId)..'['..playerId..']. Оружие: '..weapons.get_name(weapon)..' ['..math.floor(damage)..']', color)
end

end
end

function getweaponname(weapon)
local namegun
if weapon == 0 then
namegun = "Fist"
end
if weapon == 1 then
namegun = "Brass Knuckles"
end
if weapon == 2 then
namegun = "Golf Club"
end
if weapon == 3 then
namegun = "Nightstick"
end
if weapon == 4 then
namegun = "Knife"
end
if weapon == 5 then
namegun = "Baseball Bat"
end
if weapon == 6 then
namegun = "Shovel"
end
if weapon == 7 then
namegun = "Pool Cue"
end
if weapon == 8 then
namegun = "Katana"
end
if weapon == 9 then
namegun = "Chainsaw"
end
if weapon == 10 then
namegun = "Purple Dildo"
end
if weapon == 11 then
namegun = "Dildo"
end
if weapon == 12 then
namegun = "Vibrator"
end
if weapon == 13 then
namegun = "Silver Vibrator"
end
if weapon == 14 then
namegun = "Flowers"
end
if weapon == 15 then
namegun = "Cane"
end
if weapon == 16 then
namegun = "Grenade"
end
if weapon == 17 then
namegun = "Tear Gas"
end
if weapon == 18 then
namegun = "Molotov Cocktail"
end
if weapon == 22 then
namegun = "9mm"
end
if weapon == 23 then
namegun = "Silenced 9mm"
end
if weapon == 24 then
namegun = "Desert Eagle"
end
if weapon == 25 then
namegun = "Shotgun"
end
if weapon == 26 then
namegun = "Sawnoff Shotgun"
end
if weapon == 27 then
namegun = "Combat Shotgun"
end
if weapon == 28 then
namegun = "Micro SMG/Uzi"
end
if weapon == 29 then
namegun = "MP5"
end
if weapon == 30 then
namegun = "AK-47"
end
if weapon == 31 then
namegun = "M4"
end
if weapon == 32 then
namegun = "Tec-9"
end
if weapon == 33 then
namegun = "Country Rifle"
end
if weapon == 34 then
namegun = "Sniper Rifle"
end
if weapon == 35 then
namegun = "RPG"
end
if weapon == 36 then
namegun = "HS Rocket"
end
if weapon == 37 then
namegun = "Flamethrower"
end
if weapon == 38 then
namegun = "Minigun"
end
if weapon == 39 then
namegun = "Satchel Charge"
end
if weapon == 40 then
namegun = "Detonator"
end
if weapon == 41 then
namegun = "Spraycan"
end
if weapon == 42 then
namegun = "Fire Extinguisher"
end
if weapon == 43 then
namegun = "Camera"
end
if weapon == 44 then
namegun = "Night Vis Goggles"
end
if weapon == 45 then
namegun = "Thermal Goggles"
end
if weapon == 46 then
namegun = "Parachute"
end
return namegun
end
события для того и события, их используют чтобы не заполнять все циклами, его нельзя использывать в бесконечном цикле, вынеси в отдельную функцию

Что здесь нужно убрать, чтобы цвет костей был только белым, не менялся в зависимости от цвета клиста?
Код:
script_name("Skeletal WallHack")
script_version_number(1)
script_description("thx to Valdan666 and FYP")
script_author("AppleThe & hnnssy")

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

--// *** // *** //--
whVisible = "bones" -- Мод ВХ по умолчанию. Моды написаны в комментарии ниже
optionsCommand = "bones" -- Моды ВХ: bones - только кости / names - только ники, all - всё сразу
KEY = VK_F5 -- Кнопка активации ВХ
defaultState = false -- Запуск ВХ при старте игры
--// *** // *** //--

function main()
    if not isSampLoaded() or not isCleoLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand(optionsCommand, function(param)
        if param == "bones" then whVisible = param; nameTagOff()
        elseif param == "names" or param == "all" then whVisible = param if not nameTag then nameTagOn() end
        else sampAddChatMessage("Введите корректный режим: {CCCCFF}names{4444FF}/{CCCCFF}bones{4444FF}/{CCCCFF}all", 0xFF4444FF) end
    end)
    while not sampIsLocalPlayerSpawned() do wait(100) end
    if defaultState and not nameTag then nameTagOn() end
    while true do
        wait(0)
        if wasKeyPressed(KEY) then;
            if defaultState then
                defaultState = false;
                nameTagOff();
                while isKeyDown(KEY) do wait(100) end
            else
                defaultState = true;
                if whVisible ~= "bones" and not nameTag then nameTagOn() end
                while isKeyDown(KEY) do wait(100) end
            end
        end
        if defaultState and whVisible ~= "names" then
            if not isPauseMenuActive() and not isKeyDown(VK_F8) then
                for i = 0, sampGetMaxPlayerId() do
                if sampIsPlayerConnected(i) then
                    local result, cped = sampGetCharHandleBySampPlayerId(i)
                    local color = sampGetPlayerColor(i)
                    local aa, rr, gg, bb = explode_argb(color)
                    local color = join_argb(255, rr, gg, bb)
                    if result then
                        if doesCharExist(cped) and isCharOnScreen(cped) then
                            local t = {3, 4, 5, 51, 52, 41, 42, 31, 32, 33, 21, 22, 23, 2}
                            for v = 1, #t do
                                pos1X, pos1Y, pos1Z = getBodyPartCoordinates(t[v], cped)
                                pos2X, pos2Y, pos2Z = getBodyPartCoordinates(t[v] + 1, cped)
                                pos1, pos2 = convert3DCoordsToScreen(pos1X, pos1Y, pos1Z)
                                pos3, pos4 = convert3DCoordsToScreen(pos2X, pos2Y, pos2Z)
                                renderDrawLine(pos1, pos2, pos3, pos4, 1, color)
                            end
                            for v = 4, 5 do
                                pos2X, pos2Y, pos2Z = getBodyPartCoordinates(v * 10 + 1, cped)
                                pos3, pos4 = convert3DCoordsToScreen(pos2X, pos2Y, pos2Z)
                                renderDrawLine(pos1, pos2, pos3, pos4, 1, color)
                            end
                            local t = {53, 43, 24, 34, 6}
                            for v = 1, #t do
                                posX, posY, posZ = getBodyPartCoordinates(t[v], cped)
                                pos1, pos2 = convert3DCoordsToScreen(posX, posY, posZ)
                            end
                        end
                    end
                end
            end
            else
                nameTagOff()
                while isPauseMenuActive() or isKeyDown(VK_F8) do wait(0) end
                nameTagOn()
            end
        end
    end
end

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

function nameTagOn()
    local pStSet = sampGetServerSettingsPtr();
    NTdist = mem.getfloat(pStSet + 39)
    NTwalls = mem.getint8(pStSet + 47)
    NTshow = mem.getint8(pStSet + 56)
    mem.setfloat(pStSet + 39, 1488.0)
    mem.setint8(pStSet + 47, 0)
    mem.setint8(pStSet + 56, 1)
    nameTag = true
end

function nameTagOff()
    local pStSet = sampGetServerSettingsPtr();
    mem.setfloat(pStSet + 39, NTdist)
    mem.setint8(pStSet + 47, NTwalls)
    mem.setint8(pStSet + 56, NTshow)
    nameTag = false
end

function join_argb(a, r, g, b)
  local argb = b  -- b
  argb = bit.bor(argb, bit.lshift(g, 8))  -- g
  argb = bit.bor(argb, bit.lshift(r, 16)) -- r
  argb = bit.bor(argb, bit.lshift(a, 24)) -- a
  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
От сюда ВХ - https://blast.hk/threads/15507/
Lua:
local color = sampGetPlayerColor(i)
local aa, rr, gg, bb = explode_argb(color)
local color = join_argb(255, rr, gg, bb)
замени на
Lua:
color = 0xFFFFFFFF
 

dmitri4

Известный
452
79
события для того и события, их используют чтобы не заполнять все циклами, его нельзя использывать в бесконечном цикле, вынеси в отдельную функцию
Увы но либо где то с моей стороны ошибка либо это просто не помогло
 

штейн

Известный
Проверенный
1,001
687
как в imgui в столбцах нарисовать вертикальную линию?
imgui.Columns

------

Увы но либо где то с моей стороны ошибка либо это просто не помогло

Lua:
require "lib.moonloader"
local sampev = require 'lib.samp.events'
local weapons = require 'game.weapons'

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

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    local color = sampGetPlayerColor(playerId)
    sampAddChatMessage('<DamageInfo> От '..sampGetPlayerNickname(playerId)..'['..playerId..']. Оружие: '..getweaponname(weapon)..' ['..math.floor(damage)..']', -1)
end

function getweaponname(weapon)
    local names = {
        [0] = "Fist",
        [1] = "Brass Knuckles",
        [2] = "Golf Club",
        [3] = "Nightstick",
        [4] = "Knife",
        [5] = "Baseball Bat",
        [6] = "Shovel",
        [7] = "Pool Cue",
        [8] = "Katana",
        [9] = "Chainsaw",
        [10] = "Purple Dildo",
        [11] = "Dildo",
        [12] = "Vibrator",
        [13] = "Silver Vibrator",
        [14] = "Flowers",
        [15] = "Cane",
        [16] = "Grenade",
        [17] = "Tear Gas",
        [18] = "Molotov Cocktail",
        [22] = "9mm",
        [23] = "Silenced 9mm",
        [24] = "Desert Eagle",
        [25] = "Shotgun",
        [26] = "Sawnoff Shotgun",
        [27] = "Combat Shotgun",
        [28] = "Micro SMG/Uzi",
        [29] = "MP5",
        [30] = "AK-47",
        [31] = "M4",
        [32] = "Tec-9",
        [33] = "Country Rifle",
        [34] = "Sniper Rifle",
        [35] = "RPG",
        [36] = "HS Rocket",
        [37] = "Flamethrower",
        [38] = "Minigun",
        [39] = "Satchel Charge",
        [40] = "Detonator",
        [41] = "Spraycan",
        [42] = "Fire Extinguisher",
        [43] = "Camera",
        [44] = "Night Vis Goggles",
        [45] = "Thermal Goggles",
        [46] = "Parachute"
    }
    return names[weapon]
end

------------

Есть у кого-нибудь код на проверку и скачку обновления для скрипта? Скиньте, если не сложно.
тут есть - Fyodor Kurlyuk / pisser.lua · GitLab(https://gitlab.com/qrlk/pisser.lua)
 
Последнее редактирование:

Musaigen

abobusnik
Проверенный
1,585
1,309
imgui.Columns

------



Lua:
require "lib.moonloader"
local sampev = require 'lib.samp.events'
local weapons = require 'game.weapons'

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

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    local color = sampGetPlayerColor(playerId)
    sampAddChatMessage('<DamageInfo> От '..sampGetPlayerNickname(playerId)..'['..playerId..']. Оружие: '..getweaponname(weapon)..' ['..math.floor(damage)..']', -1)
end

function getweaponname(weapon)
    local names = {
        [0] = "Fist",
        [1] = "Brass Knuckles",
        [2] = "Golf Club",
        [3] = "Nightstick",
        [4] = "Knife",
        [5] = "Baseball Bat",
        [6] = "Shovel",
        [7] = "Pool Cue",
        [8] = "Katana",
        [9] = "Chainsaw",
        [10] = "Purple Dildo",
        [11] = "Dildo",
        [12] = "Vibrator",
        [13] = "Silver Vibrator",
        [14] = "Flowers",
        [15] = "Cane",
        [16] = "Grenade",
        [17] = "Tear Gas",
        [18] = "Molotov Cocktail",
        [22] = "9mm",
        [23] = "Silenced 9mm",
        [24] = "Desert Eagle",
        [25] = "Shotgun",
        [26] = "Sawnoff Shotgun",
        [27] = "Combat Shotgun",
        [28] = "Micro SMG/Uzi",
        [29] = "MP5",
        [30] = "AK-47",
        [31] = "M4",
        [32] = "Tec-9",
        [33] = "Country Rifle",
        [34] = "Sniper Rifle",
        [35] = "RPG",
        [36] = "HS Rocket",
        [37] = "Flamethrower",
        [38] = "Minigun",
        [39] = "Satchel Charge",
        [40] = "Detonator",
        [41] = "Spraycan",
        [42] = "Fire Extinguisher",
        [43] = "Camera",
        [44] = "Night Vis Goggles",
        [45] = "Thermal Goggles",
        [46] = "Parachute"
    }
    return names[weapon]
end

------------


тут есть - Fyodor Kurlyuk / pisser.lua · GitLab(https://gitlab.com/qrlk/pisser.lua)
Зачем ты подключаешь либу weapons если все-равно ее не используешь?