import es, random, gamethread

def player_death(event_var):
    userid = int(event_var['userid'])
    dissolve(userid)
	
def dissolve(userid):
    es.server.queuecmd('es_xgive %s env_entity_dissolver'%userid)
    es.server.queuecmd('es_xfire %s env_entity_dissolver AddOutput "target cs_ragdoll"'%userid)
    if random.randint(1,3) < 3:       
        es.server.queuecmd('es_xfire %s env_entity_dissolver AddOutput "magnitude 1"'%userid)
        es.server.queuecmd('es_xfire %s env_entity_dissolver AddOutput "dissolvetype %s"'%(userid,random.choice(['1','3'])))
    else:
        es.server.queuecmd('es_xfire %s env_entity_dissolver AddOutput "magnitude 5000"'%userid)
    es.server.queuecmd('es_xfire %s env_entity_dissolver Dissolve'%userid)
    gamethread.delayed(0.05, es.server.queuecmd, 'es_xremove env_entity_dissolver')