mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
Loki, I found everything in this thread on this forum. It's just a point code that i've seen just about everyone pass around on here. So I picked it up.


Everything works just fine on my bot except my !points erase code, it erases their whole name from the points.ini file and leave it blank. So when they type !points it tries to read the points.ini and sees it's blank and just says $nick has total points.

I want it to say $nick has 0 total points, so I need to figure out a way to make !points reset change the values to 0 instead of erasing the whole points.ini file.


Code:
on *:text:!points reset:#:{
  if ($nick isop #) {
    { msg $chan All points are now erased }
    write -c points.ini.
  }
  else { msg $chan This command is only available to moderators. }
}


I know the -c points.ini file clears the whole file, I'm just not sure what to add to make it reset everyone to 0 instead of erasing the whole file.


Bramzee, I changed the 600 to 3600 (which should be 3600) seconds, but if I change it while someone is in my channel they still gain the point every 600 seconds and anyone who joins after only gains 1 point an hour.

So do I need to make the bot leave the channel then rejoin if I change anything in the code? or make sure there is nobody in the channel if I change something?

Last edited by Echosyp; 23/05/14 05:31 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Don't set them to 0, read them back as 0 if they don't exist.

Code:
on *:text:!points:#:{
  if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
  set -u10 %floodpoints On
  set -u30 %floodpoints. $+ $nick On
  msg # $nick has $iif($readini(Points.ini,n,$+(#,.,$nick),Points),$v1,0) total points.
}

on *:text:!points reset:#:{
  if ($nick isop #) {
    msg $chan All points are now erased
    write -c points.ini
  }
  else { msg $chan This command is only available to moderators. }
}

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
Ok, appreciate that.

My last question and my bot will be complete for now.


This is my join code, I want ppl to gain 1 point when they join. So new players to the channel can start with at least 1 point. But I don't want them to be able to farm points by joining and leaving and re-joining.

Code:
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 3600 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
}




So I TRIED to do the following code below to remove 1 point when they leave and give them 1 point when they join. To even stuff out, since I don't know how to make it so if non new players join they won't get the 1 point AGAIN. So I copied the fir alias. of

Code:
alias -l add.pts {
  if (%point.off) return
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}


I renamed it to alias -l subtract.pts and did writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) - 1)

hoping the - 1 would remove 1 point when they left.

Code:
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
  subtract.pts $+(#,.,$nick)
}


Above is my when they leave the channel code. I don't understand the alias -l add.pts part of that code, when they join it doesn't have the alias as part of the code, but the leaving part of the code has alias -l add.pts in it.

And you can see at the end of the part code I added my subtract.pts which doesn't work.

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
1. All aliases begin with word "alias" should be put in the remote section, not in aliases.
2. Alias can be put anywhere in the remote. Putting alias beside an event doesnt mean that alias will work for that event. Alias works when you call it in the event regardless where you put the alias in the remote.
Code:
; all lines begin with ";" is a comment.
; alias to substract user point.
alias -l substract.pts {
  yourcode here
}

; when user leaves the channel
on !*:part:#:{
  ; tell bot to turn off timerpoints.
  $+(.timerpoints.,#,.,$nick) off

  ; and then call substract.pts alias to substract their point
  substract.pts $+(#,.,$nick)
}

what you do is:
Code:
; when user leaves channel, tell bot to turn off timer.
on !*:part:#:$+(.timerpoints.,#,.,$nick) off

; this is an alias 
alias -l add.pts {
  ; tell bot to add point and write it to ini file
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)

  ; then call substract.pts alias to do whatever substract.pts want to do in its alias.
  subtract.pts $+(#,.,$nick)
}

; you dont have substract.pts alias in remote, but you calling it in add.pts alias.
; this will result unknown command in your status window

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
It didn't work, below is the two codes.



Code:
alias -l subtract.pts {
  if (%point.off) return
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) - 1)
}





