T
Tibia Demon
Guest
i try use this by @Dakos but i get error. i need make 1 forth function too for remove the custom attribute using other item gem or key and make it normal item for all player
and i try add item description for say item found by playername or belong playername.
24: attempt to index global 'self' (a nil value)
i tried add the new functions to global.lua-compat.lua and data/core/player.lua still all error
and i try add item description for say item found by playername or belong playername.
TFS 1.X+ - Item what can be used only by player what get it.
Its possible? Im thinking about exp items, what can be got from x npc for something, but i want add "permission" to use it only for player what collected it (tfs 1.5 8.6)
otland.net
Lua:
local tryfornextquest2 = Action()
function tryfornextquest2.onUse(player, item, fromPos, target, toPos, isHotkey)
local reward = player:addItem(7723)
player:setUniqueItemUsage(reward)
player:sendCancelMessage("Congratulations, you have found unique scroll that only you can use it.")
-- can add decription when look in item it say [belong to playername] or [found by playername]
return true
end
tryfornextquest2:id(7722)
tryfornextquest2:register()
Lua:
UNIQUE_CUSTOM_ATTRIBUTE = "CUSTOM_UNIQUE_USAGE"
function Player.canUseUniqueItem(item)
if not item then
return nil
end
local attr = item:getCustomAttribute(UNIQUE_CUSTOM_ATTRIBUTE)
if attr and attr == self:getGuid() then
return true
end
return false
end
function Player.setUniqueItemUsage(item)
if not item then
return nil
end
return item:setCustomAttribute(UNIQUE_CUSTOM_ATTRIBUTE, self:getGuid())
end
function Item.getUniqueUsage()
local attr = self:getCustomAttribute(UNIQUE_CUSTOM_ATTRIBUTE)
if attr then
return attr
end
return false
end
--[[
function Item.removeUniqueUsage()
i cant make this.
i need to make 1 gem when i use in any uniqueUsageitem to remove [unique] and make it normal item for all players
return false
end
]]
local tryfornextquest = Action()
function tryfornextquest.onUse(player, item, fromPos, target, toPos, isHotkey)
if item:getUniqueUsage() then
if not player:canUseUniqueItem(item) then
player:sendCancelMessage("You are not allowed to use this item.")
return true
end
player:addExperience(666)
item:remove(1)
player:sendCancelMessage("blabla congratulations.")
end
return true
end
tryfornextquest:id(1948)
tryfornextquest:register()
Last edited by a moderator: