User Tag List

Results 1 to 7 of 7

Thread: Last script c++

  1. #1
    Emulation Addict
    Join Date
    Jun 2016
    Posts
    60
    XP
    1,048
    Level
    8
    Thanks
    0
    Thanked 6 Times in 4 Posts

    Red face Last script c++

    hello boys i"am looking a kill streak c++ script its are last one as i nided for Lastest Verison 60 DBT if anyone Glad to help me can share me that script :)

  2. #2
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,856 Times in 1,119 Posts
    I don't normally do this, but a Killstreak system is pretty simple. I did this in Visual Studio and didn't receive any errors; however, I did not test it. Everything should be self-explanatory but regardless I commented some stuff.

    Basic killstreak
    • Farm prevention
    • Can do stuff on specific kills. e.g. At 5 kills you could add an aura to give the player a greater advantage.


    Code:
    struct KillStreak
    {
        uint32 kills;
        uint32 lastKilledGuid; // Prevent gaining kills from previously killed player
    };
    
    std::unordered_map<uint32, KillStreak> KillStreakContainer;
    std::mutex killstreak_mutex;
    
    class player_killstreak : public PlayerScript
    {
    public:
        player_killstreak() : PlayerScript("player_killstreak") { }
    
        void OnPVPKill(Player* killer, Player* killed) override
        {
            uint32 killerGuid = killer->GetGUID().GetCounter();
            uint32 killedGuid = killed->GetGUID().GetCounter();
            const char* killedName = killed->GetName().c_str();
            bool wasMyLastVictim = false;
            uint32 killedKills = 0;
    
            {
                std::lock_guard<std::mutex> guard(killstreak_mutex);
                wasMyLastVictim = (KillStreakContainer[killerGuid].lastKilledGuid == killedGuid);
                killedKills = KillStreakContainer[killedGuid].kills;
    
                KillStreakContainer[killerGuid].lastKilledGuid = killedGuid; // Log our previous kill (prevent farming)
                KillStreakContainer[killedGuid].kills = 0; // Reset victim kills
                KillStreakContainer[killedGuid].lastKilledGuid = 0; // Reset victim's last victim
    
                if (!wasMyLastVictim)
                {
                    KillStreakContainer[killerGuid].kills++; // Increment kills
    
                    // Do stuff on streaks below
                    switch (KillStreakContainer[killerGuid].kills)
                    {
                        case 5: // 5 kills
                            break;
                        case 10: // 10 kills
                            break;
                    }
                }
            }
    
            if (wasMyLastVictim)
            {
                ChatHandler(killer->GetSession()).PSendSysMessage("You killed %s already. Kill another player to earn something from him/her again.", killedName);
                ChatHandler(killed->GetSession()).SendSysMessage("The person who killed you did not benefit from your death. They killed you before. Now laugh at them!");
                return;
            }
    
            std::ostringstream ss;
            ss << killer->GetName()
                << " has ruined " << killedName << "'s"
                << " KillStreak of " << killedKills;
    
            sWorld->SendGlobalText(ss.str().c_str(), NULL);
        }
    };
    
    void SetupKillStreak()
    {
        new player_killstreak;
    }
    Updated the script. Thanks for Rochet2 for pointing out the thread issue and showing the ways of the mutex.

  3. The Following User Says Thank You to Tommy For This Useful Post:


  4. #3
    Original Poster
    Emulation Addict
    Join Date
    Jun 2016
    Posts
    60
    XP
    1,048
    Level
    8
    Thanks
    0
    Thanked 6 Times in 4 Posts
    Thanks i well test it anway

  5. #4
    Original Poster
    Emulation Addict
    Join Date
    Jun 2016
    Posts
    60
    XP
    1,048
    Level
    8
    Thanks
    0
    Thanked 6 Times in 4 Posts
    its works thanks for That script but how i can coloring it names that i nided :) can you edit it for meh

  6. #5
    Original Poster
    Emulation Addict
    Join Date
    Jun 2016
    Posts
    60
    XP
    1,048
    Level
    8
    Thanks
    0
    Thanked 6 Times in 4 Posts
    That i want to Add a Spell when killed a Player receving like Soul of respawn, can you edit it for meh i mean that spell, http://www.wowhead.com/spell=20707/soulstone and we Edit that, Colors of Kiling Streak names just if your editing it for meh ili happy really :)

  7. #6
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,856 Times in 1,119 Posts
    Read the comments on the script! You can add spells on certain killstreaks by doing "player->CastSpell" inside of a case:

    Code:
                    // Do stuff on streaks below
                    switch (KillStreakContainer[killerGuid].kills)
                    {
                        case 5: // 5 kills
                            player->CastSpell(player, spellid, false);
                            break;
                        case 10: // 10 kills
                            break;
    
                        // You can also add more cases below to do more stuff during a killstreak
                    }
    You can add colors by doing:

    Code:
    |cffCOLORHEX My Player's Name|r
    "|cff" : Starts the color
    "|r" : Ends the color

    And replace COLORHEX with a color hex code: http://www.color-hex.com/ (without the #)

    For example:

    Code:
    ChatHandler(killer->GetSession()).PSendSysMessage("You killed |cffcc3333%s|r already. Kill another player to earn something from him/her again.", killedName);
    Now "%s" being the player's name, the player's name will have a color now.

  8. #7
    Original Poster
    Emulation Addict
    Join Date
    Jun 2016
    Posts
    60
    XP
    1,048
    Level
    8
    Thanks
    0
    Thanked 6 Times in 4 Posts
    Thanks toomy my favorite boy :)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •