• Вопрос Вопрос
Вопрос Игнор фракции для системы голода

Как в эту систему голода (ниже) добавить игнор определенной фракции? (helix)

код:
Развернуть Свернуть Копировать
PLUGIN.name = "Survival System"
PLUGIN.author = "ZeMysticalTaco"
PLUGIN.description = "A survival system consisting of hunger and thirst."


local speed = 300
local decay = 1

ix.config.Add("hungerDecaySpeed", speed, "Speed at which hunger should decay.", nil, {
    data = {min = 100, max = 600},
    category = "Survival System"
})

ix.config.Add("hungerDecayAmount", decay, "Amount at which hunger should decay", nil, {
    data = {min = 0, max = 5},
    category = "Survival System"
})

ix.config.Add("thirstDecaySpeed", speed, "Speed at which thirst should decay.", nil, {
    data = {min = 100, max = 600},
    category = "Survival System"
})

ix.config.Add("thirstDecayAmount", decay, "Amount at which thirst should decay", nil, {
    data = {min = 0, max = 5},
    category = "Survival System"
})

if SERVER then
    function PLUGIN:OnCharacterCreated(client, character)
        character:SetData("hunger", 100)
        character:SetData("thirst", 100)
    end

    function PLUGIN:PlayerLoadedCharacter(client, character)
        timer.Simple(0.25, function()
            client:SetLocalVar("hunger", character:GetData("hunger", 100))
            client:SetLocalVar("thirst", character:GetData("thirst", 100))
        end)
    end

    function PLUGIN:CharacterPreSave(character)
        local client = character:GetPlayer()

        if (IsValid(client)) then
            character:SetData("hunger", client:GetLocalVar("hunger", 0))
            character:SetData("thirst", client:GetLocalVar("thirst", 0))
        end
    end

    local playerMeta = FindMetaTable("Player")

    function playerMeta:SetHunger(amount)
        local char = self:GetCharacter()

        if (char) then
            char:SetData("hunger", amount)
            self:SetLocalVar("hunger", amount)
        end
    end

    function playerMeta:SetThirst(amount)
        local char = self:GetCharacter()

        if (char) then
            char:SetData("thirst", amount)
            self:SetLocalVar("thirst", amount)
        end
    end

    function playerMeta:TickThirst(amount)
        local char = self:GetCharacter()

        if (char) then
            char:SetData("thirst", char:GetData("thirst", 100) - amount)
            self:SetLocalVar("thirst", char:GetData("thirst", 100) - amount)

            if char:GetData("thirst", 100) < 0 then
                char:SetData("thirst", 0)
                self:SetLocalVar("thirst", 0)
            end
        end
    end

    function playerMeta:TickHunger(amount)
        local char = self:GetCharacter()

        if (char) then
            char:SetData("hunger", char:GetData("hunger", 100) - amount)
            self:SetLocalVar("hunger", char:GetData("hunger", 100) - amount)

            if char:GetData("hunger", 100) < 0 then
                char:SetData("hunger", 0)
                self:SetLocalVar("hunger", 0)
            end
        end
    end

    function PLUGIN:PlayerTick(ply)
        if ply:GetNetVar("hungertick", 0) <= CurTime() then
            ply:SetNetVar("hungertick", ix.config.Get("hunger_decay_speed", 300) + CurTime())
            ply:TickHunger(ix.config.Get("hunger_decay_amount", 1))
        end

        if ply:GetNetVar("thirsttick", 0) <= CurTime() then
            ply:SetNetVar("thirsttick", ix.config.Get("thirst_decay_speed", 300) + CurTime())
            ply:TickThirst(ix.config.Get("thirst_decay_amount", 1))
        end
    end