Code:
on !*:part:#:{
  $+(.timerpoints.,#,.,$nick) off
  alias -l add.pts {
    writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
    subtract.pts $+(#,.,$nick)
  }

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
I didnt write code like that.
Please do pay attention.
You dont need to write alias inside your event. You have to CALL IT.
I didnt write alias inside the event, did I?

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
ok, so far this is what I have.

Code:
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 3600 
  add.pts $+(#,.,$nick)
}

on !*:part:#:{
  $+(.timerpoints.,#,.,$nick) off

}


I'm not gaining a point when I join, so I need to see if a new user will gain a point when they join.

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
For learning process, it would be good if you write some comment in your code. If you can translate it correctly with your words, then you learn something.
Code:
; when user join the channel
on !*:join:#:{
  ; tell bot to start timer every 3600secs and do "?" 
  ; please check with your previous code. 
  ; this line is wrong. there is no command or alias after 3600secs timer.
  $+(.timerpoints.,#,.,$nick) 0 3600 

  ; after activate timer, now tell bot to call add.pts alias and do whatever command in add.pts alias
  add.pts $+(#,.,$nick)
}

; when user leaves channel
on !*:part:#:{
  ; tell bot to turn off timer
  $+(.timerpoints.,#,.,$nick) off

}


Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
One last thing, my !points on and !points off command don't work unless I add the alias -l to the part of the code when someone leaves.


on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1) <<<If I don't have this typed in !points on and !points off don't work.
}[/code]

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
Here is my WHOLE bot code. Probably A LOT of errors in there, but here it is.


Code:
alias -l add.pts {
  if (%point.off) return
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}


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:!calc*:#: {
  if ($3 == $null) /msg $chan $nick  $2 = $calc( $2 )
  if ($3 != $null) /msg $chan 7Please dont use the space bar for the !calc7 trigger. Do it like this:  5+5 7for example.
}
on *:TEXT:!c:#: {
  /msg $chan To use this channel calculator, you should know this:
  /msg $chan The Calculator Buttons Are: [+] [-] [^] [*]
  ] [/]
  /msg $chan Here are some examples: 
  /msg $chan 3^2 = 9
  /msg $chan 3*2 = 6
  /msg $chan 3/2 = 1,5
  /msg $chan 3+2 = 5
  /msg $chan 3-2 = 1
}




on *:text:!points:#:{
  if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
  set -u10 %floodpoints On
  set -u30 %floodpoints. $+ $nick On
  msg # $nick has $iif($readini(Points.ini,n,$+(#,.,$nick),Points),$v1,0) total points.
}

on $*:text:/!points (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,n,$+(#,.,$3),Points) total points.
  }
  else { msg $chan This command is only available to the owner of this channel. }
}

on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 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)
}

on *:text:!points reset:#:{
  if ($nick isop #) {
    msg $chan All points are now erased
    write -c points.ini
  }
  else { msg $chan This command is only available to moderators. }
}










on $*:text:/^!points (on|off)/:#:{
  if $nick !isop # { return }
  if $2 == off { 
    set -e %point.off 1 
    msg # Not collecting points anymore.
  }
  if $2 == on { 
    unset %point.off 
    msg # Collecting points now.
  }
}







on *:text:!startuptime:#: {
  msg # Starting uptime.
  set -e %uptime. [ $+ [ # ] ] $ctime
}

on *:text:!uptime:#: { msg # I have been online for $duration($calc($ctime - %uptime. [ $+ [ # ] ] )) }

on *:text:!stopuptime:#: { 
  msg # Stopping uptime.
  unset %uptime. [ $+ [ # ] ] 
}




on *:TEXT:!giveaway enter:#:{
  if (%giveaway == on) {
    if (!$read(giveaway.txt,nw,$nick)) {
      write giveaway.txt $nick
      msg $chan $nick - you have been entered into the giveaway! 
    }
  }
  elseif (%giveaway == off) {
    msg $chan There is no active giveaway
  }
}

on *:TEXT:!giveaway start:#:{
  if ($nick isop #) {
    set -e %giveaway on
    msg $chan giveaway started. please do "!giveaway enter" to enter. To clear all names, please do "!giveaway done" 
  }
  else { msg $chan This command is only available to moderators. }
}


on *:TEXT:!giveaway end:#:{

  set -e %giveaway off
  { msg $chan Giveaway has ended. please do !draw to pick a winner!" }
}
on *:text:!giveaway done:#:{

  -e %giveaway = off
  { msg $chan giveaway is complete. erasing all names from the giveaway }
  write -c giveaway.txt.
}
on *:text:!draw:#:{ 

  if (%giveaway == off) { msg $chan The winner is $read(giveaway.txt) $+ !! If you would like to pick another winner draw again. }
  elseif (%giveaway == on) { msg $chan The giveaway is still on! please do "!giveaway end" }
}




