Syntax: Select all
# Python Imports
from collections import defaultdict
# SourcePython imports
from players.entity import PlayerEntity
from players.helpers import userid_from_index
from players.helpers import index_from_userid
from events import Event
from cvars.public import PublicConVar
from plugins.info import PluginInfo
info = PluginInfo()
info.name = "Death and Kill Streaks"
info.author = "Nergal/Assyrian"
info.version = "1.0"
info.basename = "dkstreaks"
info.variable = info.basename + "_version"
info.convar = PublicConVar(info.variable, info.version, 0, info.name + " Version")
#create a list
deathstreaks = defaultdict(int) #[i+1 for i in range(66)]
killstreaks = defaultdict(int) #[i+1 for i in range(66)]
def set_playerlist(index):
deathstreaks[index] = 0
killstreaks[index] = 0
@Event
def player_connect(game_event):
set_playerlist( index_from_userid(game_event.get_int('userid')) )
@Event
def player_disconnect(game_event):
set_playerlist( index_from_userid(game_event.get_int('userid')) )
@Event
def player_death(game_event):
victim = index_from_userid( game_event.get_int('userid') )
attacker = index_from_userid( game_event.get_int('attacker') )
if victim == attacker || attacker == -1:
return
if killstreaks[victim] == 0:
deathstreaks[victim] += 1
killstreaks[victim] = 0
deathstreaks[attacker] = 0
killstreaks[attacker] += 1