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

TFS 1.2 Talkaction add storage and remove storage

I think you could add this script I've seen on another OT but I make it on my TFS1.1 because there is no this function available, also I think this work on 1.2

/storage Lokio, 1200
This checks the storage with Key 1200 and return Value.
/storage Lokio, 1200, 5
This Change the value of the specified Key in this case 1200, and if you want to remove it just put value -1, ex: /storage Lokio, 1200, -1

add on data/talkactions/talkactions.xml

Code:
<talkaction words="/storage" separator=" " script="storagePlayer.lua" />

and in data/talkaction/scripts/storagePlayer.lua

Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

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

    local value = tonumber(split[2])
   
    if(value == nil or value <= 0)then
        player:sendCancelMessage("You need to put the storage to verify.")
        return false
    end

    local storage = getPlayerStorageValue(target, value)   
    local key = split[3]
    if key == nil then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Storage Key: " .. value .. " Storage Value: " .. storage)
    else
        setPlayerStorageValue(target.uid, value, key)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have set Storage Key: " .. value .. " Storage Value: " .. key .. ".")
    end
    return false
end

I hope this works for you.
 
@lokolokio other than the fact that you named the storage value key "value", and the key "storage", its good, but you forgot to add a check so you can set storages to numbers only, with this you can set them to strings etc (which isnt supported afaik)
i just added tonumber around split[3], and you didnt add so the person using the command can see who he did it on (just for safety)
with the tonumber, it will say the storage instead of setting it any tine it is not a valid number
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

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

    local value = tonumber(split[2])
 
    if(value == nil or value <= 0)then
        player:sendCancelMessage("You need to put the storage to verify.")
        return false
    end

    local storage = getPlayerStorageValue(target, value)
    local key = tonumber(split[3])
    if key == nil then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Storage Key: " .. value .. " Storage Value: " .. storage.." Player: "..target:getName())
    else
        setPlayerStorageValue(target.uid, value, key)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have set Storage Key: " .. value .. " Storage Value: " .. key .. " for player "..target:getName()..".")
    end
    return false
end
 
Jeje sorry I forgot to correct that becuase I use on my server to let a player access to certain zone with another player, but the TILE action check a certain storage on player, I just put in player: /storage Lokio, 1005030, Mafer, and on mafer /storage Mafer, 1005030, Lokio, and those are only the teammate that are allowed to pass, if another player steps on tile the tile reject him. and thats the reason that are not a tonumber on split[3]. but thanks alot for correct the script...
 
Back
Top