else
    ix.bar.Add(function()
        local status = ""
        local var = LocalPlayer():GetLocalVar("hunger", 0) / 100

        if var < 0.2 then
            status = ""
        elseif var < 0.4 then
            status = ""
        elseif var < 0.6 then
            status = ""
        elseif var < 0.8 then
            status = ""
        end

        return var, status
    end, Color(171, 67, 40), nil, "hunger")

    ix.bar.Add(function()
        local status = ""
        local var = LocalPlayer():GetLocalVar("thirst", 0) / 100

        if var < 0.2 then
            status = ""
        elseif var < 0.4 then
            status = ""
        elseif var < 0.6 then
            status = ""
        elseif var < 0.8 then
            status = ""
        end

        return var, status
    end, Color(0, 119, 101), nil, "thirst")
end

local playerMeta = FindMetaTable("Player")

function playerMeta:GetHunger()
    local char = self:GetCharacter()

    if (char) then
        return char:GetData("hunger", 100)
    end
end

function playerMeta:GetThirst()
    local char = self:GetCharacter()

    if (char) then
        return char:GetData("thirst", 100)
    end
end

function PLUGIN:AdjustStaminaOffset(client, offset)
    if client:GetHunger() < 15 or client:GetThirst() < 20 then
        return -1
    end
end




