This Script will Ping a User when they type !ping, and shall post the lag time in the channel. It will do the same with !version.
This also includes flood protection, to stop it from sending loads of CTCP Requests. It will tell the user how long they have to wait until the script is usable again.
; CTCP PING and Version Script
; Made By Jordan Cook (Jordan)
; Support on #Jordan irc.infinityirc.com
set %commandprefix ! ;Change the ! to anything you want. The command will start with this
on *:text:$(%commandprefix $+ ping):#: {
set %lastping $calc($ctime - %ping.lastping)
if ( %lastping >= 10 ) {
set %ping.lastping $ctime
set %pngchan $chan
set %ping.start $ticks
ctcp $nick ping
halt
} else {
notice $nick From $chan $+ : Please wait $calc(10 - %lastping) seconds
}
}
on *:ctcpreply:ping*: {
set %ping.ticks $calc($ticks - %ping.start)
msg %pngchan $nick $+ 's Ping Response Time is $calc(%ping.ticks / 1000) seconds
halt
}
on *:text:$(%commandprefix $+ version):#: {
set %lastversion $calc($ctime - %version.lastversion)
if ( %lastversion >= 10 ) {
set %version.lastversion $ctime
set %verchan $chan
ctcp $nick version
halt
} else {
notice $nick From $chan $+ : Please wait $calc(10 - %lastversion) seconds
}
}
on *:ctcpreply:version*: {
msg %verchan $nick is using: $2-
halt
}
hi
you can combine the two together and no need to use for all /set u can use /var for some variable so u can do it like this if u want
on *:text:*:#:{
if $istok(!ping.!version,$strip($1),46) {
tokenize 32 $strip($1-)
var % $+ $1 $calc($ctime - $+(%,w,$1))
if $($+(%,$1),2) >= 10 {
set $+(%,w,$1) $ctime
set %Wchan #
if ($1 == !ping) set %P.S $ticks
ctcp $nick $iif($1 == !ping,ping,version)
halt
}
else notice $nick From # $+ : Please wait $calc(10 - $+(%,$1)) seconds
}
}
on *:ctcpreply:ping*:{
var %ping.ticks $calc($ticks - %P.S)
msg %Wchan $nick $+ 's Ping Response Time is $calc(%ping.ticks / 1000) seconds
unset %P.S,%Wchan
halt
}
on *:ctcpreply:version*:{
msg %Wchan $nick is using: $2-
halt
}
P.S: the code is not tested