44 Hunter
New Member
- Joined
- Dec 14, 2017
- Messages
- 18
- Reaction score
- 4
Could someone add some functions to my script? Are they:
I want to be able to add an actionID to the item.
I also need the items to be delivered inside a bag.
It is also necessary to set an actionID on the item if it is inside a bag.
I want to be able to add an actionID to the item.
I also need the items to be delivered inside a bag.
It is also necessary to set an actionID on the item if it is inside a bag.
Lua:
local configs = {
uniqueIds = {
[2001] = {storage = PlayerStorageKeys.AlawarsVault, receiveItem = {id = 2089, actionId = 4503}, magicEffect = 30, message = "The reward you chose was %s."},
}
}
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local config = configs.uniqueIds[item.uid]
if not config then
return true
end
if player:getStorageValue(config.storage) >= 0 then
player:sendCancelMessage("You have already received a reward.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
local item = Game.createItem(config.receiveItem.id, config.receiveItem.count)
if player:addItemEx(item) ~= RETURNVALUE_NOERROR then
player:sendCancelMessage("You don't have the capacity or space to pick up the item.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
player:setStorageValue(config.storage, 1)
player:getPosition():sendMagicEffect(config.magicEffect)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, config.message:format(ItemType(config.receiveItem.id):getName()))
return true
end
for k, v in pairs(configs.uniqueIds) do
action:uid(k)
end
action:register()