function modifier_item_arcane_armlet_active_tick:GetAttributes ()
return MODIFIER_ATTRIBUTE_MULTIPLE
end
modifier_item_arcane_armlet_active_tick = class({})
if modifier_item_arcane_armlet_active_tick == nil then
modifier_item_arcane_armlet_active_tick = class({})
end
function modifier_item_arcane_armlet_active_tick:IsHidden()
return false
end
function modifier_item_arcane_armlet_active_tick:GetTexture()
return "omniknight_repel"
end
function modifier_item_arcane_armlet_active_tick:DeclareFunctions()
local funcs = {
MODIFIER_PROPERTY_STATS_INTELLECT_BONUS ,
MODIFIER_PROPERTY_CAST_RANGE_BONUS ,
}
return funcs
end
function modifier_item_arcane_armlet_active_tick:GetAttributes()
return MODIFIER_ATTRIBUTE_MULTIPLE
end
function modifier_item_arcane_armlet_active_tick:GetModifierBonusStats_Intellect(params)
return 2.78
end
function modifier_item_arcane_armlet_active_tick:GetModifierCastRangeBonus(params)
return 13.89
end
modifier_item_arcane_armlet_active_tick = class({})
if modifier_item_arcane_armlet_active_tick == nil then
modifier_item_arcane_armlet_active_tick = class({})
end
function modifier_item_arcane_armlet_active_tick:IsHidden()
return false
end
function modifier_item_arcane_armlet_active_tick:GetTexture()
return "omniknight_repel"
end
function modifier_item_arcane_armlet_active_tick:DeclareFunctions()
local funcs = {
MODIFIER_PROPERTY_STATS_INTELLECT_BONUS ,
MODIFIER_PROPERTY_CAST_RANGE_BONUS ,
}
return funcs
end
function modifier_item_arcane_armlet_active_tick:GetAttributes()
return MODIFIER_ATTRIBUTE_MULTIPLE
end
function modifier_item_arcane_armlet_active_tick:GetModifierBonusStats_Intellect(params)
return 2.78
end
function modifier_item_arcane_armlet_active_tick:GetModifierCastRangeBonus(params)
return 13.89
end
function modifier_item_echoe_shield:OnCreated(params)
if IsServer() then
self:GetParent():AddNewModifier(self:GetParent(), self:GetAbility(), "modifier_item_aether_lens", nil)
end
end
function modifier_item_echoe_shield:OnDestroy(params)
if IsServer() then
if self:GetParent():HasModifier("modifier_item_aether_lens") then
self:GetParent():RemoveModifierByName("modifier_item_aether_lens")
end
end
end
function modifier_item_echoe_shield:OnCreated(params)
if IsServer() then
self:GetParent():AddNewModifier(self:GetParent(), self:GetAbility(), "modifier_item_aether_lens", nil)
end
end
function modifier_item_echoe_shield:OnDestroy(params)
if IsServer() then
if self:GetParent():HasModifier("modifier_item_aether_lens") then
self:GetParent():RemoveModifierByName("modifier_item_aether_lens")
end
end
end
Каждый раз после смены предмета он считается за новый и даёт возможность его разобрать или продать за фул цену, как исправить?
item:SetPurchaseTime(0)
item:SetPurchaseTime(0)
function swap_to_item(keys, ItemName)
for i=0, 5, 1 do --Fill all empty slots in the player's inventory with "dummy" items.
local current_item = keys.caster:GetItemInSlot(i)
if current_item == nil then
keys.caster:AddItem(CreateItem("item_dummy_datadriven", keys.caster, keys.caster))
end
end
keys.caster:RemoveItem(keys.ability)
keys.caster:AddItem(CreateItem(ItemName, keys.caster, keys.caster)) --This should be put into the same slot that the removed item was in.
for i=0, 5, 1 do --Remove all dummy items from the player's inventory.
local current_item = keys.caster:GetItemInSlot(i)
if current_item ~= nil then
if current_item:GetName() == "item_dummy_datadriven" then
keys.caster:RemoveItem(current_item)
end
if current_item:GetName() == ItemName then
current_item:SetPurchaseTime(0)
end
end
end
end
[ W VScript ]: Script Runtime Error: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:20: This object has been deleted from C++ and no longer exists. (Use :IsNull() to detect this.)
[ W VScript ]: stack traceback:
[ W VScript ]: [C]: in function 'GetName'
[ W VScript ]: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:20: in function 'swap_to_item'
[ W VScript ]: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:34: in function <...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:33>
function swap_to_item(keys, ItemName)
for i=0, 5, 1 do --Fill all empty slots in the player's inventory with "dummy" items.
local current_item = keys.caster:GetItemInSlot(i)
if current_item == nil then
keys.caster:AddItem(CreateItem("item_dummy_datadriven", keys.caster, keys.caster))
end
end
keys.caster:RemoveItem(keys.ability)
keys.caster:AddItem(CreateItem(ItemName, keys.caster, keys.caster)) --This should be put into the same slot that the removed item was in.
for i=0, 5, 1 do --Remove all dummy items from the player's inventory.
local current_item = keys.caster:GetItemInSlot(i)
if current_item ~= nil then
if current_item:GetName() == "item_dummy_datadriven" then
keys.caster:RemoveItem(current_item)
end
if current_item:GetName() == ItemName then
current_item:SetPurchaseTime(0)
end
end
end
end
[ W VScript ]: Script Runtime Error: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:20: This object has been deleted from C++ and no longer exists. (Use :IsNull() to detect this.)
[ W VScript ]: stack traceback:
[ W VScript ]: [C]: in function 'GetName'
[ W VScript ]: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:20: in function 'swap_to_item'
[ W VScript ]: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:34: in function <...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:33>
Там же видно, что сначала идёт AddItem, а потом уже SetPurchaseTime.у тебя в скрипте сначало удаляется предмет, потом ты пытаешься сделать ему время покупки 0, следовательно ошибка.
Заноси только что добавленный айтем в локалку, и сразу же устанавливай ей время покупки на 0, а потом делай все остальное, должно сработать.
function item_arcane_armlet_sell(keys)
if keys.caster:HasModifier("modifier_item_arcane_armlet_sell") then
keys.ability:SetPurchaseTime(0)
keys.ability:DisassembleItem(0) -- Проблема сейчас тут
end
end
function item_arcane_armlet_sell(keys)
if keys.caster:HasModifier("modifier_item_arcane_armlet_sell") then
keys.ability:SetPurchaseTime(0)
keys.ability:DisassembleItem(0) -- Проблема сейчас тут
end
end
]: Script Runtime Error: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:20: This object has been deleted from C++ and no longer exists. (Use :IsNull() to detect this.)
keys.caster:AddItem(CreateItem(ItemName, keys.caster, keys.caster)) --This should be put into the same slot that the removed item was in.
local trueItem = CreateItem(ItemName, keys.caster, keys.caster) --This should be put into the same slot that the removed item was in.
keys.caster:AddItem(trueItem)
trueItem:SetPurchaseTime(0)
]: Script Runtime Error: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:20: This object has been deleted from C++ and no longer exists. (Use :IsNull() to detect this.)
keys.caster:AddItem(CreateItem(ItemName, keys.caster, keys.caster)) --This should be put into the same slot that the removed item was in.
local trueItem = CreateItem(ItemName, keys.caster, keys.caster) --This should be put into the same slot that the removed item was in.
keys.caster:AddItem(trueItem)
trueItem:SetPurchaseTime(0)
keys.ability:DisassembleItem(0)
DisassembleItem(hItem)
DisassembleItem(trueItem)