|
Joined: Aug 2013
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Aug 2013
Posts: 6 |
Hi, i'm new to all this scripting, and starting to learn a bit. I have made this script for a Twitch channel, and its works okay. The way it works is when the bot is online and people joins the chan. It gives you points every 10 minutes. BUT if bot disconnects, it dont gives points again before the user disconnect and connect again. Can some help me with fixing this ? the script is here: alias -l addPoints {
if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
var %topic $+($chan,.,$nick)
var %points $calc($readini(Points.ini,%topic,Points) + $1)
writeini -n Points.ini %topic Points %points
return %points
}
alias -l lookUpPoints {
var %topic $+($chan,.,$nick)
var %points $readini(Points.ini,%topic,Points)
return %points
}
alias doaddpoints {
if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
var %topic $+($1,.,$2)
var %points $calc($readini(Points.ini,%topic,Points) + $3)
writeini -n Points.ini %topic Points %points
echo -a Added points for %topic
}
alias dorempoints {
var %topic $+($1,.,$2)
remini -n Points.ini %topic Points
echo -a Removed points for %topic
}
on *:text:!bulls:#:{
if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
set -u5 %floodpoints On
set -u30 %floodpoints. $+ $nick On
msg # $nick has $readini(Points.ini,$+(#,.,$nick),Points) bulls.
}
on $*:text:/!bulls (add|remove)/Si:#:{
if ($nick isop #) {
if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> <user> [number] | return }
writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
{ msg $chan $3 now has $readini(Points.ini,$+(#,.,$3),Points) bulls. }
}
else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
$+(.timerpoints.,#,.,$nick) 0 600 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
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. and when i (moderator) say "!ticket roll" it will pick a random user and post the winner. And ofcause, it will make a message if the user dont have 20 points, and then the person will not be entering the raffle Thank you in advanced
Last edited by Bullerbums; 12/08/13 08:50 PM.
|
|
|
|
Joined: Aug 2013
Posts: 2
Bowl of petunias
|
Bowl of petunias
Joined: Aug 2013
Posts: 2 |
I'm pretty new as well but this might help you out for the time being. All the !checkin command does is have the bot add a timer for everyone in the channel at the time the command is run. This is a rather crude method and I hope someone can provide you with something better. on *:TEXT:!checkin:#: {
if ($nick isop #) {
var %n = $nick(#,0)
var %i = 1
var %nick = $nick(#,%i)
if (%i < %n) {
:doagain
$iif(%nick != $null,goto add,goto end)
:add
$+(.timerpoints.,#,.,%nick) 0 600 add.pts $+(#,.,%nick)
%i = %i + 1
%nick = $nick(#,%i)
goto doagain
:end
return
}
}
} As for the raffle system. I'm still working on something like that. Still learning lol
Last edited by Ergonyx; 13/08/13 01:13 PM.
|
|
|
|
Joined: Oct 2012
Posts: 164
Vogon poet
|
Vogon poet
Joined: Oct 2012
Posts: 164 |
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?
|
|
|
|
Joined: Aug 2013
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Aug 2013
Posts: 6 |
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? This was so nice! Thank you alot Atm i only have Points stored in the ini file. They way i wanted the "!ticket" system to work, was that i says that , you have to pay 20 points now, and 50 points now to be a part of the raffle. ehmm best is to come with an exemple i think  "admin says !ticket 20 (now it will cost 20 points pr tickets" user: !tickets 3 --- user buy 3 tickets = 60 points taken or is it to difficult to make? and again, Thank you so much for the help
|
|
|
|
Joined: Aug 2013
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Aug 2013
Posts: 6 |
After a quick test. on !*:join:#:{
$+(.timerpoints.,#,.,$nick) -o 0 600 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
} Did not change anything. When i disconnect my bot and rejins, it dont start to give out point. - I did try the code with and without the secound part of it.
Last edited by Bullerbums; 14/08/13 07:37 AM.
|
|
|
|
Joined: Oct 2012
Posts: 164
Vogon poet
|
Vogon poet
Joined: Oct 2012
Posts: 164 |
Yeah, my bad, sorry. "var %topic = $+(#,..$nick)" should be "var %topic = $+(#,.,$nick)"
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.
}
|
|
|
|
Joined: Aug 2013
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Aug 2013
Posts: 6 |
Nice thank you  i can now "buy" tickets, but when i do the roll nothing happens. If i enter a vrong nickname it says i'm not a mod, so something is working. But it dont draw a winner 
Last edited by Bullerbums; 14/08/13 07:47 AM.
|
|
|
|
Joined: Aug 2013
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Aug 2013
Posts: 6 |
ok this is were i stand right now. The timer if the bot has disconnect, still dont work. The !ticket is working, but if i do the !ticket roll nothing happens. If i start writing !ticket and it has i got a ticket, there is nothing in the "points.ini" that states that i got a ticket (tickets.bullerbums) this is the onlt thing that stands there: [#bullerbums.bullerbums]
Points=648 Maybe i did mess up something with the code. but i post it again to be sure. on *:TEXT:hello:#: {
if ((%floodhello) || ($($+(%,floodhello.,$nick),2))) { return }
set -u10 %floodhello On
set -u30 %floodhello. $+ $nick On
msg $chan Hello $nick , and welcome to Buller's Stream! $+
}
on *:TEXT:hallo:#: {
if ((%floodhello) || ($($+(%,floodhello.,$nick),2))) { return }
set -u10 %floodhello On
set -u30 %floodhello. $+ $nick On
msg $chan Hello $nick , and welcome to Buller's Stream! $+
}
on *:TEXT:when is the giveaway:#: {
$chan $nick The GiveAway is when Buller says so Dont forget to follow if you want to win!
}
on *:text:!hi:#:{
if ($nick isop #) { msg # Hi there! }
else { msg # Sorry you cannot use this command }
}
alias -l addPoints {
if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
var %topic $+($chan,.,$nick)
var %points $calc($readini(Points.ini,%topic,Points) + $1)
writeini -n Points.ini %topic Points %points
return %points
}
alias -l lookUpPoints {
var %topic $+($chan,.,$nick)
var %points $readini(Points.ini,%topic,Points)
return %points
}
alias doaddpoints {
if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
var %topic $+($1,.,$2)
var %points $calc($readini(Points.ini,%topic,Points) + $3)
writeini -n Points.ini %topic Points %points
echo -a Added points for %topic
}
alias dorempoints {
var %topic $+($1,.,$2)
remini -n Points.ini %topic Points
echo -a Removed points for %topic
}
on *:text:!bulls:#:{
if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
set -u5 %floodpoints On
set -u30 %floodpoints. $+ $nick On
msg # $nick has $readini(Points.ini,$+(#,.,$nick),Points) bulls.
}
on $*:text:/!bulls (add|remove)/Si:#:{
if ($nick isop #) {
if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> <user> [number] | return }
writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
{ msg $chan $3 now has $readini(Points.ini,$+(#,.,$3),Points) bulls. }
}
else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
$+(.timerpoints.,#,.,$nick) -o 0 600 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}
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
}
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}
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.
}
on *:text:!ticket roll:#:{
if ($nick == Bullerbums) {
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.
}
I did some testing and put the timer to 3 sec. and still dont count. (its back to 10 minutes now) I dont know if it makes any diffrent, but i use the "remote.ini" to run my bot
Last edited by Bullerbums; 14/08/13 08:12 AM.
|
|
|
|
Joined: Aug 2013
Posts: 6
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Aug 2013
Posts: 6 |
|
|
|
|
|