• 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 Quest not working

Spoking

Oldschool Developer
Joined
Sep 4, 2007
Messages
434
Reaction score
34
Hello, i got some problems, my quests.lua doesn't work.

Code:
local annihilatorReward = {1990, 2400, 2431, 2494}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid > 1000 and item.uid < 10000 then
		local itemWeight = getItemWeight(item.uid, 1)
		local playerCap = getPlayerFreeCap(cid)
		if isInArray(annihilatorReward, item.uid) == TRUE then
			if getPlayerStorageValue(cid, 30015) == -1 then
				if playerCap >= itemWeight then
					if item.uid == 1990 then
						container = doPlayerAddItem(cid, 1990, 1)
						doContainerAddItem(container, 2326, 1)
					else
						doPlayerAddItem(cid, item.uid, 1)
					end
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(item.uid) .. '.')
					setPlayerStorageValue(cid, 30015, 1)
				else
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(item.uid) .. ' weighing ' .. itemWeight .. ' oz it\'s too heavy.')
				end
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
			end
		elseif getPlayerStorageValue(cid, item.uid) == -1 then
			if playerCap >= itemWeight then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(item.uid) .. '.')
				doPlayerAddItem(cid, item.uid ,1)
				setPlayerStorageValue(cid, item.uid, 1)
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(item.uid) .. ' weighing ' .. itemWeight .. ' oz it\'s too heavy.')
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
		end
	else
		return FALSE
	end
	return TRUE
end

Errors i get in console:
Code:
[07/07/2008  00:19:37] Lua Script Error: [Action Interface] 
[07/07/2008  00:19:37] data/actions/scripts/quests/quests.lua:onUse

[07/07/2008  00:19:37] data/actions/scripts/quests/quests.lua:4: attempt to call global 'getItemWeight' (a nil value)
[07/07/2008  00:19:37] stack traceback:
[07/07/2008  00:19:37] 	data/actions/scripts/quests/quests.lua:4: in function <data/actions/scripts/quests/quests.lua:2>

Can somebody upload a working quest.lua

btw, i use 8.2 tfs, rev949
 
It was renamed to getItemWeightById(itemid) I guess, try that.

--

//getItemWeightById(itemid, count, <optional> precision)

It is in luascript.cpp
 
Last edited:
use :
getItemWeightById(item.id, 1)

btw I got this problem too :D changed to getitemweight~~ and now got this:
Code:
[07/07/2008  12:38:30] data/actions/scripts/quests/quests.lua:onUse

[07/07/2008  12:38:30] data/actions/scripts/quests/quests.lua:24: attempt to compare string with number
[07/07/2008  12:38:30] stack traceback:
[07/07/2008  12:38:30] 	data/actions/scripts/quests/quests.lua:24: in function <data/actions/scripts/quests/quests.lua:2>


my line number 24 : if playerCap >= itemWeight then


now deleted this linesto miss cap checking: here is my script:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid > 1000 and item.uid < 10000 then
		if getPlayerStorageValue(cid, item.uid) == -1 then
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(item.uid) .. '.')
				doPlayerAddItem(cid, item.uid ,1)
				setPlayerStorageValue(cid, item.uid, 1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
		end
	else
		return FALSE
	end
	return TRUE
end

12:51 You have found a chest.
 
Last edited:
use :
getItemWeightById(item.id, 1)

btw I got this problem too :D changed to getitemweight~~ and now got this:
Code:
[07/07/2008  12:38:30] data/actions/scripts/quests/quests.lua:onUse

[07/07/2008  12:38:30] data/actions/scripts/quests/quests.lua:24: attempt to compare string with number
[07/07/2008  12:38:30] stack traceback:
[07/07/2008  12:38:30] 	data/actions/scripts/quests/quests.lua:24: in function <data/actions/scripts/quests/quests.lua:2>


my line number 24 : if playerCap >= itemWeight then


now deleted this linesto miss cap checking: here is my script:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid > 1000 and item.uid < 10000 then
		if getPlayerStorageValue(cid, item.uid) == -1 then
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(item.uid) .. '.')
				doPlayerAddItem(cid, item.uid ,1)
				setPlayerStorageValue(cid, item.uid, 1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
		end
	else
		return FALSE
	end
	return TRUE
end

12:51 You have found a chest.

So, does it work or not?

edit: Tried, working

Thank you very much!
 
Last edited:
it writing wrong msg, as for me, also it doesnt check cap..so you got 0 cap item will drop under you.. Anybody can post really working quest.lua?
 
Back
Top