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

Lua TFS 1.2 Storage value.

FallenOTs

Member
Joined
Jul 14, 2013
Messages
45
Reaction score
11
Why does this:
Code:
    elseif msgcontains(msg, 'look') and quest == 2 and talk_state == 3 or msgcontains(msg, 'yes') and quest == 2 and talk_state == 3 then
        selfSay("Please, go quickly. This town has lost enough warriors from the evil surrounding it.", cid)
        player:setStorageValue("drezdenquest", 3)
        player:setStorageValue("drezdena", 1)

Set drezdenquest to value 1 as well. Are we not able to have multiple setStorages in the same if statements?
 
why are using "string" to setStorage, this function use numbers, or a string declared in the lib/storages.lua (something like that)
this "" is not need same when you declare the storage at the lib
 
why are using "string" to setStorage, this function use numbers, or a string declared in the lib/storages.lua (something like that)
this "" is not need same when you declare the storage at the lib
As far as I know string is used because otherwise it looks for a variable, unless something has changed between 0.4 and 1.2
 
player:setStorageValue("drezdenquest", 3) Can we agree that there is a string here? And can we agree that we can check the storage for this string. I miss read what he said about storing strings, as it's irrelevant to the posters question.
Well the code says
Code:
// player:setStorageValue(key, value)
int32_t value = getNumber<int32_t>(L, 3);
uint32_t key = getNumber<uint32_t>(L, 2);
But then you look at its definition, the <int32_t> & <uint32_t> must be casting its return value?
String in, cast out.. even idk what heck this says.. well i have a general idea :p
Code:
template<typename T>
     T getNumber(const std::string& s) const
     {
       auto it = listNames.find(s);
       if (it == listNames.end()) {
         std::cout << "[Error - DBResult::getNumber] Column '" << s << "' doesn't exist in the result set" << std::endl;
         return static_cast<T>(0);
       }

       if (row[it->second] == nullptr) {
         return static_cast<T>(0);
       }

       T data;
       try {
         data = boost::lexical_cast<T>(row[it->second]);
       } catch (boost::bad_lexical_cast&) {
         data = 0;
       }
       return data;
     }
 
Well the code says
Code:
// player:setStorageValue(key, value)
int32_t value = getNumber<int32_t>(L, 3);
uint32_t key = getNumber<uint32_t>(L, 2);
But then you look at its definition, the <int32_t> & <uint32_t> must be casting its return value?
String in, cast out.. even idk what heck this says.. well i have a general idea :p
Code:
template<typename T>
     T getNumber(const std::string& s) const
     {
       auto it = listNames.find(s);
       if (it == listNames.end()) {
         std::cout << "[Error - DBResult::getNumber] Column '" << s << "' doesn't exist in the result set" << std::endl;
         return static_cast<T>(0);
       }

       if (row[it->second] == nullptr) {
         return static_cast<T>(0);
       }

       T data;
       try {
         data = boost::lexical_cast<T>(row[it->second]);
       } catch (boost::bad_lexical_cast&) {
         data = 0;
       }
       return data;
     }
What I'm saying is, you can store an int in a string. String being the storage you're calling, int being the return value of the storage.
 
so what is the issue with the script? why is it that whenever theres a second setStorage it always sets the first storage to the second value?
 
Back
Top