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

Solved Znote Shop_System error

mernes

New Member
Joined
Jul 30, 2009
Messages
41
Reaction score
0
Hey guys, so I just installed znote AAC and fixed shop system for my otserver, I got myself points and tried donate.. I got my item on the website, and to get the item I had to go on the tibia server and write !shop ingame to get the item.. nothing happend, checked the console and this error showed up:
[Error - TalkAction Interface]
data/talkactions/scripts/znoteshop.lua: onSay
Description:
data/talkactions/scripts/znoteshop.lua:28: attempt to call field 'executeQuery' (a nil value)
stack traceback:
data/talkactions/scripts/znoteshop.lua:28: in function <data/talkactions/scripts/znoteshop.lua:2>

Here is the Znoteshop.lua
Lua:
-- Znote Shop v1.0 for Znote AAC on TFS 0.3.6+ Crying Damson.
function onSay(cid, words, param)
	local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
	local cooldown = 15 -- in seconds.
	
	if getPlayerStorageValue(cid, storage) <= os.time() then
		setPlayerStorageValue(cid, storage, os.time() + cooldown)
		local accid = getAccountNumberByPlayerName(getCreatureName(cid))
		
		-- Create the query
		local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. " LIMIT 1;")
		
		-- Detect if we got any results
		if orderQuery ~= false then
			-- Fetch order values
			local q_id = result.getDataInt(orderQuery, "id")
			local q_type = result.getDataInt(orderQuery, "type")
			local q_itemid = result.getDataInt(orderQuery, "itemid")
			local q_count = result.getDataInt(orderQuery, "count")
			result.free(orderQuery)
			
			-- ORDER TYPE 1 (Regular item shop products)
			if q_type == 1 then
				-- Get wheight
				local playerCap = getPlayerFreeCap(cid)
				local itemweight = getItemWeightById(q_itemid, q_count)
					if playerCap >= itemweight then
						db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
						doPlayerAddItem(cid, q_itemid, q_count)
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!")
					else
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
					end
			end
			-- Add custom order types here
			-- Type 2 is reserved for premium days and is handled on website, not needed here.
			-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
			-- So use type 4+ for custom stuff, like etc packages.
			-- if q_type == 4 then
			-- end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")
		end
		
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
	end
	return false
end

So from what I'd say, something is wrong here:
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
Although can't find what the problem is..
I've searched a bit on the otland, find someone with the same problem but he just said he fixed it..
Thanks!
 
Last edited by a moderator:
Already tried db.query?
If that doesn't work, go to data/lib/100-compat.lua and look for a line that looks like this.
Lua:
db.executeQuery = db.query
Remove it or replace them with eachother.

Btw, next time, use the right tags for scripts.
http://otland.net/f16/proper-tagging-168098/

It worked to remove Db.executeQuery = db.query from 100-compat.lua. But what function did it have?

Ill mind to use right tags.

Thanks :)
 
db.executeQuery = db.query means that if you use db.executeQuery in a script, it becomes db.query, so if db.query is a nil value (something that doesn't exist in your server), then using db.executeQuery will also give the nil value error because it's set to db.query.
 
No, the reason why you had to change that in your 100-compat.lua is because you changed the data folder (or lib folder).
The server the lib folder was used for, uses db.query instead of db.executeQuery, so for that server db.executeQuery is a nil value. With db.executeQuery = db.query all db.executeQuery will become db.query so it's not a nil value anymore in that server.
So it's just the difference with that other server that you had to change or remove that line.
 
Last edited:
No, the reason why you had to change that in your 100-combat.lua if because you changed the data folder (or lib folder).
The server the lib folder was used for, uses db.query instead of db.executeQuery, so for that server db.executeQuery is a nil value. With db.executeQuery = db.query all db.executeQuery will become db.query so it's not a nil value anymore in that server.
So it's just the difference with that other server that you had to change or remove that line.
Okey, got it now :) Thanks
 
Back
Top