• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Action id key in a chest

Kisskotte

New Member
Joined
May 26, 2008
Messages
60
Reaction score
1
Hello

I'm wondering if its posible to make a key with a certain action id be in a chest that only can be loot once per player. have tried to use Rme. and put the key in the chest and put the action id on the key but when i try it the key is just inside the chest and u can loot it once per restart and the same player can loot it. I have done some chest that you can loot once per char. But have no ide how to make an item in the chest with a action id.

here is an example of code of a quest chest so you know what kind of codes.

Questbox.lua
Code:
        elseif item.uid == 10609 then
			queststatus = getPlayerStorageValue(cid,10609)
		if queststatus == -1 then
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"Here is your new start gear.")
			doPlayerAddItem(cid,2457,1)
			doPlayerAddItem(cid,2465,1)
			doPlayerAddItem(cid,2478,1)
			doPlayerAddItem(cid,2643,1)
			doPlayerAddItem(cid,2456,1)
			doPlayerAddItem(cid,2175,1)
			doPlayerAddItem(cid,2544,100)
			setPlayerStorageValue(cid,10609,1)
		else
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"The chest is empty.")
	end

Actions.xml
Code:
<action uniqueid="10609" script="questbox.lua" />

/R.
 
TFS 0.3.7:

LUA:
local t = {
	[1000] = { -- Chest Action Id
		storage = 10609, -- Storage
		keyId = 2090, -- Key Item Id
		actionId = 2001 -- Key Action Id
	}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k = t[item.actionid]
	if k then
		if getPlayerStorageValue(cid, k.storage) < 0 then
			local id = doCreateItemEx(k.keyId, 1)
			if doPlayerAddItemEx(cid, id) ~= RETURNVALUE_NOERROR then
				doPlayerSendCancel(cid, "You cannot carry this item.")
			else
				doItemSetAttribute(id, "aid", k.actionId)
				setPlayerStorageValue(cid, k.storage, 1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a " .. getItemInfo(k.keyId).name .. "!")
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "The " .. getItemInfo(item.itemid).name .. " is empty.")
		end
	end
	return true
end

TFS 0.2.12:

LUA:
local t = {
	[1000] = { -- Chest Action Id
		storage = 10609, -- Storage
		keyId = 2090, -- Key Item Id
		actionId = 2001 -- Key Action Id
	}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k = t[item.actionid]
	if k then
		if getPlayerStorageValue(cid, k.storage) < 0 then
			local id = doCreateItemEx(k.keyId, 1)
			if doPlayerAddItemEx(cid, id) ~= RETURNVALUE_NOERROR then
				doPlayerSendCancel(cid, "You cannot carry this item.")
			else
				doSetItemActionId(id, k.actionId)
				setPlayerStorageValue(cid, k.storage, 1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a " .. getItemName(k.keyId) .. "!")
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "The " .. getItemName(item.itemid) .. " is empty.")
		end
	end
	return true
end
 
Last edited:
rme option:
put key with action id into chest
set action id 2000 on chest

Has tried that but then can you loot the chest one time per restart and the same person can loot it. the chest will just open like a non action id and it will just be a key inside :)
 
rme option:
put key with action id into chest
set action id 2000 on chest

edit:
forgot, u have to set unique id on chest (it will be your storage id)
should be:
put key with action id into chest
set action id 2000 on chest
set unique id on chest

and tell me, what distribution are you using?
if any of TFS over 3.4, this solution works or you are doing something wrong.

and open your actions.xml, locate there id of your chest and paste its script here
 
Back
Top