mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2006
Posts: 87
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
So this is my first script that I'm actually working on. I will explain everything.

So I am trying to make a points system for my chat where people earn points for doing different things. Right now, I am in the process of manually adding points to different users. Here's what I have so far:

Code:
on *:text:*!give*:#: { 
  if ($1 == %c $+ !give) { 
    .inc %$2 $3 | msg $chan $2 was given $3 points
  }
}

on *:text:*!take*:#: { 
  if ($1 == %c $+ !take) { 
    .dec %$2 $3 | msg $chan $3 points was taken away from $2
  }
}


The !give command gives a user points.
Example:
[23:05:03] <@Sableye> !give Haseo 30
[23:05:04] <@[PN]Bot> Haseo was given 30 points

The !take command does the opposite. It takes points from a user.
Example:
[23:57:15] <@Sableye> !take Abhishek 4
[23:57:16] <@[PN]Bot> 4 points was taken away from Abhishek

A few things that I need help with. How can I get it so that only ops can use the commands? How can I make it so that a user can find out the total amount of points that he/she has? Lastly, am I even on the right track? :tongue:

Last edited by Sableye2; 30/06/06 05:02 AM.
Joined: Apr 2006
Posts: 400
K
Fjord artisan
Offline
Fjord artisan
K
Joined: Apr 2006
Posts: 400
use, if ($nick isop $chan) and try setting $3 to a variable.


-Kurdish_Assass1n
Joined: May 2006
Posts: 87
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
How do I set $3 to a variable? Sorry but I'm new at this.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
 set %var $3 


I'll do some more work based on your original request and the replies that you've gotten, when I get home from work.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Your code wont work %$2 is not the nick passed as a var like %nickpassed it is a var called "%$2", to load the var use $+(%,$2) this connects the parts with $2 being its contents.
to access it u need to add $( ,2) around it, this is to tell mirc to evaluate it twice, first time to connect the parts, second time to get the contnets $($+(%,$2),2)

Code:
on @*:text:*!give*:#: { 
  if ($1 == %c $+ !give) { 
    .inc $+(%,$2) $3 | msg $chan $2 was given $3 points, total is now $($+(%,$2),2)
  }
}
on @*:text:*!take*:#: { 
  if ($1 == %c $+ !take) { 
    .dec $+(%,$2) $3 | msg $chan $3 points was taken away from $2, total is now $($+(%,$2),2)
  }
}
on *:text:*!amount*:#: { 
  if ($1 == %c $+ !amount) { 
    msg $chan $nick you have $iif( $($+(%,$nick),2) , $v1,0) points
  }
}

Joined: May 2006
Posts: 87
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
The code that DaveC provided works. The only thing is that I would like only ops to use the commands !give and !take, but not !amount. Here is what I have so far:

Code:
on @*:text:*!give*:#: {
  if ($nick isop $chan)
  if ($1 == %c $+ !give) {
    .inc $+(%,$2) $3 | msg $chan $2 was given $3 points, total is now $($+(%,$2),2)
  }
}


So when I added that in, the script stopped working. Any ideas of what I am doing wrong?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You need another set of braces for the if statement
Code:
on *:text:*!give*:#:{
if ($nick isop $chan) &amp;&amp; ($1 == %c $+ !give) {
.inc $+(%,$2) $3 
 msg $chan $2 was given $3 points, total is now $($+(%,$2),2) 
}
 }


or
Code:
 on *:text:*!give*:#:{
if ($nick isop $chan) {
if ($1 == %c $+ !give) {
.inc $+(%,$2) $3 
 msg $chan $2 was given $3 points, total is now $($+(%,$2),2) 
}
}
 } 


Realistically the two codes above are the same.

Joined: May 2006
Posts: 87
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
Thanks RusselB and everyone, you've all been a great help.

Okay, I have a second thing that I need help with. I would like it so that when a user types in !start, they get 100 points automatically. However, I only would like to have !start work on a user once.

For example:
<George> !start
<%[PN]Points> 100 points have been given to George
<George> !start
<%Points> Sorry, but you already earned your 100 points

Code:
on *:text:*!start*:#: {
  if ($1 == %c $+ !start) {
    .inc 
  }
}


I wasn't sure of what to add for the 3rd line. I didn't know if this would be an .inc command or not.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
No, it should be an if statement. The /inc command will increment (increase) the value of a variable by a given amount (or one if no amount is supplied).

You need to compare the value of the person's account (which I'm going to presume is being stored in a variable) with the value of 100.

If the value of the variable equals 100 then send the Sorry message.

I know this isn't coded, but it looks like you want to try to code this on your own, so I've just explained what it is you need to do, without actually showing the code.

Joined: May 2006
Posts: 87
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
Code:
on *:text:*!start*:#: {
  if ($1 == %c $+ !start) {
  .compare $+(%,$2) 100 }
  else {
    if ($2 == 100) | msg $chan Sorry, but you already have 100 points
  }
}


Pretty messy right now. I don't think the .compare thing is right or the %.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
The only thing is that I would like only ops to use the commands


Doh! I wasnt thinking overly hard, and i made it so it only worked if the bot was an op, but from anyone who triggered it. Sorry.

/me shucks my feet, and walks off wondering where i parked the car.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
on *:text:*!start*:#: {
  if (($1 == %c $+ !start) &amp;&amp; (!$var($+(%,$nick),1))) {
    set $+(%,$nick) 100 | msg $chan $nick starts with 100 points.
  }
  else {
    msg $chan Sorry, but you already had your 100 points.
  }
}

$var($+(%,$nick),1) breaks down like this $+(%,$nick) = the var name of the variable holding the nicks amount, $var( ,1) this then tests if that variable exists (even if its value is zero) or $null, if it exists its true, if it doesnt exist its false (it actually returns the variable name which makes it true, but if it dont exist then it returns a $null which is the same as false for a IF)
The ! at the front reverses the condition, since we want to go in only if its false (no varable %nick exists)


Now you could be meaner and use this
Code:
on *:text:*!start*:#: {
  if (($1 == %c $+ !start) &amp;&amp; (!$var($+(%,$nick),1))) {
    set $+(%,$nick) 100 | msg $chan $nick starts with 100 points.
  }
  elseif ($calc(1 * $($+(%,$nick),2)) isnum 101-) {
    set $+(%,$nick) 100 | msg $chan Since you insisted $nick $+ , your score has been reset to 100 when it was $v1
  }
  else {
    msg $chan Sorry, but you already had your 100 points.
  }
}

Same thing, but if u do a !start and u got over 100 points it resets ya to 100

Joined: May 2006
Posts: 87
S
Babel fish
OP Offline
Babel fish
S
Joined: May 2006
Posts: 87
Thank you. Now I've just encountered a problem with the !amount script. When I type in !amount, this is what I get:

[16:50:56] <@Sableye> !total
[16:50:56] -[PN]Points:#pn-fun- Sableye you have points

It doesn't say how many points I have. I've tried it with several times and with another account, but I get the same message. Here is the script that I am using. It's the one that DaveC posted a few posts back.

Code:
on *:text:*!amount*:#: {
  if ($1 == %c $+ !amount) {
    notice $chan $nick you have $iif( $($+(%,$nick),2) , $v1,0) points
  }
}

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
That should not have been possable, should there have been no value it well have used 0, please check the script is intack in the bot


Link Copied to Clipboard