# Bonus plugin for Deathrun Mod v 1.5
# Visit our DeathRun Server 188.134.21.171:27015
# Visit our site www.tk-portal.ru

import es, playerlib

deathrun_noblock = es.ServerVar("deathrun_noblock")
deathrun_armor = es.ServerVar("deathrun_armor")
deathrun_nightvision = es.ServerVar("deathrun_nightvision")
deathrun_crysisskin = es.ServerVar("deathrun_crysisskin")

def load():
    es.server.cmd("es_xmexec ../addons/eventscripts/deathrun/deathrun.cfg")
    if int(deathrun_crysisskin) == 1:
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit.vtf')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit.vmt')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit_bump.vtf')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit_helm.vtf')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit_helm.vmt')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit_helm_bump.vtf')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit_visir.vtf')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit_visir.vmt')
        es.server.queuecmd('downloadable materials/models/player/slow/nanosuit/slow_nanosuit_visir_bump.vtf')
        es.server.queuecmd('downloadable models/player/slow/nanosuit/slow_nanosuit.dx80.vtx')
        es.server.queuecmd('downloadable models/player/slow/nanosuit/slow_nanosuit.dx90.vtx')
        es.server.queuecmd('downloadable models/player/slow/nanosuit/slow_nanosuit.mdl')
        es.server.queuecmd('downloadable models/player/slow/nanosuit/slow_nanosuit.phy')
        es.server.queuecmd('downloadable models/player/slow/nanosuit/slow_nanosuit.sw.vtx')
        es.server.queuecmd('downloadable models/player/slow/nanosuit/slow_nanosuit.vvd')
        es.server.queuecmd('downloadable models/player/slow/nanosuit/slow_nanosuit.xbox.vtx')

def es_map_start(event_var): 
    es.server.cmd("es_xmexec ../addons/eventscripts/deathrun/deathrun.cfg")

def player_spawn(event_var):
    userid = int(event_var['userid'])
    player = playerlib.getPlayer(userid)
    score = player.attributes['kills']
    if es.getplayerteam(userid) == 2:
        es.tell(userid, '#multi', '#lightgreenYou have become a terrorist,kill all ct')
    if int(deathrun_noblock) == 1:
        es.setplayerprop(userid, 'CBaseEntity.m_CollisionGroup', 2)
    es.fire(userid, "!self", "addoutput", "gravity 1")
    if es.getplayerteam(userid) == 3:
        if int(deathrun_armor) == 1:
            player.set("armor", "125")
        if int(deathrun_nightvision) == 1:
            player.set("nightvision", 1)
        if score == 1:
            player.set("speed", 1.05)
            player.set("health", 105)
            es.tell(userid, '#multi', '#lightgreenYou have gained 5% more speed and #green5 HP #lightgreenfor #green1 frag.')
        elif score == 2:
            player.set("speed", 1.10)
            player.set("health", 110)
            es.tell(userid, '#multi', '#lightgreenYou have gained 10% more speed and #green10 HP #lightgreenfor #green2 frags.')
        elif score == 3:
            player.set("speed", 1.10)
            player.set("health", 115)
            es.fire(userid, "!self", "addoutput", "gravity 0.9")
            es.tell(userid, '#multi', '#lightgreenYou have gained 10% more speed, #green10% less gravity #lightgreenand #green15 HP #lightgreenfor #green3 frags.')
        elif score == 4:
            player.set("speed", 1.10)
            player.set("health", 120)
            es.fire(userid, "!self", "addoutput", "gravity 0.9")
            es.tell(userid, '#multi', '#lightgreenYou have gained 10% more speed, #green10% less gravity #lightgreenand #green20 HP #lightgreenfor #green4 frags.')	
        elif score == 5:
            player.set("speed", 1.15)
            player.set("health", 125)
            es.fire(userid, "!self", "addoutput", "gravity 0.85")
            es.tell(userid, '#multi', '#lightgreenYou have gained 15% more speed, #green15% less gravity #lightgreenand #green25 HP #lightgreenfor #green5 frags.')
        elif score == 6:
            player.set("speed", 1.15)
            player.set("health", 130)
            es.fire(userid, "!self", "addoutput", "gravity 0.85")       
            es.tell(userid, '#multi', '#lightgreenYou have gained 15% more speed, #green15% less gravity #lightgreenand #green30 HP #lightgreenfor #green6 frags.')
        elif score == 7:
            player.set("speed", 1.15)
            player.set("health", 135)
            es.fire(userid, "!self", "addoutput", "gravity 0.8")
            es.tell(userid, '#multi', '#lightgreenYou have gained 15% more speed, #green20% less gravity #lightgreenand #green35 HP #lightgreenfor #green7 frags.')
        elif score == 8:
            player.set("speed", 1.15)
            player.set("health", 140)
            es.fire(userid, "!self", "addoutput", "gravity 0.8")
            es.tell(userid, '#multi', '#lightgreenYou have gained 15% more speed, #green20% less gravity #lightgreenand #green40 HP #lightgreenfor #green8 frags.')
        elif score == 9:
            player.set("speed", 1.2)
            player.set("health", 145)
            es.fire(userid, "!self", "addoutput", "gravity 0.75")
            es.tell(userid, '#multi', '#lightgreenYou have gained 20% more speed, #green25% less gravity #lightgreenand #green45 HP #lightgreenfor #green9 frags.')
        elif score > 9:
            player.set("speed", 1.25)
            player.set("health", 150)
            es.fire(userid, "!self", "addoutput", "gravity 0.7")
            es.tell(userid, '#multi', '#lightgreenYou have gained 25% more speed, #green30% less gravity #lightgreenand #green50 HP #lightgreenfor #green10 frags.')
            if int(deathrun_crysisskin) == 1:
                player.setModel('player/slow/nanosuit/slow_nanosuit.mdl')

def player_death(event_var):
    userid = int(event_var['userid'])
    playerlib.getPlayer(userid).set("speed", 1)