Very simple lua question here (Please make fun of me)

Alright, so I started trying to teach myself lua the other night with The Garry’s Mod Wiki , and everything was going well, but tonight I attempted to create an addon that when you type in a command, for this example, !SteamID , it will print your steamID in the console.

Anyways, heres the code:

function getSteamID ( ply, text, public, UserID )
if ( string.sub(text, 1, 8) == “!SteamID” ) then
print( ply:SteamID()…" is your SteamID!" )

hook.Add( “print”, “getSteamID”, getSteamID )

Thanks in advance!

You’re trying to use a hook which doesn’t even exist, for a chat command you want to use the hook PlayerSay. Here’s a list of hooks that exist in Garry’s Mod.

An example of how you could do this:

function GetSteamID(ply, text, public)
	newtext = string.lower(text) -- removes case sensitive shit; so a player can type !steamID and it will still work
	if ( string.sub(newtext, 1, 8) == "!steamid" ) then
		ply:ChatPrint("Your SteamID is: " ..ply:SteamID())
		return "" -- removes the !steamid from chat if you want it otherwise just remove this line
hook.Add("PlayerSay", "GetSteamID", GetSteamID) --1st = Actual Hook, 2nd = "Nickname for this hook", 3rd = The function this hook will use

Well, that would explain it. Thanks for the reply.