Note: This forum is merely an archive. It is no longer possible to register or post. - StackOverflow
New Ace of Spades Forums: http://buildandshoot.com/

Ratio 1.2 *Now With Headshot K/D*

Finished a script? Pop it in here.

Ratio 1.2 *Now With Headshot K/D*

Postby LinktersHD » Wed Jul 25, 2012 10:00 am

At last Infogulch and Me figured out how to add Headshot K/D within the ratio.py.
Basically it will tell you:
%s kills, %s deaths, %s headshot, %s melee, %s grenade
Anyway here is the download link to it:
https://dl.dropbox.com/u/87474659/Scripts/ratio.py
And here is the code:
Code: Select all
"""
K/D ratio script.

Author: LinktersHD, Infogulch, Yourself
Maintainer: mat^2
"""

from commands import get_player, add
from pyspades.constants import *

# True if you want to include the headshot-death ratio in the ratio
# NOTE: this makes the message overflow into two lines
HEADSHOT_RATIO = True

# "ratio" must be AFTER "votekick" in the config.txt script list
RATIO_ON_VOTEKICK = True
IRC_ONLY = False

def ratio(connection, user=None):
    msg = "You have"
    if user != None:
        connection = get_player(connection.protocol, user)
        msg = "%s has"
        if connection not in connection.protocol.players:
            raise KeyError()
        msg %= connection.name
    if connection not in connection.protocol.players:
        raise KeyError()
   
    kills = connection.ratio_kills
    deaths = float(max(1,connection.ratio_deaths))
    headshotkills = connection.ratio_headshotkills
    meleekills = connection.ratio_meleekills
    grenadekills = connection.ratio_grenadekills
   
    msg += " a kill-death ratio of %.2f" % (kills/deaths)
    if HEADSHOT_RATIO:
        msg += ", headshot-death ratio of %.2f" % (headshotkills/deaths)
    msg += " (%s kills, %s deaths, %s headshot, %s melee, %s grenade)." % (kills, connection.ratio_deaths, headshotkills, meleekills, grenadekills)
    return msg

add(ratio)

def apply_script(protocol, connection, config):
    class RatioConnection(connection):
        ratio_kills = 0
        ratio_headshotkills = 0
        ratio_meleekills = 0
        ratio_grenadekills = 0
        ratio_deaths = 0
       
        def on_kill(self, killer, type, grenade):
            if killer is not None and self.team is not killer.team:
                if self != killer:
                    killer.ratio_kills += 1
                    killer.ratio_headshotkills += type == HEADSHOT_KILL
                    killer.ratio_meleekills    += type == MELEE_KILL
                    killer.ratio_grenadekills  += type == GRENADE_KILL
           
            self.ratio_deaths += 1
            return connection.on_kill(self, killer, type, grenade)
   
    class RatioProtocol(protocol):
        def on_votekick_start(self, instigator, victim, reason):
            result = protocol.on_votekick_start(self, instigator, victim, reason)
            if result is None and RATIO_ON_VOTEKICK:
                message = ratio(instigator, victim.name)
                if IRC_ONLY:
                    self.irc_say('* ' + message)
                else:
                    self.send_chat(message, irc = True)
            return result
   
    return RatioProtocol, RatioConnection
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: Ratio 1.2 *Now With Headshot K/D*

Postby BlueToonYoshi » Wed Jul 25, 2012 9:51 pm

Wow great job guys! This is a very nice update to the ratio script! Do you think you can add the addition of how many shots total you did, like the accuracy script? It would basically make that script useless now if you do. I think people would like the feature too.
User avatar
BlueToonYoshi
Member
 
Posts: 240
Joined: Sun Feb 19, 2012 6:03 am
Location: Mississippi

Re: Ratio 1.2 *Now With Headshot K/D*

Postby LinktersHD » Wed Jul 25, 2012 9:52 pm

BlueToonYoshi wrote:Wow great job guys! This is a very nice update to the ratio script! Do you think you can add the addition of how many shots total you did, like the accuracy script? It would basically make that script useless now if you do. I think people would like the feature too.

Sure!
I will see if i can do that.
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: Ratio 1.2 *Now With Headshot K/D*

Postby BlueToonYoshi » Wed Jul 25, 2012 9:56 pm

Thank you! I appreciate it.
User avatar
BlueToonYoshi
Member
 
Posts: 240
Joined: Sun Feb 19, 2012 6:03 am
Location: Mississippi

Re: Ratio 1.2 *Now With Headshot K/D*

Postby LinktersHD » Wed Jul 25, 2012 9:58 pm

BlueToonYoshi wrote:Thank you! I appreciate it.

By any chance do you host a server?
If not get one at DMEHosting.com. They are very cheap at $3.95 p/m. If you did i would see your server have a great potential since you know a lot about Pyspades.
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: Ratio 1.2 *Now With Headshot K/D*

Postby BlueToonYoshi » Wed Jul 25, 2012 10:06 pm

No I can't host a server, due to not being able to port-forward. My dad has it so I can't do it. Also I am broke right now. Oh and also I have been watching over the servers a little. Also I really think you should add more maps to the rotation on the servers. Playing same old maps gets a little repetitive sometimes.
User avatar
BlueToonYoshi
Member
 
Posts: 240
Joined: Sun Feb 19, 2012 6:03 am
Location: Mississippi

Re: Ratio 1.2 *Now With Headshot K/D*

Postby LinktersHD » Wed Jul 25, 2012 10:07 pm

Ah ok.
Please reply on this thread:
viewtopic.php?f=11&t=12601
About the server tomorrow it is having a major upgrade. So don't worry it will be MORE fun.
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: Ratio 1.2 *Now With Headshot K/D*

Postby EssigGurkenFred » Sat Aug 04, 2012 3:25 pm

I was waiting for this a long time! Thanks :)
User avatar
EssigGurkenFred
Member
 
Posts: 1370
Joined: Tue Jan 31, 2012 6:47 pm
Location: At Home

Re: Ratio 1.2 *Now With Headshot K/D*

Postby Varun » Sat Aug 04, 2012 3:32 pm

Nice. Very nice. Another thing to improve myself on. I personally use ratios primarily to improve myself, and to see where I am at. This is/will be very helpful.
User avatar
Varun
{RS} Leader
 
Posts: 2472
Joined: Mon Feb 20, 2012 6:46 am
Location: Burnie, Tasmania, Australia, where I will be in my bed from 0000 to 1300.

Re: Ratio 1.2 *Now With Headshot K/D*

Postby jojoestinky » Wed Aug 08, 2012 7:44 am

This is cool! thank you
User avatar
jojoestinky
[C.H] Member
 
Posts: 171
Joined: Sat Jul 21, 2012 9:26 am


Return to Script releases



Who is online

Users browsing this forum: No registered users and 3 guests

cron