--TODO: Populate Hunger and Thirst Items.
--TODO: Drown out colors and restrict stamina restoration for hungry / thirsty players.
local hunger_items = {
    ["cook"] = {
        ["name"]    = "Печенье",
        ["model"]   = "models/hlvr/food/biscuits_box_1.mdl",
        ["desc"]    = "Небольшие мучные кондитерские изделия различной формы и пониженной влажности.",
        ["hunger"]  = 20,
        ["thirst"]  = 0,
    },
    ["kola"] = {
        ["name"]    = "Кока-кола",
        ["model"]   = "models/hlvr/food/can_1.mdl",
        ["desc"]    = "Кока-кола.",
        ["hunger"]  = 0,
        ["thirst"]  = 50,
      },
    ["cookcombine"] = {
        ["name"]    = "Печенье Альянса",
        ["model"]   = "models/hlvr/food/biscuits_box_1_combine.mdl",
        ["desc"]    = "Небольшие мучные кондитерские изделия различной формы и пониженной влажности, производитель печенья - Альянс.",
        ["hunger"]  = 35,
        ["thirst"]  = 0,
    },
    ["cookcombine"] = {
        ["name"]    = "Арбуз",
        ["model"]   = "models/props_junk/watermelon01.mdl",
        ["desc"]    = "арбуз сытный и вкусный.",
        ["hunger"]  = 45,
        ["thirst"]  = 30,
    },
    ["cookcombine"] = {
        ["name"]    = "ХэдКраб",
        ["model"]   = "models/Lamarr.mdl",
        ["desc"]    = "ХэдКраб что вы можете его сьесть?.",
        ["hunger"]  = 30,
        ["thirst"]  = 0,
    },
    ["crackers"] = {
        ["name"]    = "Крэкеры",
        ["model"]   = "models/hlvr/food/crackers_box_1.mdl",
        ["desc"]    = "Хрустящее печенье со слоистой структурой и маслянистой поверхностью.",
        ["hunger"]  = 25,
        ["thirst"]  = 0,
    },
    ["bread"] = {
        ["name"]    = "Хлеб",
        ["model"]   = "models/uu_branded/bioshockinfinite/dread_loaf.mdl",
        ["desc"]    = "Хлебобулочное изделие продолговатой формы.",
        ["hunger"]  = 30,
        ["thirst"]  = 0,
    },
    ["cabbage"] = {
        ["name"]    = "Капуста",
        ["model"]   = "models/hlvr/food/cabbage01a.mdl",
        ["desc"]    = "Двулетнее растение, сельскохозяйственная культура.",
        ["hunger"]  = 35,
        ["thirst"]  = 0,
    },
     ["salat"] = {
        ["name"]    = "Салат",
        ["model"]   = "models/uu_branded/mres/consumables/lag_mre.mdl",
        ["desc"]    = "Смешаные овощи.",
        ["hunger"]  = 50,
        ["thirst"]  = 15,
    },
     ["soup"] = {
        ["name"]    = "Суп",
        ["model"]   = "models/hlvr/food/spam_3.mdl",
        ["desc"]    = "Суп приготовленый своими руками",
        ["hunger"]  = 64,
        ["thirst"]  = 75,
    },
    
    ["teaa"] = {
        ["name"]    = "Чай в банке",
        ["model"]   = "models/uu_branded/bioshockinfinite/xoffee_mug_closed.mdl",
        ["desc"]    = "Чай в банке",
        ["hunger"]  = 0,
        ["thirst"]  = 100,
    },
    
    ["spam"] = {
        ["name"]    = "Овощной суп",
        ["model"]   = "models/hlvr/food/spam_3.mdl",
        ["desc"]    = "Консервированный суп с овощами.",
        ["hunger"]  = 45,
        ["thirst"]  = 0,
        
    },
    ["ration_bar"] = {
        ["name"]    = "Вода Альянса",
        ["model"]   = "models/props_junk/popcan01a.mdl",
        ["desc"]    = "Небольшая бутылка наполненная водой Альянса.",
        ["hunger"]  = 0,
        ["thirst"]  = 45,
    },
    ["potato"] = {
        ["name"]    = "Картошка",
        ["model"]   = "models/uu_branded/bioshockinfinite/hext_potato.mdl",
        ["desc"]    = "Небольшой пакет наполненный картошкой.",
        ["hunger"]  = 25,
        ["thirst"]  = 0,
    },
    ["hotpotato"] = {
        ["name"]    = "Жареная картошка",
        ["model"]   = "models/uu_branded/bioshockinfinite/bag_of_hhips.mdl",
        ["desc"]    = "Небольшой пакет наполненный картошкой.",
        ["hunger"]  = 65,
        ["thirst"]  = 0,
    },
    ["ogurec"] = {
        ["name"]    = "Огурец",
        ["model"]   = "models/hlvr/food/zucchini01a.mdl",
        ["desc"]    = "Огурец.",
        ["hunger"]  = 12,
        ["thirst"]  = 1,
    },
    ["water_vend"] = {
        ["name"]    = "Вода",
        ["model"]   = "models/uu_branded/props_lunk/popcan01a.mdl",
        ["desc"]    = "Синяя банка с водой.",
        ["hunger"]  = 0,
        ["thirst"]  = 65,
        
    },
    ["headkrabicdeadinside"] = {
        ["name"]    = "Сердце хэд-краба",
        ["model"]   = "models/hlvr/food/headcrab_gland.mdl",
        ["desc"]    = "Только для вортов",
        ["hunger"]  = 63,
        ["thirst"]  = 12,
    },
    ["supervoda"] = {
        ["name"]    = "Огромная бутылка воды",
        ["model"]   = "models/props_junk/garbage_plasticbottle003a.mdl",
        ["desc"]    = "Большая бутылочка.",
        ["hunger"]  = 0,
        ["thirst"]  = 89,
    },
    ["cumchatka"] = {
        ["name"]    = "CHATKA",
        ["model"]   = "models/hlvr/food/can_square.mdl",
        ["desc"]    = "",
        ["hunger"]  = 0,
        ["thirst"]  = 34,
    },
    ["levvodka"] = {
        ["name"]    = "Водка",
        ["model"]   = "models/uu_branded/bioshockinfinite/ebsinthebottle.mdl",
        ["desc"]    = "",
        ["hunger"]  = 0,
        ["thirst"]  = 42,
    },
    ["bashkapear"] = {
        ["name"]    = "Пиво",
        ["model"]   = "models/uu_branded/bioshockinfinite/hext_bottle_lager.mdl",
        ["desc"]    = "",
        ["hunger"]  = 0,
        ["thirst"]  = 22,
    },
    ["vinod"] = {
        ["name"]    = "Вино",
        ["model"]   = "models/uu_branded/bioshockinfinite/jin_bottle.mdl",
        ["desc"]    = "",
        ["hunger"]  = 0,
        ["thirst"]  = 32,
    },
    ["can"] = {
        ["name"]    = "Вода",
        ["model"]   = "models/props_junk/popcan01a.mdl",
        ["desc"]    = "Небольшая металлическая банка наполненная водой Альянса.",
        ["hunger"]  = 0,
        ["thirst"]  = 35,
    },
    ["mpfeat1"] = {
        ["name"]    = "Пищевые добавки ГэО",
        ["model"]   = "models/uu_branded/mres/consumables/zag_mre.mdl",
        ["desc"]    = "Небольшая металлическая банка наполненная водой Альянса.",
        ["hunger"]  = 45,
        ["thirst"]  = 15,
    },
    ["citizeneat1"] = {
        ["name"]    = "Пищевые добавки",
        ["model"]   = "models/hlvr/food/ration_bar.mdl",
        ["desc"]    = "Небольшая металлическая банка с непонятной субстанцией.",
        ["hunger"]  = 35,
        ["thirst"]  = 10,
    },
}
for k, v in pairs(hunger_items) do
    local ITEM = ix.item.Register(k, nil, false, nil, true)
    ITEM.name = v.name
    ITEM.description = v.desc
    ITEM.model = v.model
    ITEM.width = v.width or 1
    ITEM.height = v.height or 1
    ITEM.category = "Еда"
    ITEM.hunger = v.hunger or 0
    ITEM.thirst = v.thirst or 0
    ITEM.empty = v.empty or false
    function ITEM:GetDescription()
        return self.description
    end
    ITEM.functions.Consume = {
        name = "Употребить",
        OnCanRun = function(item)
            if item.thirst != 0 then
                if item.player:GetCharacter():GetData("thirst", 100) >= 100 then
                    return false
                end
            end
            if item.hunger != 0 then
                if item.player:GetCharacter():GetData("hunger", 100) >= 100 then
                    return false
                end
            end
        end,
        OnRun = function(item)
            local hunger = item.player:GetCharacter():GetData("hunger", 100)
            local thirst = item.player:GetCharacter():GetData("thirst", 100)
            item.player:SetHunger(hunger + item.hunger)
            item.player:SetThirst(thirst + item.thirst)
            item.player:EmitSound("physics/flesh/flesh_impact_hard6.wav")
            if item.empty then
                local inv = item.player:GetCharacter():GetInventory()
                inv:Add(item.empty)
            end
        end
    }
