• Making a weapon that freezes the player you're pointing at
    3 replies, posted
How do I get the name of the player that my crosshair is pointing at?
Get the players trace (from eyes to wherever they're looking). If they see a player then display their name. As for the SWEP part: [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8e50.html[/url] In the SWEP:PrimaryAttack() check if what the Holder is looking at is indeed another player. If it is then freeze them, else throw some sort of error message. --Welp you just took the code and ran [B]Edit:[/B] You can figure out the rest easily.
[QUOTE=Aeternal;52132737]Get the players trace (from eyes to wherever they're looking). If they see a player then display their name. As for the SWEP part: [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8e50.html[/url] In the SWEP:PrimaryAttack() check if what the Holder is looking at is indeed another player. If it is then freeze them, else throw some sort of error message. --Welp you just took the code and ran [B]Edit:[/B] You can figure out the rest easily.[/QUOTE] Well not really, I was trying to figure out what each part of it was doing so that I could actually understand what the heck am I doing..
[QUOTE=Crooks_;52132855]Well not really, I was trying to figure out what each part of it was doing so that I could actually understand what the heck am I doing..[/QUOTE] Sorry about that. Anyways, you can get the players name printed on the screen by using badguy:Name(). Thing is you'll have to do this client side AND outside the SWEP.PrimaryAttack function so you can draw it on the players screen all the time instead of only when they fire.
Sorry, you need to Log In to post a reply to this thread.