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:
**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: