Finding current weapon...

Somehow this code only gives a positive reaction if the current weaon isn’t a SMG.
[lua]
function GM:HUDPaint()

self.BaseClass:HUDPaint()

local person = LocalPlayer()

	if !person:Alive() then return 
	end

local numWeapon = person:GetActiveWeapon( ):GetPrintName()


if string.gmatch(numWeapon, "SMG") then
	print( "Correct!" )
else
	print( "Phail!" )
end

surface.SetTextColor( 255, 255, 255, 255 )
surface.SetFont( "Default" )
surface.SetTextPos( 50, 115 )
surface.DrawText( numWeapon )

end
[/lua]

Even if i use a pistol, it gives me “Correct” in console. What am i doing wrong here? I only want it to give “Correct” if im using a SMG.

Have you tried using the not operator?

You’re using the wrong function. Use ‘string.find’ instead. ‘string.gmatch’ returns a function.

Yes, they all get “Phail” then.

[editline]09:25PM[/editline]

I’ll try it

[editline]09:35PM[/editline]

Thanks! works!

Hi, I am Andres Kramack from http://www.cathybarryadultstore.com/.

It’s a ‘pleasure’ serving the public if you know what I mean and this message is

Here at Cathy Barry Adult Store, we offer a wide variety of dildos that come in all sizes from goblin-sized dicks to black-man draconic dicks. I know at Facepunch everyone loves good old dicks which is why I personally offer anyone with an association with Facepunch Forums a 50% discount code “DIL4FACEPUNCH”. Don’t forget, this offer lasts until the next Garry’s Mod update which we so much love.

Here are pictures of our products just for you!

Sponsored Images:

http://static.fjcdn.com/pictures/Gym+leaders+hate+him_ab471d_5017861.jpg

https://static.fjcdn.com/comments/That+one+with+the+lamp+got+me+_e68beb19422eea14289caa5f4d6dffb7.jpg

Got any questions? Visit my Steam Profile!