First thing to look at would be serve and return. Use the serve to set up a situation where you can keep them behind the baseline. Same idea goes for the return, but is much trickier depending on the relative levels of serve and return. At 4.0, it shouldn't be too much of an issue. At that level, serves and returns should be about equal in terms of relative power. At 4.5+, you start seeing serves that are consistently able to set up points in favor of the server, as well as players that will actually use that advantage. So long as you can keep them at the baseline, the goal should always be depth. Nothing else matters, not spin, or height, or pace, or even how close it is to the sidelines (the last one matters, but matters less). Ideally, you aim for depth with good spin and good height around 3 feet from the sideline of your choice.
As for what happens if they get to the net, sliced lob, drop shot, side-topspin forehand, and whatever you can manage on the backhand with control (not pace). Sliced lob works decently well if you have the feel for it. Federer has used it plenty of times with good success. The drop shot is counterintuitive. Why drop shot someone already at net? Well if you can get them to volley a soft ball below the net, they have to hit up and generate their own pace. The result means you either get an easier ball to hit compared to normal, or they incur additional risk to maintain the same quality of shot (either is at least in some way good for you). Keep in mind though, that this makes it easier for them to hit a drop shot. Realistically, if you know you executed this shot well, their 2 options will be a drop shot or a ball that will travel above the height of the net. As a result, your best move is to actually run up. If it's a drop shot, you're in position to easily get it and have time to control it, meaning it becomes a battle of touch and decision-making. If it's a deep volley, you can catch it while it's above the height of the net and hit a volley down at their feet or hit a drive volley. There are times where (if they are good enough, or are good and get lucky) that they hit a really good volley off this shot and it doesn't spend much time above the height of the net. At this point you have to improvise. I've gone with the low drive volley option with decent success before, but don't recommend it (it's very low percentage). You can try to hit your own good volley and go into a volley battle or try to hit a lob volley off a lot ball. Usually this situation happens far fewer than the other two, so it's not a bad gamble to take. At the very least you should try it out for a few points and see if the percentages are good enough to commit to long term.
The side top forehand I think was discussed earlier in this thread. Basically you swing up and across the back of the ball. You actually need "proper" mechanics to get the racket head speed to make this work well though. Meaning you need to be swinging inside out on groundstrokes rather than linearly. There are videos on youtube about it. Basically the hand comes from behind your hip, relative to the net (basically your hand and hip making a line perpendicular to the net) and you swing out to the contact point, which will be about 2-3 feet to the side from where your hip is on contact (and maybe 1-2 feet in front). A more linear swing will make it difficult to do this and overall gives less racket head speed than an inside out swing, just due to the sheer difference in racket lag between the two techniques. Messing with the ratios of spin and pace, you can get the ball to dip down on them, forcing them to at least volley up or not hit as many putaway volleys. Really good volleyers will basically be able trade with you from this position for a long time, so you should look to stretch them with this shot or try to thread it into the open court.
As for the backhand, it comes down to whatever you can do with it that doesn't rely on blindly hitting it hard. Thread it to the open court with pure control (not so much pace), dip it low on them (again, a soft ball, with or without topspin, depending on what you can do with the shot), or try to combine both options. As a one hander, this is a lot easier. Our strike zones are on low balls, and we can rip those pretty hard while also hitting with a bunch of spin. Sidespin slice isn't the way to go. Side-top on backhands is possible, but a bit awkward unless it's a high ball. It's very niche and not remotely necessary, since doing it detracts from some potential racket head speed you can get, meaning you can hit a similar quality shot more consistently by ignoring it. As for sidespin on slices, it's not great for controlling the ball unless you don't want your crosscourt slice to go wide, since the underspin keeps the ball in the air longer, which allows the sidespin to create more sideways distance during its flight before it lands. All in all, it's nice to toss in as an occasional approach shot or as a changeup in a baseline rally, but not one of my top choices as a passing shot. Placement generally trumps everything in this scenario. People don't really think about this much, but even for "slow balls" the fastest players can't outrun them in the air without a headstart. And if the ball has topspin on it, they aren't outrunning it once it bounces either. So as long as you can dip it to both sides consistently, even if slow, you force them to cover a LOT of court and will force plenty of errors. You just need to be ready for them to hit a good shot if they guess right and hit the shot on balance. Too many people hit a shot, see their opponent's position, and do nothing about it. If you know you hit a good shot, and you see your opponent off balance, you should have an idea of what's coming next and how to position to set yourself up to easily hit the next shot as well as you can. If you know you hit a good shot and you seem them on balance, you should also have a general idea of what the next ball is and where you need to be to defend their best responses (and I don't mean worst case scenario stuff like a flashy winner, I mean the things that will earn them the most points long term). Eventually you get to the point where you can do this the instant you feel contact with the ball (because you will know your opponent's previous state from memory or your peripherals and experience will tell you whether they can get to the ball on balance or not). Even at 5.0 this isn't obvious. You start thinking about it more around 4.5-5.0, since you start understanding/seeing patterns, but you don't naturally react to them all properly and immediately without some practice or being told what to do by a coach (some people do, but they usually have pretty good instincts). But people spend more time on improving mechanics and making sure the fundamentals are working, which is great, but so long as your understanding of the game and your decision-making is solid, at 4.5-5.0, you're already at the mechanical level where you can start thinking about how to play the game optimally from a positional and tactical perspective. A few fractions of a second when moving for each shot is worth more than a few mph or RPMs. Higher level players are at a higher level because they move better, which allows them to hit their better shots more consistently, allowing them to be more consistent with a higher quality of shot.