By default, XChat provides the /HOP command, which is used to give chanhalf-op to the provided nickname. We will not replace this command as it still may be useful on some networks, instead we will use a new command, say /PJ (or any other you like).
Here's how the script looks like:
What does it do?
Xchat::register ("PJ", "0.1.0", "Part/Join");
Xchat::hook_command ("PJ", cmd_pj);
Xchat::command ("ECHO PART/JOIN script loaded. Use it typing /PJ.");
$chan = Xchat::get_info ("channel");
Xchat::command ("PART $chan");
Xchat::command ("JOIN $chan");
Basically, the first command will tell XChat the information about the script (name, version number, description). The second one will declare the command /PJ and the subroutine to use when it's triggered, cmd_pj. The body under sub cmd_pj contains what the command will actually do, and that's to get the name of the current channel, part it and rejoin.
Save the script under any name, say pj.pl, and put it under your ~/.xchat2/ directory, where ~ is your home directory. The script will be automatically loaded each time XChat starts.