To switch inductive load (for example 24V magnetic lock), MOSFET with higher current and voltage rating is required. Low threshold voltage below 3V is crucial as well. Inductor, serial resistor and parallel diode represents internal circuit of the magnetic lock. In case you want to drive some different inductive load, make sure the flyback diode or varistor of proper rating is present in parallel to the inductor. The zener diode is usually included in the MOSFET, however it is not meant to dissipate the high power surges from inductor. 500 pF cap simulates MOSFET gate capacitance. Schottky diode protects 3.3V RPi GPIO pin against overvoltage due to some failure in circuit. 16 Ohm is GPIO output impedance. Switching of 3.3V is controlled by software.