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

Storage (ID) Channel

Nubaza

LUA Scripter
Joined
Jun 5, 2011
Messages
330
Solutions
1
Reaction score
21
Location
New Zeland
Hello!

I tried to do a channel by storage but i can't do that.

So... i read this from a post:

Code:
How can i do one Premium Channel?

have one tag to add in channels.xml to only Premium Players open it?

Solution: All credits goes to Cykotitan.

In chat.cpp

Find:
if((readXMLString(p, "logged", strValue) || readXMLString(p, "log", strValue)) && booleanString(strValue))
flags |= CHANNELFLAG_LOGGED;
Add this under it:
if(readXMLString(p, "premium", strValue) && booleanString(strValue))
flags |= CHANNELFLAG_PREMIUM;
Find:
player->getVocationId())))
Replace it with this:
player->getVocationId())) || (tmpChannel->hasFlag(CHANNELFLAG_PREMIUM) && !player->isPremium()))

In chat.h

Find:
CHANNELFLAG_LOGGED = 1 << 2,
Add this under it:
CHANNELFLAG_PREMIUM = 1 << 3,
One of the easiest source edits, ever :).

Oh, and to implement the channel into the server, add something like this in data/XML/channels.xml:
<channel id="10" name="Premium Channel" premium="yes"/>

But.. What about to do for "storage" and not for "premium" ???
Something like: <channel id="10" name="X Channel" storageid="11740"/>

So... just if the player have the storageid "x" in value 1 can see that channel.

I tried changing that line:

player->isPremium()))
to
player->getStorage()))

but didn't worked

Please help, thanks.
 
Last edited:
chat.h:
search for:
Code:
ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access = 0,
       uint32_t level = 1, Condition* condition = NULL, int32_t conditionId = -1,
       const std::string& conditionMessage = "", VocationMap* vocationMap = NULL);
replace it with:
Code:
ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access = 0,
       uint32_t level = 1, uint32_t storage = 0, Condition* condition = NULL, int32_t conditionId = -1,
       const std::string& conditionMessage = "", VocationMap* vocationMap = NULL);
search for:
Code:
uint32_t getAccess() const {return m_access;}
add:
Code:
uint32_t getStorage() const {return m_storage;}
search for:
Code:
uint32_t m_access, m_level;
replace it with:
Code:
uint32_t m_access, m_level, m_storage;

chat.cpp:
search for:
Code:
ChatChannel::ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access/* = 0*/,
   uint32_t level/* = 1*/, Condition* condition/* = NULL*/, int32_t conditionId/* = -1*/,
   const std::string& conditionMessage/* = ""*/, VocationMap* vocationMap/* = NULL*/):
   m_id(id), m_flags(flags), m_conditionId(conditionId), m_access(access), m_level(level),
     m_name(name), m_conditionMessage(conditionMessage), m_condition(condition),
     m_vocationMap(vocationMap)
replace it with:
Code:
ChatChannel::ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access/* = 0*/,
   uint32_t level/* = 1*/, uint32_t storage/* = 0 */, Condition* condition/* = NULL*/, int32_t conditionId/* = -1*/,
   const std::string& conditionMessage/* = ""*/, VocationMap* vocationMap/* = NULL*/):
   m_id(id), m_flags(flags), m_conditionId(conditionId), m_access(access), m_level(level), m_storage(storage),
     m_name(name), m_conditionMessage(conditionMessage), m_condition(condition),
     m_vocationMap(vocationMap)
search for:
Code:
ChatChannel* tmpChannel = nit->second;
add this:
Code:
std::string tmpStorage;
search for:
Code:
if(!tmpChannel || !tmpChannel->hasFlag(CHANNELFLAG_ENABLED) || player->getAccess() < tmpChannel->getAccess()
       || (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges) && !tmpChannel->checkVocation(
       player->getVocationId()))
replace it with:
Code:
if(!tmpChannel || !tmpChannel->hasFlag(CHANNELFLAG_ENABLED) || player->getAccess() < tmpChannel->getAccess()
       || (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges) && !tmpChannel->checkVocation(
       player->getVocationId())) || tmpChannel->getStorage() != 0 && (player->getStorage(tmpChannel->getStorage(), tmpStorage) && atoi(tmpStorage.c_str()) < 1))
search for:
Code:
level = intValue;
add this:
Code:
uint32_t storage = 0;
if (readXMLInteger(p, "storage", intValue))
     storage = intValue;

Havn't tested it but it should be working.
Just add in your channels.xml
example:
Code:
<channel id="8" name="RL-Chat" storage="10000"/>
If the player has the storagevalue of 10000 same or higher then 1 then the player can see the channel.
 
Wow man!! Awesome!!
But i can't compile it :c

