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