Copied from a bigger script so might not work, not sure, u will have to test it out.
procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
if Text = '!join' then Command('/setteam0 '+inttostr(ID));
if Text = '!5' then Command('/setteam5 '+inttostr(ID));
if Text = '!spec' then Command('/setteam5 '+inttostr(ID));
end;