mIRC Home    About    Download    Register    News    Help

Print Thread
#241967 05/06/13 08:14 PM
Joined: Jun 2013
Posts: 2
S
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Jun 2013
Posts: 2
Hi,

So i have a background in computer programming and i can't seem to figure this out.

What I want to do:
Create a bot that gives every member of a channel 1 point for every minute they are in the channel.

This is what i kinda figured out so far (Syntax and other stuff may be wrong):

/timer 99999999 60 /MyFunction

/MyFunction {
%name = NAMES #channel
For (x = 1 to RFL_LISTEND) {

%Data ( %name (x) ) = %Data ( %name (x) ) +1
Print "User" + %name(x) + "has " + %Data( name(x) ) + " points)

}

Questions:
1. I'm not sure what tab to put all of this into

2. I'm pretty sure my syntax is off.

Any help would be appreciated.

Joined: Aug 2003
Posts: 144
M
Vogon poet
Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
Hi

On the remotes put this code:
Code:
alias GivePoints {
  ;this will set a temporaly variable saying the total users in the channel
  var %UsersInChannel = $nick( $1, 0)
  ;this will set a temp var with the channel name
  var %Channel = $1
  var %x = 1
  ;create a loop that will run a number of times (depending the total users)
  while ( %x <= %UsersInChannel ) {
    ;if the varaible does no exits it means the player has arrive recently
    if ( $var($+( %, Points_, $Channel_, $nick( %Channel, %x))) == 0) {
      ;it will set a local variable with number 1... 1 points because it's the firts time
      set $+( %, Points_, %Channel_, $nick( %Channel, %x)) 1
    }
    ; else... or if the variable exits them it means the user was here last time this command run for this channel
    else {
      ;it will get the value(the points) of that variable user
      var %temp $var( $+( %, Points_, %Channel_, $nick( %Channel, %x)), 1).value
      ;it will sum +1 to the variable of the player
      set $+( %, Points_, %Channel_, $nick( %Channel, %x)) %temp + 1
    }
    ;this is for the while to plus one until reach the total users in channel
    inc %x
  }
}



them the timer you need to run will be
/timer $+ #Channel_Name 0 60 /GivePoints #Channel_Name

Good codes

Last edited by Miguel_A; 05/06/13 09:13 PM.
Joined: Jun 2013
Posts: 2
S
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Jun 2013
Posts: 2
thanks,

just one question

what I write in the middle of the loop to announce the number of points.

so as it goes through the loop it would say:
User: X has Y Points


or can i setup a ! command like: !points to go through and list everyone's points

Last edited by sleepyxtreme; 05/06/13 11:28 PM.
Joined: Aug 2003
Posts: 144
M
Vogon poet
Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
;timer $+ #Channel_Name 0 60 /GivePoints #Channel_Name
Code:
alias GivePoints {
  ;this will set a temporaly variable saying the total users in the channel
  var %UsersInChannel = $nick( $1, 0)
  ;this will set a temp var with the channel name
  var %Channel = $1
  var %x = 1
  ;create a loop that will run a number of times (depending the total users)
  while ( %x <= %UsersInChannel ) {
    ;if the varaible does no exits it means the player has arrive recently
    if ( $var($+( %, Points_, %Channel, _, $nick( %Channel, %x))) == 0) {
      ;it will set a local variable with number 1... 1 points because it's the firts time
      set $+( %, Points_, %Channel, _, $nick( %Channel, %x)) 1
    }
    ; else... or if the variable exits them it means the user was here last time this command run for this channel
    else {
      ;it will get the value(the points) of that variable user
      var %temp $var( $+( %, Points_, %Channel, _, $nick( %Channel, %x)), 1).value
      ;it will sum +1 to the variable of the player
      set $+( %, Points_, %Channel, _, $nick( %Channel, %x)) %temp + 1
    }
    ;This will send a msg to the channel saying "nick NICK with X points"
    ;If you want you can use NOTICE instead or ECHO (to test, and only you will see this)
    msg %Channel nick $nick( %Channel, %x) with $var($+( %, Points_, %Channel, _, $nick( %Channel, %x)),1).value points
    ;this is for the while to plus one until reach the total users in channel
    inc %x
  }
}

Last edited by Miguel_A; 06/06/13 09:06 PM.

Link Copied to Clipboard