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

Solved Little help, add storage in c++ func // Rep +

Rebine

New Member
Joined
Feb 10, 2010
Messages
69
Reaction score
2
Location
Chile
SOLVED by: elime

ADDING STORAGE TO ANOTHER


Hello, i need another little help.-

how it's supposed to be what i can add a storage to other? Example the function setPlayerStorageValue(cid, 828, getPlayerStorageValue(cid, 828) + 500) but in C++

This is wanna edit u.u

Code:
std::string stora
std::string newStora = "-10";
if(isSummon() && getStorage(1008, stora) && seconds <= OTSYS_TIME()){
int32_t intValue = atoi(stora.c_str());
if(intValue && intValue >= 0)
{
       const Position& tmp = getPosition();
       setStorage(1008, newStora);
       g_game.addMagicEffect(tmp, 173);
       seconds = OTSYS_TIME() + 30000;
}
}

thx, i hope someone can help me on this D:
 
Last edited:
Code:
//Get the value
std::string value;
getStorage(1008, value)
    
//Change the value and put it in a stringstream
std::stringstream ss;
ss << atoi(value.c_str()) + 500;
    
//Set the value
setStorage(1008, ss.str());
 
Last edited:
Well, this is the new code:
Code:
std::string stora;
if(isSummon() && getStorage(1008, stora) && restFoodTime <= OTSYS_TIME()){
int32_t intValue = atoi(stora.c_str());
if(intValue && intValue >= 0)
{
       const Position& tmp = getPosition();
       std::stringstream ss;
       ss << atoi(value.c_str()) + 500;
       setStorage(1008, ss.str());
       g_game.addMagicEffect(tmp, 173);
       restFoodTime = OTSYS_TIME() + 30000;
}
}

I can't compile it :(

\monster.cpp In member function `virtual void Monster::eek:nThink(uint32_t)':
615 \monster.cpp `value' was not declared in this scope
 
Back
Top