on *:text:!pointcheck *:#:{
  if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return }
  set -u1 %floodcheck On
  set -u5 %floodcheck. $+ $nick On 
  msg # $2 has $readini(Points.ini,$+(#,.,$2),Points) total points. 
}





on *:text:!winner:#:{
  var %nick1 = $nick(#,$rand(1,$nick(#,0)))
  while (%nick1 == $me) { %nick1 = $nick(#,$r(1,$nick(#,0))) }
  msg # Randomly selected winner is %nick1 $+ ! Congratulations %nick1 you win... $eval($+(%,prize.,$network,.,#),2)
}





on *:TEXT:!top10:#:{
  if $nick == robpsychobob { top10 # } 
  else { msg # You are not allowed to use !top10. }
}

alias -l top10 {
  window -h @. | var %i 1
  while $gettok($remove($read(points.ini,w,$+(*,$1,*),%i),[,]),2,46) {
    var %n $v1, %p $gettok($read(points.ini,$calc($readn + 1)),2,61)
    aline @. %n %p
    var %i $calc($readn + 1)
  }
  filter -cetuww 2 32 @. @.
  var %i 1 | while %i <= 10 {
    var %list $addtok(%list,$line(@.,%i),44)
    inc %i
  }
  msg $1 Top 10 point are: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
  window -c @.
}










on *:text:!tickets:#:{
  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) >= 1) {
    ; Deduct the points
    var %a = $v1 - 1
    writeini Points.ini %topic Points %a
    ; Add the user to tickets.#channel hash table, creating the table if it doesn't exist
    hadd -m $+(tickets.,#) $nick 1
    msg # $nick You bought a ticket, you now have %a points.
  }
  else msg # $nick --- Sorry you only have $iif($readini(Points.ini,n,$+(#,.,$nick),Points),$v1,0) total points!
}
on *:text:!ticket roll:#:{
  if ($nick == forgottenheroes) {
    if ($hget($+(tickets.,#))) {
      var %i = $r(1,$hget($+(tickets.,#),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 entries at the moment. 
  }
  else msg # $nick Only Mods can use that command.
}









on $*:text:/^!addcom !?(\S+)/iS:#:{
  if ($nick !isop #) return
  writeini commands.ini commands $regml(1) $$3-
  msg # $nick > The command $2 has been created
}

on $*:text:/^!delcom !?(\S+)/iS:#:{
  if ($nick !isop #) return
  remini commands.ini commands $regml(1)
  msg # $nick > The command $2 has been removed from the database.
}

on $*:text:/^!(\S+)/:#:{
  if ($nick !isop #) return
  if ($readini(commands.ini,n,commands,$regml(1))) msg # $v1
}



I would LOVE for !points on & !points off to burn the bot on and off so he either starts collecting points while I'm streaming or stops collecting points when I quit streaming.

I would LOVE for the bot to be able to add 1 point to new users, but not allow them to quit and re-join to keep farming 1 point over and over.

I would LOVE a raffle to be added to the bot that makes it so the players can spend ever how many points they want and be entered that many times into the raffle. Then when the raffle stops it picks a random winning ticket. Even tho someone bought 100 tickets and someone else only bought 10 I stil want that person who bought 10 to have a chance at winning but a lower chance.

Last edited by Echosyp; 24/05/14 05:18 AM.
Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
Originally Posted By: Echosyp
One last thing, my !points on and !points off command don't work unless I add the alias -l to the part of the code when someone leaves.


on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1) <<<If I don't have this typed in !points on and !points off don't work.
}

That happens because what you provide here doesnt check %point.off. Also i see you have 2 add.pts aliases in your remote. One on the top of the remote, and other what you provide here. You can remove this one.

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
Yea, that's what I was saying. I do have 2 add.pts aliases. That's how the code already was when I found it on here.

But when I remove the alias that was provided in the part of the code you just quoted, the !points on !points off doesn't work. So I had to keep that in for it to work.


Also, someone else said they had to remove part of the code that gives someone 1 point when they join to make their !points on / !points off work.


I believe I'm getting confused on what makes the bot work and what breaks it.

I took a year at University of Phoenix for computer programming and always wanted to learn, but I keep running into roadblocks and stay up for hours and hours wrecking my brain trying to figure out what broke what.

Last edited by Echosyp; 24/05/14 06:25 PM.
Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
I'm 100% sure you dont need 2 same aliases in the remote.
You can remove what i was saying safely.

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
That's weird as hell.

I remove that alias and

Code:
on $*:text:/^!points (on|off)/:#:{
if $nick !isop # { return }
if $2 == off { 
  set -e %point.off 1 
  msg # Not collecting points anymore.
}
if $2 == on { 
  unset %point.off 
  msg # Collecting points now.
}
}


won't work at all. I add the alias back in and it works like a charm.



I discovered, if I move the above code to the very top of the remote tab !points on and !points off work, but if I have that code below the join and part code it no longer works. Any idea?


Figured it out.

I had:

Code:
on !*:part:#:
  $+(.timerpoints.,#,.,$nick) off
}


I changed it to

Code:
on !*:part:#:{ <----- I WAS MISSING THIS!!!!!!!
  $+(.timerpoints.,#,.,$nick) off
}

Last edited by Echosyp; 25/05/14 03:21 PM.
Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
Originally Posted By: Echosyp
I would LOVE for the bot to be able to add 1 point to new users, but not allow them to quit and re-join to keep farming 1 point over and over.

replace this code
Code:
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
}

with this one
Code:
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  if %joinfarm. [ $+ [ $+(#,.,$nick) ] ] { return }
  add.pts $+(#,.,$nick)
  var %s $calc($timer(points.,#,.,$nick).delay / 1000)
  inc $+(-u,%s) %joinfarm. [ $+ [ $+(#,.,$nick) ] ] 
}

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
Appreciate that blessing. I had just wrote it so they lose 1 point when they leave and gain that 1 point back when they join. But I believe them losing that point isn't the best option.

Joined: May 2014
Posts: 27
E
Echosyp Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: May 2014
Posts: 27
Originally Posted By: blessing
Originally Posted By: Echosyp
I would LOVE for the bot to be able to add 1 point to new users, but not allow them to quit and re-join to keep farming 1 point over and over.

replace this code
Code:
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
}

with this one
Code:
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  if %joinfarm. [ $+ [ $+(#,.,$nick) ] ] { return }
  add.pts $+(#,.,$nick)
  var %s $calc($timer(points.,#,.,$nick).delay / 1000)
  inc $+(-u,%s) %joinfarm. [ $+ [ $+(#,.,$nick) ] ] 
}


That's not working blessing, when I start mIRC and connect it says there is to many parameters in var %s $calc($timer(points.,#,.,$nick).delay / 1000)

and they still gain the 1 point when they join.

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
Yeah my bad. it should be:
Code:
var %s $calc($timer($+(points.,#,.,$nick)).delay / 1000)

Joined: Jul 2014
Posts: 8
A
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
A
Joined: Jul 2014
Posts: 8
Hi guys, i don't want to create new topic for it, so i just wanna ask you if u can help me with command. I have really no idea how to set it.

Looking for !reset command . But i don't want to delete all points from points.ini. I just want to let users delete their own points.

They are playing raffle a lot and they have often -40 points etc.

I want let them reset their own points so they will get 0.

I have same point system as others.

Code:
alias -1 addPoints {
  if ($1 !isnum) { echo 2 -st $1 is not 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 -1 lookUpPoints {
  var %topic $+($chan,.,$nick)
  var %points $readini(Points.ini,$topic,Points)
  return %points
}
alias doaddpoints {
  if ($3 !isnum { echo 2 =st $3 neni cislo. Hodnota musi byt cislo. | 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:!points:#: {
  msg # $nick ma prave $readini(Points.ini,$+(#,.,$nick),Points) bodu.
}
 
on $*:text:/!points (add|remove)/Si:#:{
  if  ($nick isop #) {
    if ($0 < 3) { msg # Spatny parametr: prikaz je !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  má práv&#283; $readini(Points.ini,$+(#,.,$3),Points) bodu.
    }
  else {msg $chan Tento prikaz je povolen pouze moderatorum. }
}
 
on !*:join:#:{
  $+(.timer3.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
}
 
on !*:part:#:$+(.timer3.,#,.,$nick) off
alias -l add.pts {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}

Page 2 of 2 1 2

Link Copied to Clipboard