This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [C++] [QUESTION]  Text/Emotes give experience?  (Read 2066 times)

Nic

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 52
    • View Profile
[C++] [QUESTION]  Text/Emotes give experience?
« on: November 30, 2010, 05:59:23 pm »
Hello,

I've seen, it give an possibility, to give players experience points per punctuation mark.

For example:

Player1 say: Hello Friends
Player1 get 120 Experience Points

(10 Points per punctuation mark.  The Player get experience in /say /emote)

Player1 [GUILD]: Hello
Player1 get 0 Experience Points

(The Player get no experience in /1 /2 /3 /4 /g /raid /p)

Can someone help me?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [C++] [QUESTION]  Text/Emotes give experience?
« Reply #1 on: November 30, 2010, 10:26:35 pm »
Hook Chat-Events. Depending on the channel, parse the message and award experience. Should be an easy script.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Nic

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 52
    • View Profile
Re: [C++] [QUESTION]  Text/Emotes give experience?
« Reply #2 on: December 01, 2010, 03:52:20 pm »
Schlumpf write a nice script, but the script is to old for Trinity Core Rev. 7331 (3.2.2a). I try to edit the script, but i havent success.

Can someone help me by the Script editing?

Code: [Select]
/*
 * Copyright (C) 2010 schlumpf
 */

#include "ScriptPCH.h"
#include "Channel.h"
#include "Player.h"

class Guild;
class Group;

class ChatXPScript : public PlayerScript
{
public:
    ChatXPScript() : PlayerScript("ChatXPScript") { }

    void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string msg)
    // CHAT_MSG_ADDON, CHAT_MSG_SAY, CHAT_MSG_EMOTE, CHAT_MSG_YELL
    {
        if( type == CHAT_MSG_EMOTE ) return;
        if( type == CHAT_MSG_ADDON ) return;
       
        int xpGain = 10;
       
        // modify:
        xpGain += msg.length();
       
        player->GiveXP( xpGain, NULL, 1.0f );
    }

    void OnChat(Player *player, uint32 /*type*/, uint32 /*lang*/, std::string msg, Player *receiver)
    // CHAT_MSG_WHISPER
    {
        int xpGain1 = 5;
        int xpGain2 = 2;
       
        // modify:
        xpGain1 *= msg.length();
        xpGain2 *= msg.length();
       
        player->GiveXP( xpGain1, NULL, 1.0f );
        receiver->GiveXP( xpGain2, NULL, 1.0f );
    }

    void OnChat(Player *player, uint32 type, uint32 /*lang*/, std::string msg, Group */*group*/)
     // CHAT_MSG_PARTY, CHAT_MSG_PARTY_LEADER, CHAT_MSG_RAID,  CHAT_MSG_RAID_LEADER, CHAT_MSG_RAID_WARNING, CHAT_MSG_BATTLEGROUND,  CHAT_MSG_BATTLEGROUND_LEADER
    {
        if( type == CHAT_MSG_PARTY ) return;
        if( type == CHAT_MSG_RAID ) return;
        if( type == CHAT_MSG_BATTLEGROUND ) return;
       
        int xpGain = 100;
       
        // modify:
        xpGain += msg.length();
       
        player->GiveXP( xpGain, NULL, 1.0f );
    }

    void OnChat(Player *player, uint32 /*type*/, uint32 /*lang*/, std::string msg, Guild */*guild*/)
    // CHAT_MSG_GUILD, CHAT_MSG_OFFICER
    {
        if( type == CHAT_MSG_OFFICER ) return;
       
        int xpGain = 10;
       
        // modify:
        xpGain += msg.length();
       
        player->GiveXP( xpGain, NULL, 1.0f );
    }

    void OnChat(Player *player, uint32 /*type*/, uint32 /*lang*/, std::string msg, Channel *channel)
    {
        if( !channel ) return;
       
        if( channel->HasFlag(CHANNEL_FLAG_TRADE) ) return;
        if( channel->HasFlag(CHANNEL_FLAG_LFG) ) return;
       
        int xpGain = 0;
       
        // modify:
        xpGain += msg.length();
       
        player->GiveXP( xpGain, NULL, 1.0f );
    }
};

void AddSC_ChatXPScript()
{
    new ChatXPScript();
}
« Last Edit: January 01, 1970, 01:00:00 am by Admin »