Ue4 how to create plugin?

I cannot tell you specifically what to do, but you should start by looking into the engine documentation.