end

  • Закрыта
  • Вопрос Вопрос
Вопрос профа за время?

Как сделать профессию за определенное отыгранное время? ставил uTime и ошибка с ним:

[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:866: attempt to index local 'jobTable' (a nil value)
1. unknown - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:866
2. Spawn - [C]:-1
3. unknown - gamemodes/base/gamemode/player.lua:100



[ERROR] A runtime error has occurred in "[C]" on line -1.
The best help I can give you is this:

DarkRP was unable to introduce player "развRatnik" to the game. Expect further errors and shit generally being fucked!

Hints:
- This error most likely does not stand on its own, and previous serverside errors have a very good chance of telling you the cause.
- Note that errors from another addon could cause this. Specifically when they're thrown during 'PlayerInitialSpawn'.
- This error can also be caused by some other addon returning a value in 'PlayerInitialSpawn', though that is less likely.
- Errors in your DarkRP configuration (jobs, shipments, etc.) could also cause this. Earlier errors should tell you when this is the case.

The responsibility for the error above lies with (the authors of) one (or more) of these files:
1. function 'Spawn'
2. gamemodes/base/gamemode/player.lua on line 100
------- End of Simplerr error -------

  • Закрыта
  • Решено
Вопрос проблема с plogs

Выдаёт эту штуку при сейве логов


[plogs] addons/plogs/lua/plogs/core_sh.lua:39: attempt to concatenate local 'name' (a nil value)
1. OpenSave - addons/plogs/lua/plogs/core_sh.lua:39
2. AddLogs - addons/plogs/lua/plogs/menu.lua:168
3. DoClick - addons/plogs/lua/plogs/menu.lua:199
4. unknown - lua/vgui/dlabel.lua:237

  • Вопрос Вопрос
Вопрос установка сборки UNIONRP City 2

Как установить?
вот сборка:

  • Закрыта
  • Решено
Вопрос как убрать это при запуске сервера?

Refusing to load wac_pod_gbomb because it is missing Type and Base keys!
Refusing to load wac_pod_grocket because it is missing Type and Base keys!
Refusing to load wac_pod_gunner because it is missing Type and Base keys!
Refusing to load wac_pod_jdam because it is missing Type and Base keys!
Refusing to load wac_pod_mg because it is missing Type and Base keys!
Refusing to load wac_pod_mis because it is missing Type and Base keys!

  • Вопрос Вопрос
Вопрос Как починить данную ошибку?

[voidcases] Warning! A net message (VoidCases_NetworkMarketplace) is already started! Discarding in favor of the new message! (VoidCases_SendConfigData)
1. SendConfigData - addons/voidcases/lua/voidcases/sh_config.lua:279
2. unknown - addons/voidcases/lua/voidcases/sh_config.lua:289
3. xpcall - [C]:-1
4. unknown - gamemodes/darkrp/gamemode/modules/base/sv_antinet.lua:129

  • Вопрос Вопрос
Вопрос порт плагина

Как портировать нижеупомянутые фрагменты кода с ClockWork на Helix?
sv_hooks.lua:
Развернуть Свернуть Копировать
function PLUGIN:OnePlayerSecond(player, curTime, infoTable)
    if player:GetCharacter() and player:Alive() then
        local jailtime = player:GetCharacterData("CP_JTime", 0)
        local jailreason = player:GetCharacterData("CP_JReason", "#N")

        if jailreason != "#N" then
            if jailtime > 0 then   
                player:SetCharacterData("CP_JTime", jailtime - 1)
            elseif jailtime <= 0 then
                if !player.isolationRemind or CurTime() >= player.isolationRemind then
                    local mark = (player:GetFaction() == FACTION_MPF or player:GetFaction() == FACTION_OTA) and " юнита " or " объекта "
                    self:SayCPRadio(nil, "Изоляция"..mark.."#"..Schema:GetDigits(player).." завершена.")
                    player.isolationRemind = CurTime() + 60
                end
            end
        end
    end
end

sh_plugin.lua:
Развернуть Свернуть Копировать
local PLUGIN = PLUGIN

util.Include("sv_hooks.lua")

sh_jailrequest.lua:
Развернуть Свернуть Копировать
local PLUGIN = PLUGIN
local COMMAND = cw.command:New("JailRequest");
COMMAND.tip = "Request an isolation for citizen.";
COMMAND.text = "<string CID> <string REASON> <number TIME(min)>";
COMMAND.flags = bit.bor(CMD_DEFAULT, CMD_DEATHCODE, CMD_FALLENOVER);
COMMAND.arguments = 3;

-- Called when the command has been run.
function COMMAND:OnRun(combine, arguments)
    if combine:GetFaction() == FACTION_MPF then
        local stringCID = arguments[1]
        local stringREASON = arguments[2]
        local numberTIME = tonumber(arguments[3])

        for k,v in pairs(player.GetAll()) do
            if Schema:GetDigits(v) == stringCID then
                if v:GetCharacterData("CP_JReason") == "#N" then
                    cw.player:SayRadio(combine, "Центр, запрашиваю изоляцию гражданина #"..stringCID..", причина: "..stringREASON..", время изоляции: "..numberTIME.." минут.", true)

                    v:SetCharacterData("CP_JReason", stringREASON)                       
                    v:SetCharacterData("CP_JTime", numberTIME * 60)                   
                    
                    timer.Simple(2, function()
                        chatbox.AddText(combine, center.."Запрос изоляции гражданина #"..stringCID.." был подтвержден."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
                    end)
                end
                return
            end
        end
    end
end;

COMMAND:Register();

sh_jailinforequest.lua:
Развернуть Свернуть Копировать
local PLUGIN = PLUGIN
local COMMAND = cw.command:New("JailInfoRequest");
COMMAND.tip = "Request information about isolated citizens.";
COMMAND.text = "";
COMMAND.flags = bit.bor(CMD_DEFAULT, CMD_DEATHCODE, CMD_FALLENOVER);
COMMAND.arguments = 0;

-- Called when the command has been run.
function COMMAND:OnRun(combine, arguments)
    local center = "Центр говорит по рации <:: "
    local centerend = " ::>"
    if Schema:PlayerIsCombine(combine) then
        cw.player:SayRadio(combine, "Запрашиваю информацию о заключённых.", true)

        timer.Simple(2, function()                   
            combine:EmitSound("npc/combine_soldier/vo/off"..math.random(1, 2)..".wav")
            chatbox.AddText(combine, center.."Запрос информации о заключённых был подтвержден."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
            local i = 0
            for k, v in pairs(player.GetAll()) do
                if v:GetCharacterData("CP_JReason", "#N") != "#N" then
                    local citizenID = Schema:GetDigits(v)   
                    i = i + 1
                    chatbox.AddText(combine, center..i..". "..v:Name().." #"..citizenID.."."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
                    chatbox.AddText(combine, center.."Причина задержания: "..v:GetCharacterData("CP_JReason").."."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
                    chatbox.AddText(combine, center.."Осталось: "..math.Round((tonumber(v:GetCharacterData("CP_JTime", 0))/60)).." минут(ы/а)."..centerend, {filter = "default", textColor = Color(10, 200, 10, 255), icon = false, radius = 0})
                end
            end
        end)
    end
end

COMMAND:Register();

  • Вопрос Вопрос
Вопрос Не работает хук

Всем привет, короче на абсолютно пустом сервере (аддонов, кроме веапон селектора нет), появился баг или ошибка. Худ HUDShouldDraw не работает.
В стандартной камере заложен скрипт который должен убирать веапон селектор и чат, но этого не происходит. Также если отдельно от свепа камеры сделать хук на ремув отображения веапон селектора, то это нихуя не поможет.
1682188378328.png

Оригинальный скрипт камеры:
Развернуть Свернуть Копировать
function SWEP:HUDShouldDraw( name )

    -- So we can change weapons
    if ( name == "CHudWeaponSelection" ) then return true end
    if ( name == "CHudChat" ) then return true end

    return false

end
Второстепенный скрипт на худ:
Развернуть Свернуть Копировать
hook.Add( "HUDShouldDraw", "HideHUD", function( name )
    if ( name == "CHudWeaponSelection" ) then return true end
end )
Ещё одна вариация скрипта, которая также не убирает веапон селектор:
Развернуть Свернуть Копировать
local hide = {
    ["CHudHealth"] = true,
    ["CHudWeaponSelection"] = true
}

hook.Add( "HUDShouldDraw", "HideHUD", function( name )
    if ( hide[ name ] ) then
        return false
    end

    -- Don't return anything here, it may break other addons that rely on this hook.
end )
Баг не зависит от аддона на веапон селектор, при удалении мною упомянутого аддона всё равно веапон селектор остаётся. Ошибок если что нигде, никуда, ничего не выдаёт.

  • Закрыта
  • Решено
Вопрос помогите с кодом

[sam-148] lua/includes/modules/draw.lua:180: attempt to index local 'color' (a nil value)
1. RoundedBox - lua/includes/modules/draw.lua:180
2. unknown - addons/sam-148/lua/sam/menu/cl_init.lua:139

Вложения

  • Вопрос Вопрос
Вопрос Ошибка ArcCw

Такая проблема с этими аддонами
ArcCw Base
[ArcCW] Modern Warfare 3 Pack. (steam)

Darkrp - режим игры
Сама ошибка:
Код:
Развернуть Свернуть Копировать
[arccw_base] lua/autorun/tableex.lua:2: bad argument #1 to 'ipairs' (table expected, got nil)
  1. ipairs - [C]:-1
   2. Add - lua/autorun/tableex.lua:2
    3. BarrelHitWall - addons/arccw_base/lua/weapons/arccw_base/shared.lua:899
     4. unknown - addons/arccw_base/lua/weapons/arccw_base/sh_think.lua:299 (x182)
Постоянно появляется на всех паках, если оружие в руках

Статистика форума

Темы
29,178
Сообщения
187,189
Пользователи
129,082
Новый пользователь
miok
Назад
Сверху Снизу