If i select points in "empty" space it works. But when i select specific points on objects (with OSNAP) it draws a rectangle without offset of 3, ie. precisely on selected points.
Nothing "wrong" per se, but it's sort of the programming equivalent of "good manners" to null returns from a function, unless you want it to return something. A function returns the last argument it evaluated, which in your code would have been the return of (setvar "osmode" oldosmode), which means, your old osnap setting.
In this case, since it's a command, it doesn't really matter much. When you run the command, you'll probably see a number printed indicating your old OSMODE. Since this number isn't hurting anyone or anything, it's fine for it to be there. If you put that (princ) before the parentheses to close the defun, however, it'll return what (princ) returns instead of what (setvar) returns, that is to say, nil.
Just something to be aware of. It's a good habit to get into. ^^