Page 1 of 2

CMUDKill Counter

Posted: 24 Mar 2011 22:29
by Earth
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

Re: CMUDKill Counter

Posted: 24 Mar 2011 22:50
by Chanele
Anyone can make a guide for us zmud users?

Re: CMUDKill Counter

Posted: 25 Mar 2011 03:17
by Cherek
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?

Re: CMUDKill Counter

Posted: 25 Mar 2011 03:30
by Chanele
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!

Re: CMUDKill Counter

Posted: 25 Mar 2011 09:05
by Laurel
paying for anything related with a free game (except for server donations) is a big "nono" inside me

Re: CMUDKill Counter

Posted: 26 Mar 2011 10:10
by Bromen
Dinner for two at McDonalds for $29? You're insane.

That's a dinner for six. haha

b.

Re: CMUDKill Counter

Posted: 26 Mar 2011 10:36
by OgreToyBoy
Pay if you want, or live with not having everything.
15 years... You been a student all that time?

Re: CMUDKill Counter

Posted: 26 Mar 2011 16:31
by Cherek
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.

Re: CMUDKill Counter

Posted: 22 Oct 2012 08:34
by Bromen
So how do put this code into Cmud?

-B

Re: CMUDKill Counter

Posted: 22 Oct 2012 10:47
by Rhaegar
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