How do I call a function when a player connects to my server?
3 replies, posted
On the wiki there is a bunch of functions that start with GM or PLAYER and then a : but I don't get what GM or PLAYER is.
I want to use the GM:PlayerConnect function but if I write something like
function GM:PlayerConnect(name, ip)
print(name .. "is an idiot.")
end
it doesn't work.
Sorry, I'm new to GLua and I feel stupid but I can't find anything helpful about this.
Thanks!
You probably dont want to edit a /Gamemode/ function, hence "GM:", so what you are looking for is creating a hook on that function, as this function already exists in your gamemode (unless you are making your own gamemode from scratch).
Hook Library Usage explains this thoroughly.
There is no issue in your code apart from what confuseth said but it should be running nonetheless. Which file are you putting this code in?
Since youre using print to make the text "Player is an idiot.", im assuming you want to print the Message in the chat, not the console. Cause thats what print does. It only gets visible in the Console. (No player will see that..)
So i suggest using Player/ChatPrint
to print it in the chat.
Otherwise, like i said, it will only be visible in the Console
Sorry, you need to Log In to post a reply to this thread.