trollebror
Developer
Hello,
I will share these two scripts because they're so extremely useful. I'm sure that something similar already have been posted but here is my version of it.
I'm using TFS 1.1.
What does it do?
It allows you to set and get any online player storage with talkactions.
Usage examples
!setstorage God Trollebror, 25000, 1
!getstorage God Trollebror, 25000
Code
global.lua
talkactions.xml
set_storage.lua
get_storage.lua
I will share these two scripts because they're so extremely useful. I'm sure that something similar already have been posted but here is my version of it.

I'm using TFS 1.1.
What does it do?
It allows you to set and get any online player storage with talkactions.
Usage examples
!setstorage God Trollebror, 25000, 1
!getstorage God Trollebror, 25000
Code
global.lua
Code:
function string.trim(self)
return (self:gsub("^%s*(.-)%s*$", "%1"))
end
talkactions.xml
Code:
<talkaction words="!setstorage" separator=" " script="set_storage.lua"/>
<talkaction words="!getstorage" separator=" " script="get_storage.lua"/>
set_storage.lua
Code:
function onSay(player, words, param, type)
if not player:getGroup():getAccess() then
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then
return false
end
-- Extract the specified parameters.
local parameters = param:split(",")
if parameters[3] == nil then
player:sendCancelMessage("Insufficient parameters, usage: !setstorage playerName, key, value")
return false
end
-- Remove trailing/leading white spaces from parameters.
local playerName = (parameters[1] or ""):trim()
local storageKey = tonumber(parameters[2]) or 0
local storageValue = tonumber(parameters[3]) or 0
-- Get meta player.
local checkedPlayer = Player(playerName)
if not checkedPlayer then
player:sendCancelMessage(string.format("Could not find player '%s'.", playerName))
player:getPosition():sendMagicEffect(CONST_ME_BUBBLES)
return false
end
-- Set specified storage value on player.
checkedPlayer:setStorageValue(storageKey, storageValue)
-- Print the message in Local Chat in orange (only self can see).
player:sendTextMessage(MESSAGE_EVENT_ORANGE, string.format("Storage key '%s' was set to '%s' for player '%s'.", storageKey, storageValue, checkedPlayer:getName()))
player:getPosition():sendMagicEffect(CONST_ME_BUBBLES)
end
get_storage.lua
Code:
function onSay(player, words, param, type)
if not player:getGroup():getAccess() then
return true
end
if player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then
return false
end
-- Extract the specified parameters.
local parameters = param:split(",")
if parameters[2] == nil then
player:sendCancelMessage("Insufficient parameters, usage: !getstorage playerName, key")
return false
end
-- Remove trailing/leading white spaces from parameters.
local playerName = (parameters[1] or ""):trim()
local storageKey = tonumber(parameters[2]) or 0
-- Get meta player.
local checkedPlayer = Player(playerName)
if not checkedPlayer then
player:sendCancelMessage(string.format("Could not find player '%s'.", playerName))
player:getPosition():sendMagicEffect(CONST_ME_BUBBLES)
return false
end
-- Get specified storage value from player.
local storageValue = checkedPlayer:getStorageValue(storageKey)
-- Print the message in Local Chat in orange (only self can see).
player:sendTextMessage(MESSAGE_EVENT_ORANGE, string.format("Storage key '%s' is currently set to '%d' for player '%s'.", storageKey, storageValue, checkedPlayer:getName()))
player:getPosition():sendMagicEffect(CONST_ME_BUBBLES)
end