Yes , this has already been answered in the forums, please search before asking next time.
The chat_msg_received event is sent whenever we write something in the chat window, to know if it's your own message or a message from someone else, simply do a check on the evpar(user) and check whether it's yourself or not.
if { $user != [::config::getKey login] } {
incr msg_received
} else {
incr msg_sent
}