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

/getstorage /setstorage command problem tfs 1.5 8.6

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i have problem with command /setstorage, this command not set a storage value ;/ (/getstorage working without problems)
When im using it i see a message but value is still -1

Im not worked in my server for 2-3 weeks, but it working last time, so why it now have problem?

I was make a test script with line player:setStorage(x,x) and it working, so why this command has problem with same command?


Code:
-- Works for any TFS 1.X,
-- as long as versions after 1.2
-- maintain backward compatibility

function onSay(cid, words, param, type)
   local player = Player(cid)
   if not player or 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 words == "/getstorage" and parameters[2] == nil then
     player:sendCancelMessage("Insufficient parameters, usage: !getstorage playerName, key")
     return false
   end

   if words == "/setstorage" and 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

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

   local storageValue = tonumber(parameters[3]) or checkedPlayer:getStorageValue(storageKey)
   local msg = string.format("Storage key '%s' %s set to '%d' for player '%s'.", storageKey, "%s", storageValue, checkedPlayer:getName())
   if words == "/setstorage" then
     -- Set specified storage value on player.
     checkedPlayer:setStorageValue(storageKey, storageValue)
     msg = string.format(msg, "is now")
   else
     -- Get specified storage value from player.
     msg = string.format(msg, "is currently")
   end

   -- Print the message in Local Chat in orange (only self can see).
   player:sendTextMessage(MESSAGE_EVENT_ORANGE, msg)
   player:getPosition():sendMagicEffect(CONST_ME_BUBBLES)
end
 
If you haven't altered the script in 2-3 weeks, my guess is that it was never working to begin with.

My guess would be that words doesn't come back with /setstorage but instead returns setstorage

you can confirm this by printing words and finding out what it returns.
print(words)
 
In data/scripts/talkactions create file .lua and put:
Lua:
local storageSet = TalkAction("/set")

function storageSet.onSay(cid, words, param)
    local player = Player(cid)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")
    if split[2] == nil then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end

    local target = Player(split[1])
    if target == nil then
        player:sendCancelMessage("A player with that name is not online.")
        return false
    end

    -- Trim left
    split[2] = split[2]:gsub("^%s*(.-)$", "%1")
    split[3] = split[3]:gsub("^%s*(.-)$", "%1")
    local ch = split[2]
    local ch2 = split[3]
    setPlayerStorageValue(getPlayerByName(split[1]), tonumber(ch), tonumber(ch2))
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "The storage with id: "..tonumber(ch).." from player "..split[1].." is now: "..ch2..".")
    return false
end

storageSet:separator(" ")
storageSet:register()

Command: /set NAME CHAR, STORAGE (Ex: 99999), Value (Ex: 1) // Ex: ==> /set Bubble, 99999, 1
 
If you haven't altered the script in 2-3 weeks, my guess is that it was never working to begin with.

My guess would be that words doesn't come back with /setstorage but instead returns setstorage

you can confirm this by printing words and finding out what it returns.
print(words)

This script working 100%, cuz im tested many scripts with it but now i don't know why not working :(
I didn't make any changes in this script, and im sure in 100% it work 2-3 weeks ago
There is a screen with print:
1654183827334.png

I saw something, first message is from /getstorage command, second is from /setstorage, and why in /setstorage message is "is currently" not "is now"?
In script i see this:
Code:
   if words == "/setstorage" then
     -- Set specified storage value on player.
     checkedPlayer:setStorageValue(storageKey, storageValue)
     msg = string.format(msg, "is now")
     print(words)
   else
     -- Get specified storage value from player.
     msg = string.format(msg, "is currently")
     print(words)
   end

So i think, "is now" is for /setstorage and "is currently" for /getstorage
1654183923733.png

@Azerty thanks, your script work, but still i'm confused why my script stop working
 
Last edited:
Back
Top