CMUDKill Counter

Need some help with your MUD client? Forgot your password? Get help here.
Forum rules
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
User avatar
Earth
Great Adventurer
Posts: 159
Joined: 04 Mar 2010 16:40
Location: Southern California, USA

CMUDKill Counter

Post by Earth » 24 Mar 2011 22:29

Hi all,

Ilrahil made a request to me to see if I could code a kill counter in CMUD. I came up with a primitive one that's fairly easy to use, and I wanted to share it here for all to use (or study). Since it's been a while since I've used ZMUD, I'm not sure if the following will work, but my guess is that the script won't work on probably the most latest versions of ZMUD, if they work at all.

First, you need a place to store kills. In CMUD, there is a nice data type called a database record. I use this data type quite a bit, because the database record hold a list of key and value pairs. In other words, within one variable, I can store a list of other variables which I refer to by name. For my example, I will use a variable called @KillCount.

@KillCount will store data like this with the number indicating how many kills of that particular race:
  • troll = 5
    hobbit = 4
    human = 2
    orc = 4
    dwarf = 1
    goblin = 3
Now that you hopefully understand the data...let's start coding. Here is the trigger that you will need:

Code: Select all

#TRIG {You killed * (%w).} {#if (%db(@KillCount, %1) == "") {#ADDKEY KillCount %1 1} {#ADDKEY KillCount %1 (%db(@KillCount, %1) + 1)}}
If you already have a trigger that captures this, you may have to modify it, or make sure that this trigger has priority. So, let's me explain how the code works. The (%w). part of the trigger captures the last word in the sentence that has a period following it and stores it in a temp variable, %1.

The %db(@KillCount, %1) part checks the variable @KillCount to see if there is a key with the name %1 and returns the value. If CMUD can't find a variable it returns "", so basically, if you haven't killed something of %1 type, it executes {#ADDKEY KillCount %1 1}, which creates a brand new key and sets it to 1.

If the key exists already, then {#ADDKEY KillCount %1 (%db(@KillCount, %1) + 1)}} happens which basically adds 1 to the existing number it returns and puts it back inside the variable.

That's it. Nice and simple.

Now let's add a few aliases that you can use to clear and show the values in @KillCount.

Code: Select all

#alias resetkills {#var KillCount "";#echo "Kill Count Reset!"}
#alias showkills {#echo @KillCount}
With these aliases you simply type the resetkills command and it will blank out @KillCount completely. If you type showkills, it will dump a list of all types of kills and how many.

I won't concern myself with formatting at this point as it may confuse things, I'll let you figure out now to make the results pretty if you so desire.

I just wanted to keep this simple so you have something you can try and use right away. Just copy and paste the 3 code lines into your command box and you should be good to go.

The above script is one of the reasons I use CMUD, it's quite amazing how you can do something so powerful with only 3 lines of script.

Feel free to post and questions or comments here.

Happy coding!

Edited to fix typo
Last edited by Earth on 24 Mar 2011 23:06, edited 1 time in total.

Chanele
Champion
Posts: 566
Joined: 04 Mar 2010 12:39

Re: CMUDKill Counter

Post by Chanele » 24 Mar 2011 22:50

Anyone can make a guide for us zmud users?

User avatar
Cherek
Site Admin
Posts: 3612
Joined: 04 Mar 2010 04:36

Re: CMUDKill Counter

Post by Cherek » 25 Mar 2011 03:17

Come on Chanale, you've probably been using zMud forever (a hacked version too I bet), its time to actually give something back to Zuggsoft. Go get your credit card... yeah... now, off you go.

Zuggsoft has given you so much for free, you can spend a lousy $29... its like... two movie tickets... or dinner for two at McDonalds... Dont you think they are worth it? Or he rather? I think its like one guy who's been coding it the whole time. You dont think he earned your $29?

Dont you? Could you look him in the eye and say to him: "No you have not earned my $29, I rather spend them on a meal on McDonalds".

Can you?

Chanele
Champion
Posts: 566
Joined: 04 Mar 2010 12:39

Re: CMUDKill Counter

Post by Chanele » 25 Mar 2011 03:30

I started out almost 15 years ago, a student playing at computer lab...and guess what, i'm still a student:)
You should know we have other prioritys, food and beverage!

Laurel

Re: CMUDKill Counter

Post by Laurel » 25 Mar 2011 09:05

paying for anything related with a free game (except for server donations) is a big "nono" inside me

Bromen
Champion
Posts: 678
Joined: 04 Mar 2010 06:29

Re: CMUDKill Counter

Post by Bromen » 26 Mar 2011 10:10

Dinner for two at McDonalds for $29? You're insane.

That's a dinner for six. haha

b.

User avatar
OgreToyBoy
Champion
Posts: 633
Joined: 05 Mar 2010 11:36

Re: CMUDKill Counter

Post by OgreToyBoy » 26 Mar 2011 10:36

Pay if you want, or live with not having everything.
15 years... You been a student all that time?

User avatar
Cherek
Site Admin
Posts: 3612
Joined: 04 Mar 2010 04:36

Re: CMUDKill Counter

Post by Cherek » 26 Mar 2011 16:31

Laurel: There are plenty of free clients for you to use. Anyway, dont wanna turn this thread into some piracy-discussion, was kind of a joke. But yeah, I think the Zuggsoft guy had earned my $29 after I myself had been using a hacked zMud for 14 or so years..:)

Bormen: Well, I converted to Swedish currency and the dollar rate is really low these days. So yeah, its a dinner for two at McD, including dessert and coffee of course. If you all pick the cheapest menu you might get dinner for three for $29.

Bromen
Champion
Posts: 678
Joined: 04 Mar 2010 06:29

Re: CMUDKill Counter

Post by Bromen » 22 Oct 2012 08:34

So how do put this code into Cmud?

-B

User avatar
Rhaegar
Legend
Posts: 960
Joined: 13 May 2010 06:22

Re: CMUDKill Counter

Post by Rhaegar » 22 Oct 2012 10:47

bromen wrote:So how do put this code into Cmud?

-B
Can't you just use the wizards included in cmud and copy/paste what Earth posted there?

http://www.zuggsoft.com/page.php?p=cmud ... atures.htm
I fear no evil for I am fear incarnate.

Post Reply
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/