import es
import playerlib

import wcs
from wcs import wcs

itemName = 'Lightning Flash'

wcs.Item(itemName).registerItem('attack', 3000, "You have a 15% chance of blinding an enemy.", True)
        
def player_hurt(ev):
    count   = wcs.Command(ev['attacker']).GetItemCount(itemName)
    while count:
        flashTime = 0
        if random.randint(1, 100) <= 15:
            flashTime += 2
        if freezeTime:
            es.setplayerprop(ev['userid'], "CCSPlayer.m_flFlashMaxAlpha", 200)
            es.setplayerprop(ev['userid'], "CCSPlayer.m_flFlashDuration", flashTime)
            es.tell(ev['attacker'], '#multi', '#greenLightning Flash #default- #lightgreenYou have blinded#green%s #ligtgreenfor #green%s #lightgreenseconds..' % (ev['es_username'], flashTime) )
            es.tell(ev['userid'], '#multi', '#greenLightning Flash #default- #lightgreenYou have been blinded by#green%s #ligtgreenfor #green%s #lightgreenseconds..' % (ev['es_attackername'], flashTime) )
        count -= 1
        
def player_death(ev):
    wcs.Command(ev['userid']).RemoveItem(itemName)
