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

Compiling tfs 0.4

Solution
This error is probably, because you copied code from some server that use 'int' storage keys (all servers except 0.4) and TFS 0.4 has 'string' storage keys.
These functions should work:
PHP:
bool Player::tameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(getStorage(keyString, tmp))
    {
        value = atoi(tmp.c_str());
        value |= (int32_t)pow(2., mountId % 31);
    }
    else
        value = (int32_t)pow(2., mountId % 31);

    setStorage(keyString, boost::lexical_cast<std::string>(value))...
Hello Sir Sezago,

throw us the code here so we can check it out and maybe fix it for you, I'd rather make you think a little and solve your problem yourself.

There are different ways to solve this, it depends on the way you want to store information, if you want to go byte by byte, let's put it this way:
C++:
int32_t x=sirSezagoRandomValue;
char *ptr = (char*)&x;
char *msg = new char[5];
for(int i=0;i<4;++i, ++ptr)
    msg[i] = *ptr;

If you want to store it digit by digit instead:

C++:
int32_t x=sirSezagoRandomValue;
int digs[5], count=0;
char *msg = new char[5];
while(x>0)
{
     digs[count++]=x%10;
     x/=10;
}
int i=0;
while(count--)
{
     msg[i++] = digs[count] +'0';
}

I hope you can fix it yourself, anyways if you don't think you can, provide us the code :)

Best Wishes,
Okke
 
Hello Sir Sezago,

throw us the code here so we can check it out and maybe fix it for you, I'd rather make you think a little and solve your problem yourself.

There are different ways to solve this, it depends on the way you want to store information, if you want to go byte by byte, let's put it this way:
C++:
int32_t x=sirSezagoRandomValue;
char *ptr = (char*)&x;
char *msg = new char[5];
for(int i=0;i<4;++i, ++ptr)
    msg[i] = *ptr;

If you want to store it digit by digit instead:

C++:
int32_t x=sirSezagoRandomValue;
int digs[5], count=0;
char *msg = new char[5];
while(x>0)
{
     digs[count++]=x%10;
     x/=10;
}
int i=0;
while(count--)
{
     msg[i++] = digs[count] +'0';
}

I hope you can fix it yourself, anyways if you don't think you can, provide us the code :)

Best Wishes,
Okke
//////////////////////////////////////////////////////////////////////// // Ope - Pastebin.com the code i don't under stand what u already said but the error in setstorage in the mount system
 
This error is probably, because you copied code from some server that use 'int' storage keys (all servers except 0.4) and TFS 0.4 has 'string' storage keys.
These functions should work:
PHP:
bool Player::tameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(getStorage(keyString, tmp))
    {
        value = atoi(tmp.c_str());
        value |= (int32_t)pow(2., mountId % 31);
    }
    else
        value = (int32_t)pow(2., mountId % 31);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}

bool Player::untameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(!getStorage(keyString, tmp))
        return true;

    value = atoi(tmp.c_str());
    value ^= (int32_t)std::pow(2., mountId % 31);

    Mount* mount = Mounts::getInstance()->getMountByCid(defaultOutfit.lookMount);
    if(mount->getId() == (mountId + 1))
        dismount(true);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}
 
Solution
This error is probably, because you copied code from some server that use 'int' storage keys (all servers except 0.4) and TFS 0.4 has 'string' storage keys.
These functions should work:
PHP:
bool Player::tameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(getStorage(keyString, tmp))
    {
        value = atoi(tmp.c_str());
        value |= (int32_t)pow(2., mountId % 31);
    }
    else
        value = (int32_t)pow(2., mountId % 31);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}

bool Player::untameMount(uint8_t mountId)
{
    if(!Mounts::getInstance()->getMountById(mountId))
        return false;

    int32_t key = PSTRG_MOUNTS_RANGE_START + (mountId / 31), value = 0;
    std::string keyString = boost::lexical_cast<std::string>(key);
    std::string tmp;

    mountId--;
    if(!getStorage(keyString, tmp))
        return true;

    value = atoi(tmp.c_str());
    value ^= (int32_t)std::pow(2., mountId % 31);

    Mount* mount = Mounts::getInstance()->getMountByCid(defaultOutfit.lookMount);
    if(mount->getId() == (mountId + 1))
        dismount(true);

    setStorage(keyString, boost::lexical_cast<std::string>(value));
    return true;
}
i got other error bro .. bug exxx.PNG
 
In DevCpp (screen looks like DevCpp) it was 'Rebuild all' or something like that. To compile all files again. You must do it everytime you change something in any .h file.
already done it and still get same error ..
 
In DevCpp (screen looks like DevCpp) it was 'Rebuild all' or something like that. To compile all files again. You must do it everytime you change something in any .h file.
Remember this error bro i Found what is the cause of this error
when i add this Code in TheforgottenServer.Dev it doesn't Import Mounts.h/ mounts.cpp
Code:
[Unit158]
FileName=..\mounts.cpp
CompileCpp=1
Folder=TheForgottenServer
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit159]
FileName=..\mounts.h
CompileCpp=1
Folder=TheForgottenServer
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
after adding it it should add active mounts .h / cpp but it compiling normal...
 
Back
Top