Got this errors:
Code:
 chat.cpp In member function `bool Chat::parseChannelNode(xmlNode*)': 
338 chat.cpp no matching function for call to `ChatChannel::ChatChannel(uint16_t&, std::string&, uint16_t&, uint32_t&, uint32_t&, Condition*&, int32_t&, std::string&, VocationMap*&)' 
chat.h:39 candidates are: ChatChannel::ChatChannel(const ChatChannel&) 
chat.h:39                 ChatChannel::ChatChannel(uint16_t, const std::string&, uint16_t, uint32_t, uint32_t, uint32_t, Condition*, int32_t, const std::string&, VocationMap*)

A little more help :C
 
That's a fragment:
Code:
        case CHANNEL_PRIVATE:
        {
            if(ChatChannel* newChannel = new PrivateChatChannel(CHANNEL_PRIVATE, name, flags))
                dummyPrivate = newChannel;

            break;
        }

        default:
        {
            if(ChatChannel* newChannel = new ChatChannel(id, name, flags, access, level,
                condition, conditionId, conditionMessage, vocationMap))
                m_normalChannels[id] = newChannel;

            break;
        }
    }

    return true;
}
 
chat.h:
search for:
Code:
ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access = 0,
       uint32_t level = 1, Condition* condition = NULL, int32_t conditionId = -1,
       const std::string& conditionMessage = "", VocationMap* vocationMap = NULL);
replace it with:
Code:
ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access = 0,
       uint32_t level = 1, uint32_t storage = 0, Condition* condition = NULL, int32_t conditionId = -1,
       const std::string& conditionMessage = "", VocationMap* vocationMap = NULL);
search for:
Code:
uint32_t getAccess() const {return m_access;}
add:
Code:
uint32_t getStorage() const {return m_storage;}
search for:
Code:
uint32_t m_access, m_level;
replace it with:
Code:
uint32_t m_access, m_level, m_storage;

chat.cpp:
search for:
Code:
ChatChannel::ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access/* = 0*/,
   uint32_t level/* = 1*/, Condition* condition/* = NULL*/, int32_t conditionId/* = -1*/,
   const std::string& conditionMessage/* = ""*/, VocationMap* vocationMap/* = NULL*/):
   m_id(id), m_flags(flags), m_conditionId(conditionId), m_access(access), m_level(level),
     m_name(name), m_conditionMessage(conditionMessage), m_condition(condition),
     m_vocationMap(vocationMap)
replace it with:
Code:
ChatChannel::ChatChannel(uint16_t id, const std::string& name, uint16_t flags, uint32_t access/* = 0*/,
   uint32_t level/* = 1*/, uint32_t storage/* = 0 */, Condition* condition/* = NULL*/, int32_t conditionId/* = -1*/,
   const std::string& conditionMessage/* = ""*/, VocationMap* vocationMap/* = NULL*/):
   m_id(id), m_flags(flags), m_conditionId(conditionId), m_access(access), m_level(level), m_storage(storage),
     m_name(name), m_conditionMessage(conditionMessage), m_condition(condition),
     m_vocationMap(vocationMap)
search for:
Code:
ChatChannel* tmpChannel = nit->second;
add this:
Code:
std::string tmpStorage;
search for:
Code:
if(!tmpChannel || !tmpChannel->hasFlag(CHANNELFLAG_ENABLED) || player->getAccess() < tmpChannel->getAccess()
       || (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges) && !tmpChannel->checkVocation(
       player->getVocationId()))
replace it with:
Code:
if(!tmpChannel || !tmpChannel->hasFlag(CHANNELFLAG_ENABLED) || player->getAccess() < tmpChannel->getAccess()
       || (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges) && !tmpChannel->checkVocation(
       player->getVocationId())) || tmpChannel->getStorage() != 0 && (player->getStorage(tmpChannel->getStorage(), tmpStorage) && atoi(tmpStorage.c_str()) < 1))
search for:
Code:
level = intValue;
add this:
Code:
uint32_t storage = 0;
if (readXMLInteger(p, "storage", intValue))
     storage = intValue;

Havn't tested it but it should be working.
Just add in your channels.xml
example:
Code:
<channel id="8" name="RL-Chat" storage="10000"/>
If the player has the storagevalue of 10000 same or higher then 1 then the player can see the channel.
this should be added to tfs master repo
 
change:
Code:
if(ChatChannel* newChannel = new ChatChannel(id, name, flags, access, level,
to:
Code:
if(ChatChannel* newChannel = new ChatChannel(id, name, flags, access, level, storage,

this error might occur once or twice more but you can fix it the same way as I just did here.
 
I added that:
uint32_t getStorage() const {return m_storage;}
In talkaction.h and chat.h
But it's only on chat.h

Can u do that work:
<channel id="8" name="RL-Chat" storage="10000"/>
When the storagevalue is not -1 or 0 ??? Because sometimes i use storages in Text not numbers

Thanks
 
Back
Top