local addItem = doPlayerAddItem(cid, _KEY_ID_, 1)
local newItem = Item(addItem)
if newItem ~= nil then
newItem:setActionId(_YOUR_ACTION_ID_)
end
doSetItemActionId(uid,actionid)
local config = {
keyid = 2088, --itemid of the key
aid = 1000, --which actionid should the key have
storage = 5000
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if (getPlayerStorageValue(cid, config.storage) < 1) then
setPlayerStorageValue(cid, config.storage, 1)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE,"You have found a key.")
local key = doPlayerAddItem(cid, config.keyid, 1)
doSetItemActionId(key, ""..config.aid.."")
else
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE,"This chest is empty.")
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
local pItem = player:addItem(itemId, count/subtype[default = 1])
if pItem then
pItem:setActionId(actionId)
end
end
You can use
Code:doSetItemActionId(uid,actionid)