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

Get a storage value in C++?

kokokoko

Veteran OT User
Joined
Feb 4, 2008
Messages
921
Reaction score
256
I was browsing the C++ codes, and i found this:

http://otland.net/f35/level-ranks-23463/

I'm wondering how to check a storage value of a player in C++

(Like getPlayerStorageValue())

So, instead of checking the level of the player i want it to check a storage value.


Thanks in advance,
//Kokokoko
 
Try something like this...

Code:
std::string Player::getPVPRank(uint32_t level) const
{
        int32_t rank;
        std::string ranga = "newbie";
        if(getPlayerStorageValue(STORAGEVALUE_NUMBER,rank) >= 40) && (getPlayerStorageValue(STORAGEVALUE_NUMBER,rank) <= 45))
        {
            ranga = "normal PK";
        }

I've didn't tested it and i aint the best at c++ but I hope it works for you :)


kind regards, Evil Hero
 
No it won't work this way ;p

Code:
std::string strValue;
if(player->getStorageValue(STORAGEVALUE_NUMBER, strValue))
{
	int32_t value = atoi(strValue.c_str());
	//now do what you want with this value
}
 
No it won't work this way ;p

Code:
std::string strValue;
if(player->getStorageValue(STORAGEVALUE_NUMBER, strValue))
{
	int32_t value = atoi(strValue.c_str());
	//now do what you want with this value
}

Thank you :D

Adding it now =)

EDIT: Bug :S

Code:
In member function `bool Game::violationWindow(uint32_t, std::string, int32_t, int32_t, std::string, std::string, uint16_t, bool)':
4974 [Warning] left shift count >= width of type
In member function `virtual std::string Player::getPVPRank(uint32_t) const':
251 `player' was not declared in this scope
251 `STORAGEVALUE_NUMBER' was not declared in this scope
256 `value' was not declared in this scope
[Build Error]  [obj//player.o] Error 1
 
Last edited:
Hello! :D There is 'STORAGEVALUE_NUMBER' but you need to change this to your storage key. And remove this part - 'player->'
 
Ok.. I still can't get it to work :p

I have this:
Code:
 std::string strValue;
if(getStorageValue(7892, strValue))
{
	int32_t value = atoi(strValue.c_str());
}

And when i use it,
Code:
        if(value == 1)
        {
            ranga = "Test";
        }
        else if(value == 2)
        {
            ranga = "Testest";
        }


:s
 
oO this is great idea to use storagevalue
It will be great if anyone can help with this stuff, cus this dont look like it wanna work :/
i tried doing sth, but now i have a lot of additional errors...
 
it's depends where did you want to use this, if for description, then probably:
player.cpp
search for
std::string Player::getDescription(int32_t lookDistance) const
add somewhere, for example:
after

Code:
else
	{
		s << nameDescription;
		if(!hasCustomFlag(PlayerCustomFlag_HideLevel))
			s << " (Level " << level << ")";

		s << ". " << (sex % 2 ? "He" : "She");
		if(hasFlag(PlayerFlag_ShowGroupNameInsteadOfVocation))
			s << " is " << group->getName();
		else if(vocation_id != 0)
			s << " is " << vocation->getDescription();
		else
			s << " has no vocation";

		s << getSpecialDescription();
	}

add


Code:
if(getStorageValue(YOUR_VALUE, strValue))
	{
		if(sex == PLAYERSEX_FEMALE)
			{
				s << " She";
			}
		else
			{
				s << " He";
			}
				
	s << " is ";
			
	int32_t intValue = atoi(strValue.c_str());
	switch(intValue)
		{
		case 0:
			s << " anyone.";
		case 1:
			s << " someone else.";
		default:
			s << " nobody.";
		}
	}

not tested, just for example, but I think it will work ;) All what you need, it's to replace YOUR_VALUE with storage value it should use, and then edit ranks, or add new in case part. I'm not sure about this, post here if there iwll be any errors
 
Last edited:
Back
Top