1: The OP command is there, because you ahd it there. Please refer to previous statments in the post.
2: The array element will be dlated upon unset. That is the whole idea of the unset command.
3: It is my fault you get the error
Code: Select all
if {[info exists $nserv(check)]} { return 0 }
Code: Select all
if {[info exists nserv(check)]} { return 0 }
The unset command takes a variable name, and not it's value.
4: Yes, you are very correct, the catch statment does catch errors, and is precicly what we are trying to catch.
Code: Select all
% set a "hello to all"
hello to all
% set a
hello to all
% unset a
% set a
can't read "a": no such variable
% unset a
can't unset "a": no such variable
You can drop the catch part, as an error should never occur (once the variable is set, there is no way to trigger the timer again, thus, no way to double unset (which causes the error)).
5:
I would however, sugest the following change to the script, to make it a little more less issue prone.
Replace the flood protection IF with this.
Code: Select all
if {[info exists nserv(check)]} {
if {($nserv(check) + 60) > [unixtime]} { return 0 }
}
Code: Select all
set nserv(check) [unixtime]