NEW YORK — In “War Dogs” (opening Friday), Jonah Hill and Miles Teller play South Florida slackers who took advantage of a loophole in the U.S. military’s procurement procedures to snare a $300 million contract from the Pentagon to supply arms to the Afghan army. It’s based on a true story — though heavily dramatized and somewhat fictionalized for cinematic effect — and Teller got a chance to meet his real-life counterpart, David Packouz, during the filming process.

“By the time I met him to talk about the character, I had already been shooting for some time, so I had a pretty good grasp on who he was,” Teller said. “But, for me, it is always interesting to meet the real-life person you’re playing. A lot of the time, if you just listen and really pay attention, they’re going to tell you a lot of things about their life you might not otherwise have picked up on from reading the script, or even reading news accounts about them.”

In the movie, Packouz is actually seen in a cameo, entertaining residents at a nursing home by playing the guitar. Teller is seen attempting to sell high-end bedding linens to the facilities manager — as the real Packouz did to in a failed attempt make some serious cash.

What struck the actor the most was the fact that “for David, a lot of this experience is still ongoing. This thing did not just end with him being convicted and getting his suspended sentence and so forth. There’s a lot of gray area regarding this and how it has continued to affect his life.”

It was completely different for Hill, who did not get the opportunity to meet or talk with the man he’s playing. Efraim Diveroli was not involved in making the film and in fact is involved in litigation with the filmmakers.

On top of that, as explained by the film’s director, Todd Phillips, Diveroli “didn’t want to cooperate with the movie, because apparently he’s kind of writing his own book — doing his own thing. But the movie is told through David’s eyes, so that was OK.”

That said, Hill did admit in a recent joint interview with Teller in a New York hotel suite, “I would have loved to hear his own perspective on this aspect of his life and his experience. I would have enjoyed hearing anything he would have been able to talk about.”

In one particular scene in the film, Hill is seen shooting off an automatic weapon — with apparent glee. The actor revealed that scene actually took quite a bit of acting ability on his part.

“I’m not a big gun person. I frankly did not enjoy that scene. But, I had to pretend to be a person who was really enjoying that. However, I don’t think he was enjoying shooting the guns as much he was enjoying realizing the rounds [of ammunition] worked at that particular moment. He was able to make a deal. He realized he was about to make a lot of money. That was the excitement for him.”

Looking back on the experience of making “War Dogs,” Teller admitted it did make him think a lot about the factors that made this seemingly crazy situation a reality.

“Look, we’re in this election season right now and there’s a lot of fast talking going on. People get into an emotional mood and perhaps are paying more attention to the candidates and the issues and so forth.

“But we absolutely should be paying attention all the time! We need to know about the laws that our representatives are making, the laws they are passing. What these guys did — a lot of it was simply not at all illegal. They really exploited a loophole that was already there. They did the work and took the time to read up on it and see where the boundaries were. They then got into the middle of it all and exploited it.”

Hill nodded in agreement. “America is an amazing country, and I wouldn’t want to live anywhere else. But there’s a lot of absurdity — and to a scary degree — when you see the flaws in our laws and how our government works. I just hope that bringing attention to those flaws will help get them corrected.”

Director Phillips also noted a frightening aspect of “War Dogs” — that two twentysomething guys with no organization behind them were able to con the Pentagon.

“It is a little scary — and that’s an understatement,” said Phillips. “This movie is an indictment of the procurement process. It’s also a bit of an indictment of the Pentagon and how it has a lack of checks and balances, or did have a lack of checks and balances at the time this film takes place.

“So it is eye-opening, making you realize these two slackers from South Florida could figure out a way to scam the system and land a $300 million arms deal.”