@name BAREL THINGSYTY
@persist Barrel:entity Ply:entity
@trigger all

if(first() || duped()){
    
runOnChat(1)
runOnLast(1)
runOnTick(1)  
propSpawnEffect(0)

Ply = noentity()

function entity getPlayerByName(Nk:string){
    
    local PL = players()
    
    for(I = 0,PL:count()){
        if(PL[I,entity]:name():lower():find(Nk)){
         return PL[I,entity]   
        }
    }
}

}

if(chatClk(owner())){
    
    local Chat = owner():lastSaid():lower():explode(" ")
    
    if(Chat[1,string] == "-minge"){
        
        hideChat(1)
        Ply = getPlayerByName(Chat[2,string])
        
        if(Ply:isValid() && Ply:isPlayer()){
            
         print("Found Player ("+Ply:name()+")")
            
         Barrel = propSpawn("models/props_borealis/bluebarrel001.mdl",Ply:pos(),ang(0,0,0),1)
         Barrel:setAlpha(0)
        
         timer("remove",5000) # Remove after 5 seconds
        
        }
        
    }
    
}

if(Ply != noentity()){
 Barrel:setPos(Ply:pos())   
}

if(clk("remove")){
  Barrel:propDelete()  
  Ply = noentity()
  print("Removed Minge Thingy")
}

if(last()){
  Barrel:propDelete()   
  Ply = noentity()
}
