Jump to content
Search In
  • More options...
Find results that contain...
Find results in...



#0
Guest

User Menu


Sign In

Sign In



Sign Up

Forum Menu


Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!

Sign in to follow this  
Taco

PvP Kill Reward Script With Cooldown! Stop your player's from kill farming!

Recommended Posts

T
O
P
I
C

S
T
A
R
T
E
R

So today someone was asking about how to prevent players from sitting in a corner trading kills for items. I thought about the options and most people's solution was garbage. I thought what if i made each player have a cooldown.

And so this script was born:

2ded6e01853442878cba891d1446376c.png

It might not be the best way to handle this and there is quite a few more things I could add to this. But it works and I haven't found any flaws in it so far. I made it in a couple hours. I thought about trying to sell this after I finished it but figured it would be nice to give the community something. So enjoy and give me your opinion especially you @Rochet2 if you manage to see this.

Some of my ideas on things I should add:

  • Making World Configs/Updating Trinity Core's Default Ones.
  • Perhaps Clearing the map from memory on shutdown. "Might not be needed but a good idea none the less".
  • A couple bools to disable/enable the messages..
  • A had a few other meh ideas.

You can get the script from my public Bitbucket Repo.

Share this post


Link to post
Share on other sites

Not sure if you are the author of the script who posted it on the other emulation forums however a better solution would be this 

enum Configurations{
    itemID = 45978,
    amount = 1
}

struct check_delay_info{
    uint32 lastChecked;
};
static std::map<uint32, check_delay_info> check_delay;
class PvPRewards : PlayerScript
{
public:
    PvPRewards() : PlayerScript("PvPRewards") {}
    
    //This is called when a player kills another player.
    void OnPVPKill(Player* killer, Player* /*killed*/)
    {
        //get curent timestamp
        time_t now = time(0);

        //get player guid as index for our map
        uint32 playerguid = killer->GetGUID();

        //turn the remaining time into a string so we can show it in chat
        std::string rem_time = std::to_string(check_delay[playerguid].lastChecked - now);

        //If cooldow is cleared add item and update cooldown
        if (now >= check_delay[playerguid].lastChecked){
            killer->AddItem(itemID, amount);
            ChatHandler(killer->GetSession()).PSendSysMessage("You have been rewarded with %u pvp tokens for killing a player of the oposite faction and begun a cooldown", amount);
            check_delay[playerguid].lastChecked = now + 60; //1 minute cooldown
        }
        //Else send a message with remaining time
        else
            ChatHandler(killer->GetSession()).PSendSysMessage("You must wait %s seconds before receving another kill credit !", rem_time.c_str());
    }
};

void AddSC_PvPRewards()
{
    new PvPRewards();
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

About Us

MMO-Society is the Forum former known as Lordcraft, MMO-Society offers various of Resources to help you evolve your knowledge within Emulation, In the process we make sure to form a strong community bond in-between each other and thus we are proud to can admit that MMO-Society is possibly the friendliest Community Forum to currently exist.

All trademarks referenced are the properties of their respective owners.
©2018 MMO-Society. All rights reserved.

Social Links

Discord Server Join
Twitter Follow us
×
×
  • Create New...