• 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!

Key_100001

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
My script don't work:
\data\actions\scripts\quests\key_100001.lua
Code:
dofile('data/actions/lib/lib-key_100001.lua')

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid == itemUid1 then
	if getPlayerStorageValue(cid, storage) == FALSE then
	   doSetItemActionId(woodenKey, 100001)
	   doPlayerSendTextMessage(cid, msgStyle, msgFound)
	   setPlayerStorageValue(cid, storage, TRUE)
	 elseif getPlayerStorageValue(cid, storage) == TRUE then
	   doPlayerSendTextMessage(cid, msgStyle1, msgEmpty)

	 elseif item.uid == itemUid2 then
	if getPlayerStorageValue(cid, storage) == FALSE then
	   doSetItemActionId(woodenKey, 100001)
	   doPlayerSendTextMessage(cid, msgStyle, msgFound)
	   setPlayerStorageValue(cid, storage, TRUE)
	 elseif getPlayerStorageValue(cid, storage) == TRUE then
	   doPlayerSendTextMessage(cid, msgStyle1, msgEmpty)
   end
  end
 end
   return TRUE
end

\data\actions\lib\lib-key_100001.lua
Code:
itemUid1 = 35001
itemUid2 = 35002
storage = 100001
itemChest = 2087
msgStyle = MESSAGE_INFO_DESCR
msgFound = "You have found a Wooden Key."
msgEmpty = "It is empty."
woodenKey = doPlayerAddItem(cid, itemChest, 1)

\data\actions\actions.xml
Code:
	<action uniqueid="35001" script="quests/key_100001.lua" />
	<action uniqueid="35002" script="quests/key_100001.lua" />

Please help-me.
 
try changing the place of
PHP:
dofile('data/actions/lib/lib-key_100001.lua')

function onUse(cid, item, fromPosition, itemEx, toPosition)
so it's like this
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
dofile('data/actions/lib/lib-key_100001.lua')
 
Code:
woodenKey = doPlayerAddItem(cid, itemChest, 1)
cid is nil, it should be in the script itself, not in some random file.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local woodenKey = doPlayerAddItem(cid, itemChest, 1)
~~~~~~
 
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	dofile('data/actions/lib/lib-key_100001.lua')
	if item.uid == itemUid1 then
	if getPlayerStorageValue(cid, storage) == FALSE then
	   doSetItemActionId(woodenKey, 100001)
	   doPlayerSendTextMessage(cid, msgStyle, msgFound)
	   setPlayerStorageValue(cid, storage, TRUE)
	 elseif getPlayerStorageValue(cid, storage) == TRUE then
	   doPlayerSendTextMessage(cid, msgStyle, msgEmpty)

	 elseif item.uid == itemUid2 then
	if getPlayerStorageValue(cid, storage) == FALSE then
	   doSetItemActionId(woodenKey, 100001)
	   doPlayerSendTextMessage(cid, msgStyle, msgFound)
	   setPlayerStorageValue(cid, storage, TRUE)
	 elseif getPlayerStorageValue(cid, storage) == TRUE then
	   doPlayerSendTextMessage(cid, msgStyle, msgEmpty)
   end
  end
 end
   return TRUE
end
 
PHP:
local itemUid1 = 35001
local itemUid2 = 35002
local storage = 100001
local itemChest = 2087
local msgStyle = MESSAGE_INFO_DESCR
local msgFound = "You have found a Wooden Key."
local msgEmpty = "It is empty."

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == itemUid1 then
    if getPlayerStorageValue(cid, storage) <= FALSE then
       woodenKey = doPlayerAddItem(cid, itemChest, 1)
       doSetItemActionId(woodenKey, 100001)
       doPlayerSendTextMessage(cid, msgStyle, msgFound)
       setPlayerStorageValue(cid, storage, TRUE)
     elseif getPlayerStorageValue(cid, storage) == TRUE then
       doPlayerSendTextMessage(cid, msgStyle, msgEmpty)

     elseif item.uid == itemUid2 then
    if getPlayerStorageValue(cid, storage) <= FALSE then
       woodenKey = doPlayerAddItem(cid, itemChest, 1)
       doSetItemActionId(woodenKey, 100001)
       doPlayerSendTextMessage(cid, msgStyle, msgFound)
       setPlayerStorageValue(cid, storage, TRUE)
     elseif getPlayerStorageValue(cid, storage) == TRUE then
       doPlayerSendTextMessage(cid, msgStyle, msgEmpty)
   end
  end
 end
   return TRUE
end

How about that?
 
Use this instead:
replace setItemActionId with
Code:
doSetItemActionId(doPlayerAddItem(cid, id, 1), 10001)
 
PHP:
local itemUid1 = 35001
local itemUid2 = 35002
local storage = 100001
local itemChest = 2087
local msgStyle = MESSAGE_INFO_DESCR
local msgFound = "You have found a Wooden Key."
local msgEmpty = "It is empty."

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid == itemUid1 then
		if getPlayerStorageValue(cid, storage) <= FALSE then
			woodenKey = doPlayerAddItem(cid, itemChest, 1)
			doSetItemActionId(woodenKey, 100001)
			doPlayerSendTextMessage(cid, msgStyle, msgFound)
			setPlayerStorageValue(cid, storage, TRUE)
		elseif getPlayerStorageValue(cid, storage) == TRUE then
			doPlayerSendTextMessage(cid, msgStyle, msgEmpty)
		end
	elseif item.uid == itemUid2 then
		if getPlayerStorageValue(cid, storage) <= FALSE then
			woodenKey = doPlayerAddItem(cid, itemChest, 1)
			doSetItemActionId(woodenKey, 100001)
			doPlayerSendTextMessage(cid, msgStyle, msgFound)
			setPlayerStorageValue(cid, storage, TRUE)
		elseif getPlayerStorageValue(cid, storage) == TRUE then
			doPlayerSendTextMessage(cid, msgStyle, msgEmpty)
		end
	end
	return TRUE
end
Fixed some syntax and ends etc. and tabbed
 
Back
Top