BUT if bot disconnects, it dont gives points again before the user disconnect and connect again.
Can some help me with fixing this ?
That's because they are online timers, meaning that they are turned off when you disconnect.
Change timer to an offline timer by adding the -o switch.
on !*:join:#:{
$+(.timerpoints.,#,.,$nick) -o 0 600 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}
This means though that the timers of any users who quit/part before the bot re-joins will not be stopped.
Adding this should fix that
raw 366:*:{
var %i = 1
while ($timer(%i)) {
if ($+(points.,$2,.,*) iswm $v1) {
var %a = $v2
if ($gettok(%a,-1,46) !ison $2) { .timer $+ %a off | continue }
}
inc %i
}
}
If some one wants to help me bit more.
If people use the command "!ticket 20" it should take 20 points from the points.ini file, and put it in a raffle.
Try this, note that the trigger is
!ticket (not "!ticket 20")
on *:text:!ticket:#:{
if ($hget($+(tickets.,#),$nick)) { msg # $nick You already have a ticket! | return }
var %topic = $+(#,..$nick)
; Check if enough points
if ($readini(Points.ini,%topic,Points) >= 20) {
; Deduct the points
var %a = $v1 - 20
writeini Points.ini %topic Points %a
; Add the user to tickets.#channel hash table, creating the table if it doesn't exist
hinc -m $+(tickets.,#) $nick
msg # $nick You bought a ticket, you now have %a points.
}
else msg # $nick Sorry, you only have $v1 points.
}
when i (moderator) say "!ticket roll" it will pick a random user and post the winner.
You need to change the ($nick == Yournick) below.
on *:text:!ticket roll:#:{
if ($nick == Yournick) {
if ($hget($+(tickets.,#))) {
var %i = $r(1,$hget(,0).item
msg # The winner is $hget($+(tickets.,#),%i).item
; The next line frees the table (all data in it is gone)
hfree $+(tickets.,#)
}
else msg # Sorry $nick there is no such table $+(tickets.,#)
}
else msg # $nick Only Mods can use that command.
}
An ini file might not be the best way to store this data. There is a lot of file reading/writing going on here.
What other data gets kept in the ini file besides points?