c++ code :

/*convert to oregon by amir_cinderella
original script created by ??*/
void OnPVPKill(Player* pKiller, Player* pVictim)
{
        uint32 KillerGUID = pKiller->GetGUIDLow();
        uint32 VictimGUID = pVictim->GetGUIDLow();
        struct KillStreak_Info
        {
            uint32 killstreak;
            uint32 lastkill;
        };

        static std::map<uint32, KillStreak_Info> KillStreakData;
        
        if (KillerGUID == VictimGUID || KillStreakData[KillerGUID].lastkill == VictimGUID)
        return;
        
        if (KillStreakData[VictimGUID].killstreak >= 3)
        {
            std::ostringstream ss;
            ss << "|cFF81CF42" << pKiller->GetName() << "|r Has Ended |cFFFFFFFF" << pVictim->GetName() << " !!! ";
            sWorld.SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
        }

        ++KillStreakData[KillerGUID].killstreak;
        KillStreakData[KillerGUID].lastkill = VictimGUID;
        KillStreakData[VictimGUID].killstreak = 0;
        KillStreakData[VictimGUID].lastkill = 0;

        if (KillStreakData[KillerGUID].killstreak % 3 == 0) // send killstreak message every 3 kills
        {
            std::ostringstream ss;
            ss << "|cFF81CF42" << pKiller->GetName() << "|r Has A KillStreak Of |cFF42A0CF" << KillStreakData[KillerGUID].killstreak << "|r!!!!!";
            sWorld.SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
        }
        else if (KillStreakData[KillerGUID].killstreak == 3)
        {
            std::ostringstream ss;
            ss << "|cFF81CF42" << pKiller->GetName() << "|r Is On A Killing Spree!!";
            sWorld.SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
        }
                
}

void AddSC_killstreak()
{
    Script *newscript;
    newscript = new Script;
    newscript->Name = "killstreak";
    newscript->pOnPVPKill = &OnPVPKill;
    newscript->RegisterSelf();
}

Nice!

"A little hard-work never killed anyone important." - Abe

Error    5    error LNK2005: "void __cdecl OnPVPKill(class Player *,class Player *)" (?OnPVPKill@@YAXPAVPlayer@@0@Z) already defined in scripts.lib(on_events.obj)    scripts.lib    oregon-core
Error    6    fatal error LNK1169: one or more multiply defined symbols found    C:\Core\build\bin\Release\oregon-core.exe   

any ?

It's because you have an empty function called OnPVPKill in your on_events.cpp file.

5 (edited by Forthehorde 2014-09-21 17:05:05)

nvm Fixed
Thanks

damm I have installed this, made 27 kills but it didint announce nothing mby missing strings ?

Did you add AddSC_killstreak to ScriptLoader.cpp?

LordUsagi wrote:

Did you add AddSC_killstreak to ScriptLoader.cpp?

yes

Not too positive then, looks like it should work fine. Can I see pastebin versions of both scriptloader.cpp and the script file you have this in?

Script Loader--- http://pastebin.com/e7jfTx2R

/*convert to oregon by amir_cinderella
original script created by ??*/
void OnPVPKill(Player* pKiller, Player* pVictim)
{
        uint32 KillerGUID = pKiller->GetGUIDLow();
        uint32 VictimGUID = pVictim->GetGUIDLow();
        struct KillStreak_Info
        {
            uint32 killstreak;
            uint32 lastkill;
        };

        static std::map<uint32, KillStreak_Info> KillStreakData;
        
        if (KillerGUID == VictimGUID || KillStreakData[KillerGUID].lastkill == VictimGUID)
        return;
        
        if (KillStreakData[VictimGUID].killstreak >= 3)
        {
            std::ostringstream ss;
            ss << "|cFF81CF42" << pKiller->GetName() << "|r Has Ended |cFFFFFFFF" << pVictim->GetName() << " !!! ";
            sWorld.SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
        }

        KillStreakData[KillerGUID].killstreak;
        KillStreakData[KillerGUID].lastkill = VictimGUID;
        KillStreakData[VictimGUID].killstreak = 0;
        KillStreakData[VictimGUID].lastkill = 0;

        if (KillStreakData[KillerGUID].killstreak % 3 == 0) // send killstreak message every 3 kills
        {
            std::ostringstream ss;
            ss << "|cFF81CF42" << pKiller->GetName() << "|r Has A KillStreak Of |cFF42A0CF" << KillStreakData[KillerGUID].killstreak << "|r!!!!!";
            sWorld.SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
        }
        else if (KillStreakData[KillerGUID].killstreak == 3)
        {
            std::ostringstream ss;
            ss << "|cFF81CF42" << pKiller->GetName() << "|r Is On A Killing Spree!!";
            sWorld.SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
        }
                
}

