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

C++ Check storagevalue on sources?

Zell

Intermediate OT User
Joined
Oct 23, 2010
Messages
214
Reaction score
117
Hiho people, I want change some descriptions from player.cpp?
But i tryed a lot of kinds to call getstorage and nothing..

Im using a (tfs?) 0.6.3 server with client 7.6.

Here is the code..I just need:

Code:
std::string Player::getDescription(int32_t lookDistance) const
{
    std::stringstream s;
    std::string str;

if getPlayerStorageValue(cid, 11005) >= 1
           s << "Here I Add my text.";

elseif getPlayerStorageValue(cid, 11005) >= 25
           s << "Here I Add my second text.";

    if(lookDistance == -1){
        s << "yourself.";
     
 
    }

Thanks for help!
 
Last edited:
Solution
Function getStorageValue changes already existing variable so you need to declare it beforehand.

C++:
int32_t number;
getStorageValue(11005, number);
feels very weird to call getPlayerStorageValue(cid,value) in c++ dont you think? this is a lua function not a c++ method (something the object "player" can call (a function))
Code:
std::string value;
getStorage(11005,value);
int64_t number = atoi(value.c_str());

if (number >= 1 ){

}
else if (number >= 25){

}

to see all methods(functions) avaliable for players, check player.h
 
Last edited:
feels very weird to call getPlayerStorageValue(cid,value) in c++ dont you think? this is a lua function not a c++ method (something the object "player" can call (a function))
Code:
std::string value;
getStorage(11005,value);
int64_t number = atoi(value.c_str());

if (number >= 1 ){

}
else if (number >= 25){

}

to see all methods(functions) avaliable for players, check player.h


I check on player.h and i find
Code:
    void addStorageValue(const uint32_t key, const int32_t value);
    bool getStorageValue(const uint32_t key, int32_t& value) const;

When I use the code i get this error

Code:
 C:1.0\player.cpp In member function `virtual std::string Player::getDescription(int32_t) const': 
252 C:1.0\player.cpp `getStorage' was not declared in this scope 

[/code

Here my code :(

[code]
std::string Player::getDescription(int32_t lookDistance) const
{
    std::stringstream s;
    std::string str;
        std::string value;
        getStorage(11005,value);
        int64_t number = atoi(value.c_str());
    if(lookDistance == -1){
        s << "yourself.";
       
        if(getVocationId() != VOCATION_NONE)
            s << " You are " << vocation->getVocDescription() << ".";
       
       
       

        if (number >= 1 ){
                s << "Honour: [=====|=====] peasant.";
            }
        else if (number >= 25){
        s << "Honour: [======|====] citizen.";
            }

       
        else
            s << " You have no vocation.";
    }

and so on

Why I get this error? how can i declare getstorage?
 
I check on player.h and i find
Code:
    void addStorageValue(const uint32_t key, const int32_t value);
    bool getStorageValue(const uint32_t key, int32_t& value) const;

When I use the code i get this error

Code:
 C:1.0\player.cpp In member function `virtual std::string Player::getDescription(int32_t) const':
252 C:1.0\player.cpp `getStorage' was not declared in this scope

[/code

Here my code :(

[code]
std::string Player::getDescription(int32_t lookDistance) const
{
    std::stringstream s;
    std::string str;
        std::string value;
        getStorage(11005,value);
        int64_t number = atoi(value.c_str());
    if(lookDistance == -1){
        s << "yourself.";
     
        if(getVocationId() != VOCATION_NONE)
            s << " You are " << vocation->getVocDescription() << ".";
     
     
     

        if (number >= 1 ){
                s << "Honour: [=====|=====] peasant.";
            }
        else if (number >= 25){
        s << "Honour: [======|====] citizen.";
            }

     
        else
            s << " You have no vocation.";
    }

and so on

Why I get this error? how can i declare getstorage?
you definitely aren't using tfs if you don't have this? link me where your sources are on github or anything for me to check it

edit: bool getStorageValue(const uint32_t key, int32_t& value) const;
u answered ur own question
 
Function getStorageValue changes already existing variable so you need to declare it beforehand.

C++:
int32_t number;
getStorageValue(11005, number);
 
Solution
Function getStorageValue changes already existing variable so you need to declare it beforehand.

C++:
int32_t number;
getStorageValue(11005, number);


Thanks to both for try help me, I have not been long stuying yet c++ and some things I dont know for now..

With this now is working, thanks again!
 
Back
Top