Poll

Was any of these somewhat interesting or "cool"?

Yes, thank you :)
262 (96.7%)
No, do better next time :(
9 (3.3%)

Total Members Voted: 270

Author Topic: Player Connect/Disconnect Message [1.11v]  (Read 133372 times)

0 Members and 4 Guests are viewing this topic.

Offline cynel

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Player Connect/Disconnect message
« Reply #45 on: October 22, 2013, 10:38:44 AM »

I'm sorry, I'm not able to help you out here. I've become busy with a IRL situation, and some major other issues. Though, you're in a great community, so someone may be able to help you out here.

Ah, no problem! I'll just keep trying  :)

Offline npd1124

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Player Connect/Disconnect message
« Reply #46 on: November 11, 2013, 06:33:19 AM »
for some reason the disconnect message works but it doesnt display the message when someone join the server that is the most important part of it

Code: [Select]
// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
local nickteamcolour1 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined in the server." )
--surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
--surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Connect/Disconnect message
« Reply #47 on: November 11, 2013, 07:55:10 AM »
for some reason the disconnect message works but it doesnt display the message when someone join the server that is the most important part of it

Code: [Select]
// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
local nickteamcolour1 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined in the server." )
--surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
--surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)

Can you please post the server side script too?
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline npd1124

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Player Connect/Disconnect message
« Reply #48 on: November 11, 2013, 08:13:26 AM »
Can you please post the server side script too?

here is the server code

Code: [Select]
// server side apple
AddCSLuaFile( "cl_player.lua"  )

//Spawn
function FirstSpawn( ply )
timer.Create( "server_spawn_timer_wait", 3, 1, function()
colour1 = ply:Team()
spawn1 = ply:Nick()
umsg.Start( "player_spawn")
umsg.String(spawn1)
umsg.Short(colour1)
umsg.End()
Msg("Player " .. spawn1 .. " has joined the server.\n")
end)
end
 
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )

 
//Disconnect
function PlayerDisconnect( ply )
colour3 = ply:Team()
spawn3 = ply:Nick()
umsg.Start( "player_disconnect")
umsg.String(spawn3)
umsg.Short(colour3)
umsg.End()
Msg("Player " .. spawn3 .. " has left the server.\n")
end
 
hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect )

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Connect/Disconnect message
« Reply #49 on: November 15, 2013, 01:43:59 AM »
here is the server code

Code: [Select]
// server side apple
AddCSLuaFile( "cl_player.lua"  )

//Spawn
function FirstSpawn( ply )
timer.Create( "server_spawn_timer_wait", 3, 1, function()
colour1 = ply:Team()
spawn1 = ply:Nick()
umsg.Start( "player_spawn")
umsg.String(spawn1)
umsg.Short(colour1)
umsg.End()
Msg("Player " .. spawn1 .. " has joined the server.\n")
end)
end
 
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )

 
//Disconnect
function PlayerDisconnect( ply )
colour3 = ply:Team()
spawn3 = ply:Nick()
umsg.Start( "player_disconnect")
umsg.String(spawn3)
umsg.Short(colour3)
umsg.End()
Msg("Player " .. spawn3 .. " has left the server.\n")
end
 
hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect )

Not sure mate. I'd try the original version, and see if it works for you, and debug from there.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline PinkieHoofBump

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: Player Connect/Disconnect message
« Reply #50 on: November 15, 2013, 06:58:26 AM »
Is it possible to add the country when a player joins the server? like:  "PinkieHoofBump has entered the game from The Netherlands."?
That would be great!

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Player Connect/Disconnect message
« Reply #51 on: November 15, 2013, 07:19:20 AM »
Is it possible to add the country when a player joins the server? like:  "PinkieHoofBump has entered the game from The Netherlands."?
That would be great!
That would require you to fetch the IP using something like Player.IPAddress then check that IP with some sort of GeoLocation database. I'm not sure how you would do that though.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Pizhik

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: Player Connect/Disconnect message
« Reply #52 on: November 17, 2013, 06:00:45 AM »
Can you modify the code so that it was written in a chat message when connected player, not first spawned?

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Connect/Disconnect message
« Reply #53 on: November 17, 2013, 08:14:11 AM »
Can you modify the code so that it was written in a chat message when connected player, not first spawned?

This has been brought up before. Though colors do not work, which is a major reason why I made this addon.

You can do this yourself though by changing:
sv_player.lua
Code: [Select]
// server side apple
AddCSLuaFile( "cl_player.lua"  )

//Spawn
function FirstSpawn( ply )
spawn1 = ply:Nick()
umsg.Start( "player_spawn")
umsg.String(spawn1)
umsg.End()
Msg("Player " .. spawn1 .. " has joined the server.\n")
end
 
hook.Add( "PlayerConnected", "playerInitialSpawn", FirstSpawn )

 
//Disconnect
function PlayerDisconnect( ply )
colour3 = ply:Team()
spawn3 = ply:Nick()
umsg.Start( "player_disconnect")
umsg.String(spawn3)
umsg.Short(colour3)
umsg.End()
Msg("Player " .. spawn3 .. " has left the server.\n")
end
 
hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect )


cl_player.lua
Code: [Select]
// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
chat.AddText( Color( 255, 0, 255 ), "[Server] ", name1, Color( 255, 255, 255 ), " has joined in the server." )
surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
chat.AddText( Color( 255, 0, 255 ), "[Server] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)


That should work, though I didn't test it.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Player Connect/Disconnect message
« Reply #54 on: November 17, 2013, 08:15:46 AM »
REMINDER:
I have updated this recently, and I forgot to tell you guys about it. So when you all have time for those who have this addon, check it out and download this new version, k-thanks-bye!
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Player Connect/Disconnect message
« Reply #55 on: December 13, 2013, 02:25:34 PM »
Tetra posted some questions about some code - To keep only Chaos's code discussion in this thread, I moved/split the topics to here ->
http://forums.ulyssesmod.net/index.php/topic,6818.0.html
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline HipsterWizard

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: Player Connect/Disconnect message
« Reply #56 on: December 15, 2013, 01:57:53 PM »
Sorry but im really new to lua coding, where would I place this file for it to work in the garrysmod folder?

Offline JakeGriffin

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Player Connect/Disconnect message
« Reply #57 on: December 30, 2013, 09:07:13 AM »
Sorry for the bump here, but could you tell me how I would go about making it so it replaces disconnect with "was kicked" or "was banned"?

I already have a script that shows join and disconnect messages, but I'm not 100% sure how to add disconnect reason (ie kicked or banned)

Thanks!

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Player Connect/Disconnect message
« Reply #58 on: December 30, 2013, 01:30:07 PM »
Sorry for the bump here, but could you tell me how I would go about making it so it replaces disconnect with "was kicked" or "was banned"?

I already have a script that shows join and disconnect messages, but I'm not 100% sure how to add disconnect reason (ie kicked or banned)

Thanks!
That's what the log echo is for.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Player Connect/Disconnect message
« Reply #59 on: December 30, 2013, 01:39:48 PM »
Sorry for the bump here, but could you tell me how I would go about making it so it replaces disconnect with "was kicked" or "was banned"?

I already have a script that shows join and disconnect messages, but I'm not 100% sure how to add disconnect reason (ie kicked or banned)

Thanks!

When you kick or ban someone, ULX will print out that they've been kicked/banned in chat.

Unless you meant how they left, as in client crash, client disconnect, timeout, etc.
Out of the Garry's Mod business.