So I'm trying to add joining and leaving msgs to my server. (Rather new to lua coding)
I guessed that as it uses "GM:" I would need to code it in the gamemode, was I correct?
Why is this code not working?
[CODE]//Join - Leave msgs
function GM:PlayerConnect ( ply )
for k, ply in pairs( player.GetAll() ) do
ply:ChatPrint( Color(255,100,100) , "[ " .. ply:Nick() .. " has connected to the server! ]" )
end
end
function GM:PlayerDisconnected( ply )
for k, ply in pairs( player.GetAll() ) do
ply:ChatPrint( Color(100,255,100) , "[ " .. ply:Nick() .. " has disconnected from the server! ]" )
end
end[/CODE]
Edit...
You not only didn't call hooks but,
You also have another problem, you're calling ply in for k, ply in pairs(player.GetAll()) at which that will print every player in the chat.
[code]
function PlayerIsConnecting( ply )
for k, all in pairs( player.GetAll() ) do
all:ChatPrint( Color(255,100,100) , "[ " .. ply:Nick() .. " has connected to the server! ]" )
end
end
hook.Add("PlayerConnect", "PlayerConnectinnifasdfjasdfklj", PlayerIsConnecting)
function PlayerIsDisconnected( ply )
for k, all in pairs( player.GetAll() ) do
all:ChatPrint( Color(100,255,100) , "[ " .. ply:Nick() .. " has disconnected from the server! ]" )
end
end
hook.Add("PlayerDisconnected", "PlayerDisconnectnifasdfjasdfklj", PlayerIsDisconnected)
[/code]
Uhm still not working :3
Bump?
You can't use colors in chatprint
You need to network it and use chat.AddText if you want color
To demonstrate the usage of networking and colored chat messages, check this out and place it in your addons folder if you want to use it.
[url]https://www.dropbox.com/sh/bajhivsy3k251ww/AABhtid3Yx5T16V-b_ZWhj06a[/url]
-snip- silly me
Sorry, you need to Log In to post a reply to this thread.