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