void AddSC_killstreak()
{
    Script *newscript;
    newscript = new Script
    newscript->Name = "killstreak";
    newscript->pOnPVPKill = &OnPVPKill;
    newscript->RegisterSelf();
}.

From the looks of the script it doesn't allow for killing the same person over and over again so

Player A kills Player B
Then Kills Player C it counts but if Kills player B again it won't count until different player has been killed

I try with killing 3 different charcters and it wont work, mby bcs i`m trying from 1 ip ? with 4 wows

Not sure, you could modify the script or try with breakpoints to see if it's executing at all.

What this script?

Similar to Dota2 or Unreal Tournament, the more kills you get you can get Killing Sprees, Godlike etc.

16 (edited by obana 2015-07-09 14:15:16)

hello,
I added a script to the core. Windows compiling is successfull, but compiling on linux - error.

/src/scripts/Custom/killstreak.cpp: In function ‘void OnPVPKill(Player*, Player*)’:
/src/scripts/Custom/killstreak.cpp:13:48: error: template argument for ‘template<class _T1, class _T2> struct std::pair’ uses local type ‘OnPVPKill(Player*, Player*)::KillStreak_Info’
/src/scripts/Custom/killstreak.cpp:13:48: error:   trying to instantiate ‘template<class _T1, class _T2> struct std::pair’
/src/scripts/Custom/killstreak.cpp:13:48: error: template argument 4 is invalid
/src/scripts/Custom/killstreak.cpp:13:64: error: invalid type in declaration before ‘;’ token
/src/scripts/Custom/killstreak.cpp:15:66: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:18:38: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:25:34: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:26:34: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:27:34: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:28:34: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:30:38: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:33:121: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
/src/scripts/Custom/killstreak.cpp:36:43: error: invalid types ‘int[uint32 {aka unsigned int}]’ for array subscript
make[2]: *** [src/scripts/CMakeFiles/scripts.dir/Custom/killstreak.cpp.o] Error 1
make[1]: *** [src/scripts/CMakeFiles/scripts.dir/all] Error 2
make: *** [all] Error 2

_________________________________
fix it
other error on server startup:

RegisterSelf, but script named killstreak does not have ScriptName assigned in database. 

how to fix?

Sorry for my bad english

This is the script i use for my server thought it might be usefull to someone

void OnPVPKill(Player* killer, Player* killed)
{
        bool OnlyInBattlegrounds = false;
        bool LooseTokenOnPvPDeath = true;
        int32 AmountOfItemsYouWantTheVictimToLoose = 1;
        bool AddTokenOnPvPKill = true;
        int32 ItemReward = 29434;
        int32 AmountOfRewardsOnKillStreak[9] = { 4, 6, 8, 10, 12, 14, 16, 18, 20 };
        int32 HowManyTimesYouWantTheKillerToGetAwardedForKillingTheSameVictim = 2;
        const int32 KillerStreak1 = 05;
        const int32 KillerStreak2 = 10;
        const int32 KillerStreak3 = 15;
        const int32 KillerStreak4 = 20;
        const int32 KillerStreak5 = 30;
        const int32 KillerStreak6 = 40;
        const int32 KillerStreak7 = 50;
        const int32 KillerStreak8 = 60;
        const int32 KillerStreak9 = 70;
        int32 KillStreaks[9] = { KillerStreak1, KillerStreak2, KillerStreak3, KillerStreak4, KillerStreak5, KillerStreak6, KillerStreak7, KillerStreak8, KillerStreak9 };

        uint32 kGUID;
        uint32 vGUID;
        char msg[500];
        kGUID = killer->GetGUID();
        vGUID = killed->GetGUID();
        std:: string killername;
        std:: string killedname;
        killername = killer->GetName();
        killedname = killed->GetName();

        struct SystemInfo
        {
            uint32 KillStreak;
            uint32 LastGUIDKill;
            uint8 KillCount;
        };

        static std::map<uint32, SystemInfo> KillingStreak;

            if (kGUID == vGUID)
        {
            return;
        }
            if (KillingStreak[kGUID].LastGUIDKill == vGUID)
        {
            KillingStreak[kGUID].KillCount++;
            KillingStreak[vGUID].KillCount = 1;
           
            killer->AddItem(ItemReward, 1);
            if (LooseTokenOnPvPDeath == true)
            {
                killed->DestroyItemCount(ItemReward, AmountOfItemsYouWantTheVictimToLoose, true, false);
            }
        }
        if (KillingStreak[kGUID].LastGUIDKill != vGUID)
        {
            KillingStreak[kGUID].KillCount = 1;
            KillingStreak[vGUID].KillCount = 1;
        }

        if (KillingStreak[kGUID].KillCount == HowManyTimesYouWantTheKillerToGetAwardedForKillingTheSameVictim)
        {
            return;
        }

        if (OnlyInBattlegrounds == true)
        {
            if (!killer->GetMap()->IsBattleground() || killer->GetMapId() == 30)
            {
                return;
            }
        }

        if (KillingStreak[vGUID].KillStreak >= 5)
        {
            int killstreak = KillingStreak[vGUID].KillStreak;
            std::ostringstream ss;
            ss << "|cffFF0000[KillStreak Announcer]: |cff00FF00" << killer->GetName() << "|r Has Ended |cff00FF00" << killed->GetName() << "|r's killing streak of " << killstreak;
            sWorld.SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
        }

        KillingStreak[kGUID].KillStreak++;
        KillingStreak[vGUID].KillStreak = 0;
        KillingStreak[kGUID].LastGUIDKill = vGUID;
        KillingStreak[vGUID].LastGUIDKill = 0;

        if (AddTokenOnPvPKill == true)
        {
            killer->AddItem(29435, 1);
        }

        if (LooseTokenOnPvPDeath == true)
        {
            killed->DestroyItemCount(ItemReward, AmountOfItemsYouWantTheVictimToLoose, true);
        }

        switch(KillingStreak[kGUID].KillStreak)
        {
            case KillerStreak1:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF5|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[1]);
                killer->ModifyHonorPoints(500);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak2:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF10|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[2]);
                killer->ModifyHonorPoints(1000);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak3:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF15|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[3]);
                killer->ModifyHonorPoints(1500);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak4:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF20|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[4]);
                killer->ModifyHonorPoints(2000);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak5:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF30|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[5]);
                killer->ModifyHonorPoints(3000);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak6:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF40|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[6]);
                killer->ModifyHonorPoints(4000);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak7:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF50|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[7]);
                killer->ModifyHonorPoints(5000);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak8:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF60|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[8]);
                killer->ModifyHonorPoints(6000);
                killer->CastSpell(killer, 24378, true);
                break;

            case KillerStreak9:
                snprintf(msg, 500, "|cffFF0000[KillStreak Announcer]: |cff00FF00%s|r killed |cff00FF00%s|r and is on |cff00FFFF70|r kill streak.", killername.c_str(), killedname.c_str());
                sWorld.SendServerMessage(SERVER_MSG_STRING, msg);
                killer->AddItem(ItemReward, AmountOfRewardsOnKillStreak[9]);
                KillingStreak[kGUID].KillStreak = 0;
                killer->ModifyHonorPoints(7000);
                killer->CastSpell(killer, 24378, true);
                break;
        }
    }

Nice code.... smile smile smile