10sa / Advanced-Nutscript

Nutscript 1.0 Based New RP Framework.
MIT License
8 stars 5 forks source link

NextBot NPC의 function ENT:OnKilled에 아이템 스폰 구문을 넣었을 경우 발생하는 오류 #1

Closed Frosty1940 closed 7 years ago

Frosty1940 commented 7 years ago
local items = {}

for k, v in pairs( nut.item.GetAll() ) do
    if (v.category == "폐품") then
        items[k] = v
    end
end

local RandomItem = table.Random(items)
nut.item.Spawn(self:GetPos() + Vector(0, 0, 8), nil, RandomItem)

위와 같은 코드로 생겨난 아이템을 조준할 시, 클라이언트 사이드에서 나오는 오류

[ERROR] gamemodes/nutscript/gamemode/libs/external/sh_pon.lua:406: attempt to call a nil value

  1. decode - gamemodes/nutscript/gamemode/libs/external/sh_pon.lua:406
    1. GetData - gamemodes/nutscript/entities/entities/nut_item.lua:40
    2. DrawTargetID - gamemodes/nutscript/entities/entities/nut_item.lua:64
      1. Run - gamemodes/nutscript/gamemode/kernel/cl_kernel.lua:401
      2. unknown - gamemodes/nutscript/gamemode/kernel/cl_kernel.lua:172
10sa commented 7 years ago

해당 코드가 UTF로 인코딩 되었는지 확인 바람.

Frosty1940 commented 7 years ago

UTF-8로 인코딩 되어 있습니다.

10sa commented 7 years ago

폐품 아이템 쪽에 문제가 있는것 같은데요, 다른 아이템 아무거나 한가지만 (카테고리 단위로 말고) 넣어서 확인 부탁드립니다.

Frosty1940 commented 7 years ago

[ERROR] gamemodes/nutscript/gamemode/libs/external/sh_pon.lua:406: attempt to call a nil value

  1. decode - gamemodes/nutscript/gamemode/libs/external/sh_pon.lua:406
    1. GetData - gamemodes/nutscript/entities/entities/nut_item.lua:60
    2. DrawTargetID - gamemodes/nutscript/entities/entities/nut_item.lua:84
      1. Run - gamemodes/nutscript/gamemode/kernel/cl_kernel.lua:401
      2. unknown - gamemodes/nutscript/gamemode/kernel/cl_kernel.lua:172
    local items = {}

    for k, v in SortedPairs( nut.item.GetAll() ) do
        if (v.name == "항우울제") then
            items[k] = v
        end;
    end;

    local RandomItem = table.Random(items)
    nut.item.Spawn(self:GetPos() + Vector(0, 0, 8), nil, RandomItem)

pairs도 마찬가지

10sa commented 7 years ago

해당 아이템 코드를 올려주십시요.

Frosty1940 commented 7 years ago
ITEM.name = "항우울제"
ITEM.desc = "우울한 감정을 싹 떨쳐버리게 만들어 줍니다."
ITEM.model = Model("models/props_lab/box01a.mdl")
ITEM.functions = {}
ITEM.price = 15
ITEM.weight = .3
ITEM.functions.Use = {
    text = "빨아들이기",
    run = function(item)
        if (CLIENT) then
            item.player:EmitSound("music/stingers/industrial_suspense1.wav", 60)
        else
            local client = item.player

            client:SetNetVar("noDepress", client:GetNetVar("noDepress", 0) - 0.5)
            client:SetNetVar("blur", 0.95)

            timer.Simple(8, function()
                if (IsValid(client)) then
                    client:SetNetVar("blur", 0)
                    client:SetNetVar("noDepress", client:GetNetVar("noDepress", 0) + 1)
                end
            end)

            timer.Simple(128, function()
                if (IsValid(client)) then
                    client:SetNetVar("noDepress", client:GetNetVar("noDepress", 0.5) - 0.5)
                end
            end)
        end
    end
}
Frosty1940 commented 7 years ago
BASE.name = "Base Junk"
BASE.uniqueID = "base_junk"
BASE.category = "폐품"
BASE.worth = 5
BASE.noBusiness = true
BASE.isJunk = true
BASE.functions = {}
BASE.functions.Scrap = {
    text = "분해하기",
    menuOnly = true,
    run = function(itemTable, client, data)
        if (SERVER) then
            local amount = math.max(itemTable.worth + math.random(-5, 5), 1)

            timer.Simple(0.7, function()
                if (!IsValid(client)) then
                    return
                end

                nut.util.Notify("아이템을 분해하여 "..nut.currency.GetName(amount).." 만큼을 얻었습니다.", client)
                client:GiveMoney(amount)
            end)
        else
            surface.PlaySound("buttons/button5.wav")
        end
    end
}
10sa commented 7 years ago

Fixed.