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

Level for send Private Message

leo123456

New Member
Joined
Jun 13, 2009
Messages
33
Best answers
0
Reaction score
0
Hi community,

I need script for allow send private message if player have level 50 or more.

I abelive that its simple.

Thank's
 

bayview

Banned User
Joined
Jan 25, 2018
Messages
611
Best answers
25
Reaction score
290
Hi community,

I need script for allow send private message if player have level 50 or more.

I abelive that its simple.

Thank's
Well if it's simple then try doing it yourself and get back to us.. maybe it is.. but you will never know until you try ;)

Btw this is support not requests, support is for help with that something that already exists where as requests is for something which has yet to exist.
 

Infernum

Support Team
Joined
Feb 14, 2015
Messages
5,498
Best answers
547
Reaction score
3,396
game.cpp, replace this
with this
C++:
bool Game::playerSpeakTo(Player* player, SpeakClasses type, const std::string& receiver,
    const std::string& text)
{
    Player* toPlayer = getPlayerByName(receiver);
    if(!toPlayer || toPlayer->isRemoved())
    {
        player->sendTextMessage(MSG_STATUS_SMALL, "A player with this name is not online.");
        return false;
    }

    bool canSee = player->canSeeCreature(toPlayer);
    if(toPlayer->hasCondition(CONDITION_GAMEMASTER, GAMEMASTER_IGNORE)
        && !player->hasFlag(PlayerFlag_CannotBeMuted))
    {
        char buffer[70];
        if(!canSee)
            sprintf(buffer, "A player with this name is not online.");
        else
            sprintf(buffer, "Sorry, %s is currently ignoring private messages.", toPlayer->getName().c_str());

        player->sendTextMessage(MSG_STATUS_SMALL, buffer);
        return false;
    }

    if(type == SPEAK_PRIVATE_RED && !player->hasFlag(PlayerFlag_CanTalkRedPrivate))
        type = SPEAK_PRIVATE;

    if (player->getLevel() < 50) {
        player->sendTextMessage(MSG_STATUS_SMALL, "You must be level 50 to send private messages.");
    }

    toPlayer->sendCreatureSay(player, type, text);
    toPlayer->onCreatureSay(player, type, text);
    if(!canSee)
    {
        player->sendTextMessage(MSG_STATUS_SMALL, "A player with this name is not online.");
        return false;
    }

    char buffer[80];
    sprintf(buffer, "Message sent to %s.", toPlayer->getName().c_str());
    player->sendTextMessage(MSG_STATUS_SMALL, buffer);
    return true;
}
 

drakylucas

Well-Known Member
Joined
Dec 15, 2015
Messages
132
Best answers
1
Reaction score
54
game.cpp, replace this
with this
C++:
bool Game::playerSpeakTo(Player* player, SpeakClasses type, const std::string& receiver,
    const std::string& text)
{
    Player* toPlayer = getPlayerByName(receiver);
    if(!toPlayer || toPlayer->isRemoved())
    {
        player->sendTextMessage(MSG_STATUS_SMALL, "A player with this name is not online.");
        return false;
    }

    bool canSee = player->canSeeCreature(toPlayer);
    if(toPlayer->hasCondition(CONDITION_GAMEMASTER, GAMEMASTER_IGNORE)
        && !player->hasFlag(PlayerFlag_CannotBeMuted))
    {
        char buffer[70];
        if(!canSee)
            sprintf(buffer, "A player with this name is not online.");
        else
            sprintf(buffer, "Sorry, %s is currently ignoring private messages.", toPlayer->getName().c_str());

        player->sendTextMessage(MSG_STATUS_SMALL, buffer);
        return false;
    }

    if(type == SPEAK_PRIVATE_RED && !player->hasFlag(PlayerFlag_CanTalkRedPrivate))
        type = SPEAK_PRIVATE;

    if (player->getLevel() < 50) {
        player->sendTextMessage(MSG_STATUS_SMALL, "You must be level 50 to send private messages.");
    }

    toPlayer->sendCreatureSay(player, type, text);
    toPlayer->onCreatureSay(player, type, text);
    if(!canSee)
    {
        player->sendTextMessage(MSG_STATUS_SMALL, "A player with this name is not online.");
        return false;
    }

    char buffer[80];
    sprintf(buffer, "Message sent to %s.", toPlayer->getName().c_str());
    player->sendTextMessage(MSG_STATUS_SMALL, buffer);
    return true;
}
Below this:
Code:
player->sendTextMessage(MSG_STATUS_SMALL, "You must be level 50 to send private messages.");
you should write "return false;", shouldn't you? :p (I'm not criticizing, just reporting a possibly mistake :p)
 

Infernum

Support Team
Joined
Feb 14, 2015
Messages
5,498
Best answers
547
Reaction score
3,396
Below this:
Code:
player->sendTextMessage(MSG_STATUS_SMALL, "You must be level 50 to send private messages.");
you should write "return false;", shouldn't you? :p (I'm not criticizing, just reporting a possibly mistake :p)
you're right, forgot to stop execution if the player's level doesn't meet the requirement

I will test. Thanks.
change
C++:
    if (player->getLevel() < 50) {
        player->sendTextMessage(MSG_STATUS_SMALL, "You must be level 50 to send private messages.");
    }
to
C++:
    if (player->getLevel() < 50) {
        player->sendTextMessage(MSG_STATUS_SMALL, "You must be level 50 to send private messages.");
        return false;
    }
 
OP
L

leo123456

New Member
Joined
Jun 13, 2009
Messages
33
Best answers
0
Reaction score
0
The compilation is OK.

I will restart my server late and test.

Thanks.
 
Top