Lua Новый дамаг информер.

hells666

Участник
Автор темы
28
58
Версия SA-MP
  1. 0.3.7 (R1)
  2. 0.3.7-R2
  3. 0.3.7-R3
  4. 0.3.7-R4
  5. Любая
При попадании в игрока будет появляться текстдрав.
Есть несколько 'режимов':

+-:
/dmg +-
Когда вы попадаете в игрока будет появляться текстдрав "+",
когда игрок попадает по вам, будет появляться текстдрав "-".

text:
/dmg text
Тоже самое что и +-, но вместо + будет "DAMAGED", вместо - будет "TAKED"

score:
/dmg score
Когда вы попадаете в игрока, будет написано, сколько вы нанесли урона,
когда попадают по вам, то будет написано сколько по вам нанесли урона.

full:
/dmg full
Будет показываться вся информация, то есть:
- Кол-во урона
- Ид оружия
- Часть тела

Если урон нанести по вам, то будет еще показываться:
- Сколько у вас осталось хп ( число )
- Сколько у вас осталось хп ( в '>', то есть если осталось 30 хп, то >>> )

Код открытый, все надписи, цвета и т.д. можно изменить.

Код:
require "lib.moonloader"

local event = require "lib.samp.events"

local dmgtype = 0

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

    sampRegisterChatCommand("dmg", dmgtype)
 
    while true do
        wait(1)
    end
end

function dmgtype( arg )
    if arg == "text" then dmgtype = 3 end
    if arg == "full" then dmgtype = 2 end
    if arg == "+-" then dmgtype = 1 end
    if arg == "score" then dmgtype = 0 end 
end

function event.onSendGiveDamage(playerId, damage, weapon, bodypart)
    if dmgtype == 2 then createTextdraw("DAMAGED~n~" .. "DAMAGE: " .. math.floor(damage) .. "~n~" .. "WEAPON: " .. weapon .. "~n~" .. "BODYPART: " .. bodypart .. "~n~DAMAGED") end
    if dmgtype == 1 then createTextdraw("+") end
    if dmgtype == 0 then createTextdraw("+" .. math.floor(damage)) end
    if dmgtype == 3 then createTextdraw("+DAMAGED") end
end

function event.onSendTakeDamage(playerId, damage, weapon, bodypart)
    heal = getCharHealth(PLAYER_PED)
    local headpolos = " "
    if heal > 10 then headpolos = headpolos .. ">" end
    if heal > 20 then headpolos = headpolos .. ">" end
    if heal > 30 then headpolos = headpolos .. ">" end
    if heal > 40 then headpolos = headpolos .. ">" end
    if heal > 50 then headpolos = headpolos .. ">" end
    if heal > 60 then headpolos = headpolos .. ">" end
    if heal > 70 then headpolos = headpolos .. ">" end
    if heal > 80 then headpolos = headpolos .. ">" end
    if heal > 90 then headpolos = "FULL HEALTH" end

    if dmgtype == 2 then createTextdraw("TAKED~n~" .. "DAMAGE: " .. math.floor(damage) .. "~n~" .. "WEAPON: " .. weapon .. "~n~" .. "BODYPART: " .. bodypart .. "~n~" .. "HEALTH: " .. heal .. "~n~" .. headpolos .. "~n~TAKED") end
    if dmgtype == 1 then createTextdraw("-") end
    if dmgtype == 0 then createTextdraw("-" .. math.floor(damage)) end
    if dmgtype == 3 then createTextdraw("+TAKED") end
end



function createTextdraw(text)
    sampTextdrawCreate(td_Id, text, 322, 110)
    sampTextdrawSetShadow(td_Id,1,0x90000000)
    sampTextdrawSetLetterSizeAndColor(td_Id, 0.4, 1.5, -1)
    sampTextdrawSetAlign(td_Id, 2)
    sampTextdrawSetBoxColorAndSize(td_Id, 0,0, 1000, 500)

    global_thread = lua_thread.create(function()
            wait(100)
            
            for i = 95, 0, -1 do
            color = '0x';
            color = color..i..'FFFFFF';
            
            sampTextdrawSetLetterSizeAndColor(td_Id, 0.4, 1.5, color)
            wait(5)
            
            end
            sampTextdrawDelete(td_Id)
    end)
end
 

Вложения

  • newdmg.lua
    2.6 KB · Просмотры: 349
  • Нравится
Реакции: thund3rgrove