So, you are looking for an esp hack? (esp = know where all players are at all times usually with boxes around them)...
If that is what you seek, there is no need to code one yourself (other than the fun of doing so if thats your thing) because there are quite a few available here.
Here is a link to the one I use - (bottom)
It is pretty safe to use, BUT there is gonna be an update soon (I am guessing since they are putting out there map pack in a couple days) and you should pay very close attention to the version that displays when you connect to the game because when they update you will get banned if you use the old ones.
Credits: I DID NOT MAKE THIS HACK... however I cant find the post where I got it from, and theres no credits with the file... sorry but here you go threadstarter, hope this helps
*note: you need an injector (I use winject, just google it), and all you do is start MW2 > then run winject > then select iw4.mp from the list > and select the dll from the .rar i linked and hit enject.