mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2011
Posts: 10
Z
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2011
Posts: 10
Code:
on 5:TEXT:!updatecb *:#:{ 

  write -c orders.txt Current Battle: $2- 

} 

on *:TEXT:!cb:#:msg $chan $read(orders.txt)



The above is the current code I have. That is actually working perfectly fine at the moment. However, It doesn't work for my IRC Nickname as they only work on other people.

My current Users List is below:

Code:
5:MyNick 
5:FriendNick1 
5:FriendNick2 
5:FriendNick3


If you could, let me know how I would have the commands work with MyNick as well.

Both !updatecb and !cb don't work for me - I would like !cb to work for anyone, and !updatecb to work with those with a permission of 5.

Thanks in advance.

Last edited by ZGoldsmith92; 23/07/11 08:42 PM.
Joined: Jun 2011
Posts: 10
Z
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2011
Posts: 10
Got it fixed.

This was the working code:

Code:
on 5:INPUT:#:{
  if ($1 == !updatecb) { 
    write -c orders.txt 2Current Battle: $2- 
    .timermsg 1 1 msg $chan 3Battle Updated Successfully!
  } 


  on *:INPUT:#:{
    if ($1 == !cb) { .timermsg 1 1 msg $chan $read(orders.txt) 
    }

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Using a text file for storing a line of message is such a waste of resource.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I think $read/write is acceptable for this kind of once-in-a-while operation. However, you should make your code safe (i.e unexploitable) by including the "n" switch at $read:
Quote:
on *:TEXT:!cb:#:msg $chan $read(orders.txt,nt)

Also note that the timer in your input event will add an extra evaluation layer to its command part. This as well may generate unwanted results. I suggest to either omit the timer, or to use the following construct:
Code:
on *:INPUT:*:{
  if ($1 == !cb) { .timermsg 1 1 msg $safe($chan $read(orders.txt,n)) }
}

alias -l safe { bset -ct &a 1 $1 | return $!regsubex(safe, $bvar(&a,1-) ,/(\d+)(?: |$)/g,$chr(\1)) }

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
It seems troublesome having to include the -t and/or -n switch for safety concern, along with the safe alias. What if you use a global variable instead of a text file? Same difference?


Link Copied to Clipboard