• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

OnPVPKill Abuse System

Tommy

Founder
Hello! Today I'm going to release a script that I made just for PvP purposes. This is so those nasty players of yours can't cheat!

What does this system do?

  • Prevents players from killing each other for a certain amount of minutes

It is a pretty easy system to understand.


Let me show you some screen-shots!


I killed my opponent:

fd5cfc3500044f00ae57fff.png



I want to kill the same player again, but...

ZceVAxA.jpg

At first I tried to kill the same player again, it prompt me with the '2 minute' wait time, afterwards the '1 minute' wait time.


Now I spammed killed the player, which didn't work! Gawd. As you see on the bottom, it reset to 2 minutes. That is because the timer reset and removed me from the abuse list so I can kill the player again and receive my reward(s).


1qrcznH.jpg


.: Script :.
http://paste2.org/ID3XOaOJ - Paste2
http://pastebin.com/h19KymwS - Pastebin
Code:
/*
 *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗ 
 *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
 *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
 *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
 *            [URL="http://www.emudevs.com"]www.emudevs.com[/URL]
*/
struct PlayerAbuse
{
    uint64 victimGUID;
    uint32 whenKilled;
};

std::map<uint64, PlayerAbuse> abuseList;

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

    void OnPVPKill(Player* killer, Player* victim)
    {
        if (killer->GetGUID() == victim->GetGUID())
            return;

        if (!abuseList.empty())
        {
            for (std::map<uint64, PlayerAbuse>::const_iterator itr = abuseList.begin(); itr != abuseList.end(); ++itr)
            {
                if (itr->first == killer->GetGUID() && itr->second.victimGUID == victim->GetGUID()) // Initial check
                {
                    if (GetMSTimeDiffToNow(itr->second.whenKilled) < 180000) // < 3 minutes 180000
                    {   // The player won't be able to kill the same player for another 3 minutes
                        ChatHandler(killer->GetSession()).PSendSysMessage("You cannot kill this player for another %u minute(s).", CalculateTimeInMinutes(GetMSTimeDiffToNow(itr->second.whenKilled)));
                        return;
                    }
                    else
                        abuseList.erase(killer->GetGUID());
                }
            }
        }
        // Adding the killer/victimGUID to the abuse list
        abuseList[killer->GetGUID()].victimGUID = victim->GetGUID();
        abuseList[killer->GetGUID()].whenKilled = getMSTime();

        /* You can add other code beyond this point */
    }

    uint32 CalculateTimeInMinutes(uint32 m_time)
    {
        uint32 howManyMinutes;
        if (m_time >= 180000) // 180000 = 3 minutes
            howManyMinutes = 3;
        else if (m_time < 180000-60000)
            howManyMinutes = 2;
        else if (m_time > 180000-60000)
            howManyMinutes = 1;
        return howManyMinutes;
    }
};

void AddSC_player_abuse()
{
    new kill_player_abuse();
}
 

lillecarl

Respected Member
Good idea!
I used another approach on my own system.
I made 2 deques (use vectors if you like) on the player class (guess they can be added in scripts, i do not raelly get trinitycores scripting system)
on kill:
Code:
m_killed.push_front(ipaddress);
while (m_killed.size() > 20)
    m_killed.pop_back();

uint8 count = 0;
for (iteratoretc.. itr = m_killed.begin(); itr != m_killed.end(); ++itr;
    if (*itr = ipaddress)
        ++count;

if (count > 5)
    return true;
return false;

just wrote this in the browser, but it's the logic i use. Then you can players by percentage instead of timer. But i might actually do something that does a long term check for less % farming and "time bans" users from killing eachother. To make it really safe :)

Thanks for the idea, i thought i could share mine as well :)
 
Top