Signup Now
Page 1 of 14 12311 ... LastLast
Results 1 to 10 of 131

Thread: Kill Counter

  1. #1
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,440
    Reputation
    283
    Rep Power
    27

    Kill Counter

    Kill Counter


    Description

    Automatically counts all killed monsters and optionally saves it to the character's database. Exposes the saved data through the public API described below:


    Configuration

    Edit the saveToDB variable on the init block to specify whether the bot should save the kill count data to the database so that it persists across different sessions.


    Public API

    • killCount.set(count, name¹, name², name*, ...)
      Sets the kill count to count for creatures with names name¹, name², name*, ...
    • killCount.reset(name¹, name², name*, ...)
      Sets the kill count to 0 for creatures with names name¹, name², name*, ...
    • killCount.add(addAmount, name¹, name², name*, ...)
      Adds addAmount to the kill count for creatures with names name¹, name², name*, ...
    • killCount.get(name¹, name², name*, ...)
      Gets the sum of the kill count for creatures with names name¹, name², name*, ...



    Examples

    Checking Amount Killed (Action)
    if killCount.get('Medusa') > 500 then
    gotolabel('BackToCity')
    end

    Reseting Based after NPC Talk (Action)
    npctalk('hi', 'task', 'task', 'medusae', 'yes')
    killCount.reset('Medusa')



    Code

    init start
    -- local SCRIPT_VERSION = '1.1.1'

    -- If set to true, will save kill count to $chardb so that it is persisted
    -- throughout different sessions.
    local saveToDB = true

    -- DO NOT EDIT BELOW THIS LINE --

    -- We don't want to override the object because that'd delete all data in
    -- killCount.creatures
    if killCount == nil then
    killCount = {
    creatures = {},
    lastRan = $timems
    }

    killCount.set = function(count, ...)
    local names = table.each({...}, string.lower)

    for _, v in ipairs(names) do
    killCount.creatures[v] = count

    if killCount.saveToDB then
    $chardb:setvalue('killCount', v, count)
    end
    end
    end

    killCount.add = function(addAmount, ...)
    local names = table.each({...}, string.lower)

    for _, v in ipairs(names) do
    killCount.set(killCount.get(v) + addAmount, v)
    end
    end

    killCount.reset = function(...)
    killCount.set(0, ...)
    end

    killCount.get = function(...)
    local names = table.each({...}, string.lower)

    local count = 0
    for _, v in ipairs(names) do
    local cCount = killCount.creatures[v]

    if cCount == nil then
    cCount = 0
    killCount.set(cCount, v)
    end

    count = count + cCount
    end

    return count
    end

    if saveToDB then
    -- Thanks to [MENTION=1]Lucas Terra[/MENTION] for implementing database iterators for the
    -- sole purpose of making this script better. Lucas, you rock!
    foreach $chardb:sectionvalue v 'killCount' do
    killCount.set(v.value, v.name)
    end
    end
    end

    -- We only set saveToDB now because else it would cause unnecessary updates
    -- queried to the database when we first read it.
    killCount.saveToDB = saveToDB
    init end

    auto(100)
    foreach newmessage m do
    if m.type == MSG_INFO then
    local creature = m.content:match(REGEX_LOOT)

    if creature then
    killCount.add(1, creature)
    end
    end
    end

    -- You're welcome, Leonardo
    killCount.lastRan = $timems

    Git
    Last edited by Raphael; 09-03-2014 at 11:17 PM.
    RaphSeller
    PayPal Instantaneous Reseller


    raphseller.com

  2. #2
    Wind Tester
    Join Date
    Dec 2013
    Location
    Warsaw, Poland
    Posts
    2,578
    Reputation
    149
    Rep Power
    27
    very nice

  3. #3
    Moderator BUgWT's Avatar
    Join Date
    Dec 2013
    Location
    www.bugwt.com
    Posts
    546
    Reputation
    72
    Rep Power
    22
    u make me so proud


    LATEST SCRIPTS SKYPE
    Got a Question? Add me on Skype!
    bugwt.support

    This image is hosted on a possibly dangerous website (http://mystatus.skype.com/smallclassic/bugwt.support). Please consider reuploading it on Imgur.com.


  4. #4
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,440
    Reputation
    283
    Rep Power
    27
    Script Updated!

    Forgot to remove some testing stuff.
    RaphSeller
    PayPal Instantaneous Reseller


    raphseller.com

  5. #5
    Free User Donatello's Avatar
    Join Date
    Dec 2013
    Location
    Tuscany, Italy
    Posts
    398
    Reputation
    51
    Rep Power
    21
    I really liked it bro <3

  6. #6
    Free User
    Join Date
    Feb 2014
    Posts
    5
    Reputation
    10
    Rep Power
    0
    I'm unable to get this to work with my bot. It's supposed to be added in as a HUD right?
    And i don't edit anything, just add it?

    Sorry if you find these questions dumb, but i'm a new customer

  7. #7
    Wind Powered
    Join Date
    Dec 2013
    Location
    dvscripts.com
    Posts
    7,105
    Reputation
    433
    Rep Power
    39
    You just need add this Code like Scripter -> Persistent and later to Check it and later for example

    --Check Task
    if killCount.get("Sea Serpent","Young Sea Serpent") > 900 then
    gotolabel("Start","TaskMaker")
    else end


    Its not working with HUD to show how many Killed go to HUDS - > Kill Counter
    Regards

  8. #8
    Moderator Raphael's Avatar
    Join Date
    Dec 2013
    Location
    raphseller.com
    Posts
    2,440
    Reputation
    283
    Rep Power
    27
    Quote Originally Posted by Undeadz View Post
    I'm unable to get this to work with my bot. It's supposed to be added in as a HUD right?
    And i don't edit anything, just add it?

    Sorry if you find these questions dumb, but i'm a new customer
    No, it's meant to be added as a hotkey.
    RaphSeller
    PayPal Instantaneous Reseller


    raphseller.com

  9. #9
    Wind Powered
    Join Date
    Dec 2013
    Location
    dvscripts.com
    Posts
    7,105
    Reputation
    433
    Rep Power
    39
    @Raphael @Leonardo it isn't working after up in my script ? there are need any changes?

  10. #10
    Free User Donatello's Avatar
    Join Date
    Dec 2013
    Location
    Tuscany, Italy
    Posts
    398
    Reputation
    51
    Rep Power
    21
    Quote Originally Posted by Dworak View Post
    it isn't working after up in my script ? there are need any changes?
    It is working fine here, just did a test.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •