Valdez is under guard at a nearby hospital, and it would all be another ugly crime story, except for this: Police say Valdez, 36, updated his Facebook status all through the confrontation -- and friends replied with encouragement and, in at least one case, help.

"I'm currently in a stand off wit these shady [expletives] from old, kinda ugly but ready for whatever," Valdez wrote in his first post at 11:23 p.m. Friday. "I love u guyz and if I don't make it out of here alive that I'm in a better place and u were all great friends...."

Another person replied, "jason be strong , you have family here for you. We love u!"

Valdez had a long criminal record, according to court records reviewed by The Associated Press, including convictions for aggravated assault and domestic violence in front of a child.

Police were trying to serve Valdez with a felony drug warrant Friday, when he barricaded himself in a room at the Western Colony Inn in Ogden, blocking the door and windows with furniture. He said on Facebook there was a woman with him named Veronica. At 2:04 a.m. he posted two pictures of himself with a young woman, apparently taken in the motel room.

Police during the Ogden standoff

"He had a smartphone with him and he was making updates," said Ogden Police Lt. Danielle Croyle, the watch commander. "The officers on the scene were aware of it and they changed tactics accordingly."

There was at least one post to Valdez from someone else, saying there was a SWAT team member hiding close to the room.

"Gun ner in the bushes stay low," said the post.

"Thank you homie," Valdez replied. "Good looking out."

"It does cause concern because there were bystanders who knew him," Croyle said. "Our priority is the safety of the community, and safety is compromised when the location of officers is revealed."

Police said they tried to negotiate with the gunman, but he missed several deadlines they set. At 3:30 a.m., he sent this post: "They shut down all power and our phones are dying but I'm keep letting u all know I'm okay til these foolz make some dumb [expletive] move! Told em ill come out WHEN IM READY!!!!"

People who knew Valdez, contacted by ABC affiliate KTVX, came to his defense: "That dude is a good dude, and he'll do anything for anybody, and he's helped me a lot," said Amanda Hines, who called herself a friend.

"I tried to talk to him," said Manuel Navarro, who said he was a cousin. "You have family, we don't' need you to go out like that."

Valdez's last post was at 7:25 a.m. Saturday: "Well i was lettin this girl go but these dumb bastards made an attempt to come in after i told them not to, so i popped off a couple more shots and now were startin all over again it seems...."

An hour later, police said, they broke through the wall to arrest Valdez, but he shot himself before they could get to him. They said he is recovering from the gunshot wound, though they have not been given a prognosis. Police said officers on the scene never fired their weapons.

Charges are pending; Croyle said they could include kidnapping and attempted homicide. She said his Facebook friends could also face charges for trying to help him.

"Facebook can be a help, but it can also be a hindrance," Lt. Croyle said. "We just rolled with it."

Additional information from The Associated Press and ABC Salt Lake City station KTVX.