in an on text event you're asked to specify the location of the message. In the script you posted, the location is :#: meaning
ANY CHANNELS. As per the help files, if you change that to :?: it will mean for
ANY PRIVATEMESSAGES - Note that you would also have to manually specify the channel from that point on, $chan is only present in the case when the message is written in the channel.
on !1:TEXT:*!helpme*:?:/mode #channelname +o $nick