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

how count specific item in dp ?

WTF.Error

Member
Joined
Aug 8, 2007
Messages
489
Reaction score
10
I have a problem.
I need look for especial item in dps.


how i can count this ?
 
You have to be more specific, do you want a talkaction?
Example: "/countdp 2160"
Result: "00:00 There are 2100324 crystal coins stored in depots."
 
Code:
function onSay(cid, words, param, channel)
	if param == '' then
		local query = db.getResult("SELECT COUNT(*) AS total FROM player_depotitems")
		local t = query:getDataInt("total")
		query:free()
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are " .. t .. " depot item entries.")
	end
	local param = string.explode(param, ',')
	if tonumber(param[1]) and not tonumber(param[2]) then
		param[1] = tonumber(param[1])
		local g = nil
		if param[2] then
			g = getPlayerGUIDByName(param[2])
			if not g then
				return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Player " .. param[2] .. " does not exist.")
			end
		end
		local q = "SELECT SUM(count) AS sum, COUNT(*) AS total FROM player_depotitems WHERE itemtype = " .. param[1] .. (g and " AND player_id = " .. g or "")
		local query = db.getResult(q)
		local s, t, sid = query:getDataInt("sum"), query:getDataInt("total"), (param[1] < 1 or 11395 < param[1]) and 100 or param[1]
		query:free()
		local n = getItemInfo(sid).plural
		if n == '' or param[1] ~= sid then
			n = "items of type " .. param[1]
		end
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are " .. s .. " " .. n .. " stored in depots" .. (g and ", belonging to " .. getPlayerNameByGUID(g) or "") .. " (" .. t .. " entries)")
	end
	return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Invalid syntax. Usage: itemid, player name (optional)")
end
 
Back
Top