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

TalkAction /storage AddOn (check used storages)

Thuggeh

New Member
Joined
Jul 10, 2007
Messages
201
Reaction score
1
Ever get sick of keeping track of your used storage values? Well, my team and I, are completely sick of it. So we made a little addon to the current storage function. I'm sure there is a better way to do it, but at least I give the idea for someone to clean it up. =P Have fun.

**Tested / Works for 0.3.5pl1
Use "/storage global" and "/storage player"

Replace your old data/talkactions/scripts/storage.lua with:
Code:
function onSay(cid, words, param)
if param == "global" then
local db2 = db.getResult("SELECT `key` FROM `global_storage` WHERE `key` < 65535 ORDER BY `key`;")

local var = "\n"
local var2 = "\n"

repeat
		local stor = db2:getDataString("key")
		if string.find(var, stor) then
			var = var
		else
			if string.len(var) > 450 then
					if string.find(var2, stor) or string.find(var, stor) then
						var2 = var2
					else
						var2 = var2 .. stor .. ", "
					end
			else
				var = var .. stor .. ","
			end
		end
until not(db2:next())
		db2:free()
		
local function secondGlobalMessage(cid)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Currently used global storages: '..var2..'')
end

doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Currently used global storages: '..var..'')

if string.len(var2) > 2 then
	addEvent(secondGlobalMessage,1000,cid)
end

return true
end

if param == "player" then

local db = db.getResult("SELECT `key` FROM `player_storage` WHERE `key` < 65535 ORDER BY `key`;")
local str = "\n"
local str2 = "\n"

repeat
		local storage = db:getDataString("key")
		if string.find(str, storage) then
			str = str
		else
			if string.len(str) > 450 then
					if string.find(str2, storage) or string.find(str, storage) then
						str2 = str2
					else
						str2 = str2 .. storage .. ", "
					end
			else
				str = str .. storage .. ", "
			end
		end
until not(db:next())
		db:free()
		
local function secondMessage(cid)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Currently used player storages: '..str2..'')
end

doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'Currently used player storages: '..str..'')

if string.len(str2) > 2 then
	addEvent(secondMessage,1000,cid)
end
return true	
end

	local t = string.explode(param, ",")
	if(not t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
		return true
	end

	local tid = getPlayerByNameWildcard(t[1])
	if(not tid or (isPlayerGhost(tid) and getPlayerGhostAccess(tid) > getPlayerGhostAccess(cid))) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
		return true
	end

	if(not t[3]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " [" .. t[1] .. " - " .. t[2] .. "] = " .. getPlayerStorageValue(tid, t[2]))
	else
		setPlayerStorageValue(tid, t[2], t[3])
	end

	return true
end
 
Last edited:
Just a small notice,
Lua:
if string.find(var2, stor) or string.find(var, stor) then
	var2 = var2
else
	var2 = var2 .. stor .. ", "
end
=
Lua:
var2 = (var2:find(stor) or var:find(stor)) and var2 or var2 .. stor .. ", "
It makes the script less "readable", but shorter.
 
And you gain reputation in return!

I think the script could possibly have better functionality like allowing storages over 65535 but I kept it below because there are a bunch of storages set like 10001005 that I didn't want to see. But you can always tweak it to your needs.

Enjoy!
 
i think this is a noob question but if you clear all storages values, he can make the things again? like quest etc..? "srry if is a noob question".
 
Last edited:
Yes, storage values are what keeps track of whether or not a quest has been done already. If you clear them all then they will be able to do the quest again.
 
oh, then can be good but just for reset a server hehehe! good work then :p!
 
Bump ! I tested on TFS 0.2.11.2, and only appears this error:
Code:
[05/01/2012 20:33:26] Lua Script Error: [TalkAction Interface] 
[05/01/2012 20:33:26] data/talkactions/scripts/storage.lua:onSay
[05/01/2012 20:33:26] data/talkactions/scripts/storage.lua:76: attempt to index local 't' (a nil value)
[05/01/2012 20:33:26] stack traceback:
[05/01/2012 20:33:26] 	[C]: in function '__index'
[05/01/2012 20:33:26] 	data/talkactions/scripts/storage.lua:76: in function <data/talkactions/scripts/storage.lua:1>

For what function i have to replace "t"? :S

Thanks !
 
Back
Top