mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2008
Posts: 167
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Hi, I have mmysql working, and a way that someone can change the topic on a website, and it be reflected in the chatroom.

So, I have the following:
Code:
alias checktopic {
  var %db = $mysql_connect(host, username, password, database)
  var %sql = SELECT topic FROM sean where ID = 1
  var %res = $mysql_query(%db, %sql)
  if (%res) {
    while ($mysql_fetch_row(%res, row, $MYSQL_ASSOC)) {
      if $hget(row, topic) != $1($1).topic {
        /topic #no-nick $hget(row, topic)
      }
      else {
        halt
      }
      mysql_free %res
    }
    else {
      echo -a Error executing query: %mysql_errstr
    }
  }
}


The alias is /timermytopic 0 20 checktopic $chan

It all seams to be working correctly..
[18:53] * test-bot changes topic to 'This is my topic!!!!'

But, in another 20 seconds, it will change it again, and it will continually change it.

I am wondering how this could be done to it doesn't keep updating the topic every 20 seconds?

Thank you for any help provided,:D

Last edited by seanturner70; 23/06/09 08:04 PM.
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Certainly because your syntax for the condition is false :
Quote:
if $hget(row, topic) != $1($1).topic {
You can't use $1($1).topic, this will echo '$1 $+ ).topic' (this is because of mirc parser) but anyway, use $chan($1).topic

Last edited by Wims; 23/06/09 08:09 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2008
Posts: 167
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Thank you so much Wims, your change worked a treat.


Link Copied to Clipboard