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

getStorageValue inside setStorageValue dosent work

OTAmator

Member
Joined
May 4, 2016
Messages
60
Reaction score
8
Hi, why if i use getStorageValue inside setStorageValue then it dosent work correcly. In database like 4294967295 (in console it just returns -1)

dosent work:
Lua:
player:setStorageValue(player:getStorageValue(taskSys.storages.currentTask), taskSys.status.completed)
1701971496562.png

this code works properly:
Code:
local playerCurrentTaskStorage = player:getStorageValue(taskSys.storages.currentTask)
local playerActiveTask = taskSys:getPlayerActiveTaskDataByHisCurrentTaskStorage(playerCurrentTaskStorage)
player:setStorageValue(playerActiveTask.storage, taskSys.status.completed)
1701971643146.png
 
Last edited:
@StreamSide I dont undersand u

Im wondering why this "player:getStorageValue(taskSys.storages.currentTask)" returns "-1" (in db "4294967295") if i see this storage in db has value "17524"
 
Last edited:
ohhh now I understand
can you add some debug stuff like printing player storage value of taskSys.storages.currentTask
 
Hi, why if i use getStorageValue inside setStorageValue then it dosent work correcly. In database like 4294967295 (in console it just returns -1)

dosent work:
Lua:
player:setStorageValue(player:getStorageValue(taskSys.storages.currentTask), taskSys.status.completed)
View attachment 80463

this code works properly:
Code:
local playerCurrentTaskStorage = player:getStorageValue(taskSys.storages.currentTask)
local playerActiveTask = taskSys:getPlayerActiveTaskDataByHisCurrentTaskStorage(playerCurrentTaskStorage)
player:setStorageValue(playerActiveTask.storage, taskSys.status.completed)
View attachment 80464

Wrong:
Lua:
player:setStorageValue(player:getStorageValue(taskSys.storages.currentTask), taskSys.status.completed)

Correct:
Lua:
player:setStorageValue(taskSys.storages.currentTask, taskSys.status.completed)

First parameter of setStorageValue after player is the storage id, not value.
 
Hi, why if i use getStorageValue inside setStorageValue then it dosent work correcly. In database like 4294967295 (in console it just returns -1)

dosent work:
Lua:
player:setStorageValue(player:getStorageValue(taskSys.storages.currentTask), taskSys.status.completed)
View attachment 80463

this code works properly:
Code:
local playerCurrentTaskStorage = player:getStorageValue(taskSys.storages.currentTask)
local playerActiveTask = taskSys:getPlayerActiveTaskDataByHisCurrentTaskStorage(playerCurrentTaskStorage)
player:setStorageValue(playerActiveTask.storage, taskSys.status.completed)
View attachment 80464
You shouldn't really store a storage key as a value of another key.

It just becomes confusing when someone else comes across your code.
You should store all of your keys somewhere for reference.
In TFS, this is usually, lib/miscellaneous/051-storages.lua
 
@Fjorda
I have this thing where each task has its own unique storage value. Additionally, the storage holds the storage value for the task that the player is currently doing. I probably shouldn't keep information about the storage value of the task that the player is currently doing in the lib.
 
@Fjorda
I have this thing where each task has its own unique storage value. Additionally, the storage holds the storage value for the task that the player is currently doing. I probably shouldn't keep information about the storage value of the task that the player is currently doing in the lib.
What you should have done is to use a base storage value. For example, lets say 25000.

Each task is then incremented, so the first task would be 25001, and then 25002 so on.... To store the current task, you could use storage key 24999, and a value that holds the task index. i.e a value of 25, would be task storage 25000 + 25.
 
Back
Top