Prevent to occur the error "MSG_ONE or MSG_ONE_UNRELIABLE with no target entity"

I'm not sure if I did it in the right way, but I hope it is, otherwise tell me what's wrong.