Nimos wrote:*snipped long code*
Nimos, when new users join the channel, after any rehash/restart/etc .. (ones that were not previously in that channel before the rehash) rejoins your channel that script will cause errors for those nicknames.
Code: Select all
foreach chan $fivelines(channels) {
set fivelines(counter|$chan) 0
set fivelines(nick|$chan) ""
}
You use this code to intialize a huge array in global space for some reason. Rather than, using [info exists] command and using this to tell an initialized (aka, empty) array.
You then make this call to your procedure:
Code: Select all
if {$fivelines(nick|$chan) == $nick} {
This will cause an error for any nickname that wasn't present when you previously initialized the array. It should be based around [info exists] imo. Using a series of sets does not work dynamically how you have done it. Just words of advice.
As people chat, you add them to the array, only then do they eat memory. Until then we use [info exist] to tell if each nick is, or is not, already added to our array. If it's not then "set fivelines($nick|$chan) 1". If it is, then [incr] it ever after based on that until we hit the magic number 5.
Also...
Code: Select all
[expr round(rand() * ([llength $fivelines(answers)] - 1))]]
Might want to brace that [expr {}] to speed it up 1000% and to keep any issues with $fivelines variable from containing any exploits or substitution errors... and just do...
Code: Select all
[rand [llength $fivelines(answers)]]
which is same thing as your long code above in proper form without that nasty expr and needless round required because of that -1 you do to llength. Otherwise your code would never use the last element in the $fiveline(answers) list, which it will do rarely, not evenly like your rand suggest it would. In your list of three you can test this yourself, and do 3 queries. Multiple times. So 3 queries 20x. So 60x total. In those, the most ever the last element can appear as the result of those 60. Is 10 times. One sixth. 1/6. Half of what true random would be for 3 items, and making 60 queries. It should be 1/3rd, or 20/60th's. This is because of reasons having to do with your code versus mine and as I said only affects the last element in the list. My code above works correctly showing each of the 3 items 20 times if 60 requests were made and the list was only 3 lines long.