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

Lua Strange problem with quest chest

Zorenia

Hoster of Zorenia
Joined
Jan 21, 2009
Messages
578
Reaction score
54
Location
The Netherlands
Guys..!

got some problems with the Demon oak chest reward.

Got 4 chests:

- Demon legs (uid= 12901)
- Rainbow shield (uid= 12902)
- Royal crossbow (uid=12903)
- Spellbook of dark~ (uid= 12904)

The problem is; if I choose demon legs or Rainbow shields everything works fine. But.. if I choose royal crossbow I get a demon legs, and if I choose for the spellbook I get a Rainbow shield. It's strange but I set on none script that on that id's (12903 and 12904) you should get a demon legs or rainbow shield. Maybe I missed.. a little detail, should be easy to fix. But I can't find it!

Chest script:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local chest = {
rewards = {
[12901] = 2495, — Demon Legs
[12902] = 8905, — Rainbow Shield
[12904] = 8918, — Spellbook of Dark Mysteries
[12903] = 8851  — Royal Crossbow
},
storageId = 50090
}
if chest.rewards[item.uid] ~= nil then
if getPlayerStorageValue(cid, chest.storageId) == -1 then
doPlayerSendTextMessage(cid,22,”You have found a “.. getItemNameById(chest.rewards[item.uid]) ..”.”)
doPlayerAddItem(cid, chest.rewards[item.uid], 1)
setPlayerStorageValue(cid, chest.storageId, 1)
else
doPlayerSendTextMessage(cid,22,”It is empty.”)
end
end
return true
end

actions:
Lua:
	<action uniqueid="12901" event="script" value="quests/demonoakchest2.lua" /> — Demon Legs —
	<action uniqueid="12902" event="script" value="quests/demonoakchest2.lua" /> /> — Rainbow Shield —
	<action uniqueid="12904" event="script" value="quests/demonoakchest2.lua" /> /> — Spellbook of Dark Mysteries —
	<action uniqueid="12903" event="script" value="quests/demonoakchest2.lua" /> /> — Royal Crossbow —
 
Try this:

Lua Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local chest = {
rewards = {
[12903] = 2495, — Demon Legs
[12904] = 8905, — Rainbow Shield
[12902] = 8918, — Spellbook of Dark Mysteries
[12901] = 8851 — Royal Crossbow
},
storageId = 50090
}
if chest.rewards[item.uid] ~= nil then
if getPlayerStorageValue(cid, chest.storageId) == -1 then
doPlayerSendTextMessage(cid,22,”You have found a “.. getItemNameById(chest.rewards[item.uid]) ..”.”)
doPlayerAddItem(cid, chest.rewards[item.uid], 1)
setPlayerStorageValue(cid, chest.storageId, 1)
else
doPlayerSendTextMessage(cid,22,”It is empty.”)
end
end
return true
end

Actions:

<action uniqueid="12903" event="script" value="quests/demonoakchest2.lua" /> — Demon Legs —
<action uniqueid="12904" event="script" value="quests/demonoakchest2.lua" /> /> — Rainbow Shield —
<action uniqueid="12902" event="script" value="quests/demonoakchest2.lua" /> /> — Spellbook of Dark Mysteries —
<action uniqueid="12901" event="script" value="quests/demonoakchest2.lua" /> /> — Royal Crossbow —

It should work!
 
Guys: got solution! found a script. for everyone ;)

Lua:
	config = {
		storage = 35701,
		items = { 
			item_1 = {2495,1},  
			item_2 = {8905,1},  
			item_3 = {8851,1}, 
			item_4 = {8918,1}   
		}
	}

function onUse(cid, item, frompos, item2, topos)

   	if getPlayerStorageValue(cid,config.storage) == -1 then
   		if item.uid == 12901 then
			newItem = config.items.item_1[1]
			count = config.items.item_1[2]
   		elseif item.uid == 12902 then
			newItem = config.items.item_2[1]
			count = config.items.item_2[2]
   		elseif item.uid == 12903 then
			newItem = config.items.item_3[1]
			count = config.items.item_3[2]
   		elseif item.uid == 12904 then
			newItem = config.items.item_4[1]
			count = config.items.item_4[2]
		end

		-- MSG  Config -----------------------------------------------------------------------------------------------------------------
		msgEmpty = "It is empty."
		msgGetItem = "You have found "..getItemArticleById(newItem).." "..getItemNameById(newItem).."."
		msgNoCap = "You have found a "..getItemNameById(newItem).." weighing "..getItemWeightById(newItem,count).." oz it is too heavy."
		--------------------------------------------------------------------------------------------------------------------------------

		if getPlayerFreeCap(cid) >= getItemWeightById(newItem,count) then
   			setPlayerStorageValue(cid,config.storage,1)
   			doPlayerAddItem(cid,newItem,count)
   			doPlayerSendTextMessage(cid,21,msgGetItem)
		else
			doPlayerSendTextMessage(cid,21,msgNoCap)
		end
   	else
   		doPlayerSendTextMessage(cid,21,msgEmpty)
   	end
   	return TRUE
end
 
Back
Top