Difference between revisions of "Very simple Peak script"

From Scriptwiki
Jump to: navigation, search
 
(links enabled)
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
 
Shows the record when someone types !peak
 
Shows the record when someone types !peak
  
  <nowiki>;Execute the following every time someone (including you) joins a channel
+
  ;Execute the following every time someone (including you) joins a channel
on *:join:#: {
+
[[on_join|on *:join]]:#: {
;If the variable (%peak.#channel) where we save user peak doesn't already exist, set it to 0
+
  ;If the variable (%peak.#channel) where we save user peak doesn't already exist, set it to 0
if (!%peak. [ $+ [ $chan ] ]) {
+
  [[If-Then-Else|if]] (!%peak. [ $+ [ $chan ] ]) {
  set %peak. $+ $chan 0
+
    [[set]] %peak. $+ [[$chan]] 0
 +
  }
 +
  ;If the total amount of users is more than the old value of %peak.#channel, set the variable to the new total amount
 +
  if ([[$nick]]($chan,0) > %peak. [ $+ [ $chan ] ]) {
 +
    set %peak. $+ $chan $ifmatch
 +
  }
 
  }
 
  }
  ;If the total amount of users is more than the old value of %peak.#channel, set the variable to the new total amount
+
if ($nick($chan,0) > %peak. [ $+ [ $chan ] ]) {
+
  set %peak. $+ $chan $ifmatch
+
  ;Make the script do something every time someone says !peak
 +
on *:text:!peak:#: {
 +
  ;This here is to prevent people flooding you out
 +
  ;If a variable called %peakspam.#channel does not exist, continue
 +
  if (!%peakspam. [ $+ [ $chan ] ]) {
 +
    ;Save a variable called %peakspam.#channel for 10 seconds
 +
    set -u10 %peakspam. $+ $chan 1
 +
    ;Send a message to the channel telling people what the user record is
 +
    [[msg]] $chan User peak for $chan is: %peak. [ $+ [ $chan ] ]
 +
  }
 
  }
 
  }
}
+
 +
;Please note:
 +
;If you join a channel and someone says !peak before another person has joined, it will [[return]] "1"
 +
;This is due to [[mIRC]] not knowing the total number of users when joining a new channel
 +
;It could be fixed pretty easily, but as this is supposed to be a 'very simple' script.. :)
  
 +
== See Also ==
 +
* [[Evaluation brackets]] are used for evaluating identifiers.
  
;Make the script do something every time someone says !peak
+
[[Category:Script Archive]]
on *:text:!peak:#: {
 
;This here is to prevent people flooding you out
 
;If a variable called %peakspam.#channel does not exist, continue
 
if (!%peakspam. [ $+ [ $chan ] ]) {
 
  ;Save a variable called %peakspam.#channel for 10 seconds
 
  set -u10 %peakspam. $+ $chan 1
 
  ;Send a message to the channel telling people what the user record is
 
  msg $chan User peak for $chan is: %peak. [ $+ [ $chan ] ]
 
}
 
}
 
 
 
;Please note:
 
;If you join a channel and someone says !peak before another person has joined, it will return "1"
 
;This is due to mIRC not knowing the total number of users when joining a new channel
 
;It could be fixed pretty easily, but as this is supposed to be a 'very simple' script.. :)</nowiki>
 

Latest revision as of 11:49, 2 September 2005

A script that remembers the user record of channels. Shows the record when someone types !peak

;Execute the following every time someone (including you) joins a channel
on *:join:#: {
 ;If the variable (%peak.#channel) where we save user peak doesn't already exist, set it to 0
 if (!%peak. [ $+ [ $chan ] ]) {
   set %peak. $+ $chan 0
 }
 ;If the total amount of users is more than the old value of %peak.#channel, set the variable to the new total amount
 if ($nick($chan,0) > %peak. [ $+ [ $chan ] ]) {
   set %peak. $+ $chan $ifmatch
 }
}


;Make the script do something every time someone says !peak
on *:text:!peak:#: {
 ;This here is to prevent people flooding you out
 ;If a variable called %peakspam.#channel does not exist, continue
 if (!%peakspam. [ $+ [ $chan ] ]) {
   ;Save a variable called %peakspam.#channel for 10 seconds
   set -u10 %peakspam. $+ $chan 1
   ;Send a message to the channel telling people what the user record is
   msg $chan User peak for $chan is: %peak. [ $+ [ $chan ] ]
 }
}

;Please note:
;If you join a channel and someone says !peak before another person has joined, it will return "1"
;This is due to mIRC not knowing the total number of users when joining a new channel
;It could be fixed pretty easily, but as this is supposed to be a 'very simple' script.. :)

See Also