• Print

Author Topic: Personal edit of Player Connect/Disconnect message release  (Read 5722 times)

0 Members and 1 Guest are viewing this topic.

Offline Tetra

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Personal edit of Player Connect/Disconnect message release
« on: December 13, 2013, 05:39:05 am »
I tried to modify the plugin to show peoples' SteamIDs when they leave/join, but I can't figure out why this isn't working. Would you mind helping me out? Thanks!

cl_player.lua
Code: Lua
  1. // client side apple
  2.  
  3. // Spawn
  4. function player_spawn( data )
  5. local name1 = data:ReadString()
  6. local nickteamcolour1 = team.GetColor(data:ReadShort())
  7.         chat.AddText( Color( 255, 0, 255 ), "[Server] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined the server. Their SteamID is: " ply:SteamID())
  8. end
  9. usermessage.Hook("player_spawn", player_spawn)
  10.  
  11. // Disconnect
  12. function player_disconnect( data )
  13. local name3 = data:ReadString()
  14. local nickteamcolour3 = team.GetColor(data:ReadShort())
  15.         chat.AddText( Color( 255, 0, 255 ), "[Server] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server. Their SteamID is: " ply:SteamID())
  16. end
  17. usermessage.Hook("player_disconnect", player_disconnect)

sv_player.lua
Code: Lua
  1. // server side apple
  2. AddCSLuaFile( "cl_player.lua"  )
  3.  
  4. //Spawn
  5. function FirstSpawn( ply )
  6.         timer.Simple( 3, function()
  7. colour1 = ply:Team()
  8. spawn1 = ply:Nick()
  9.         umsg.Start( "player_spawn")
  10.         umsg.String(spawn1)
  11.         umsg.Short(colour1)
  12.         umsg.End()
  13. Msg("Player " .. spawn1 .. " has joined the server. Their SteamID is: " ply:SteamID()"\n")
  14. end)
  15. end
  16.  
  17. hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )
  18.  
  19.  
  20. //Disconnect
  21. function PlayerDisconnect( ply )
  22. colour3 = ply:Team()
  23. spawn3 = ply:Nick()
  24.         umsg.Start( "player_disconnect")
  25.         umsg.String(spawn3)
  26.         umsg.Short(colour3)
  27.         umsg.End()
  28. Msg("Player " .. spawn3 .. " has left the server.Their SteamID is: " ply:SteamID()"\n")
  29. end
  30.  
  31. hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect )

Edit: These are the two error messages I get.

Code: Lua
  1. [WolfyBada$$|6|STEAM_0:0:59621196] Lua Error:
  2.  
  3. [ERROR] addons/apple-join_leave_msg/lua/autorun/cl_player.lua:7: ')' expected near 'ply'
  4. 1. unknown - addons/apple-join_leave_msg/lua/autorun/cl_player.lua:0
  5.  
  6.  
  7. [WolfyBada$$|6|STEAM_0:0:59621196] Lua Error:
  8.  
  9. [ERROR] addons/apple-join_leave_msg/lua/autorun/sv_player.lua:13: ')' expected near 'ply'
  10. 1. unknown - addons/apple-join_leave_msg/lua/autorun/sv_player.lua:0
  11.  
« Last Edit: December 13, 2013, 06:14:00 am by Tetra »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Personal edit of Player Connect/Disconnect message release
« Reply #1 on: December 13, 2013, 02:21:43 pm »
Rather than hijacking a release thread with lots of code questions, you should take any questions you have to developers corner.
Splitting topic to keep it clean.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Personal edit of Player Connect/Disconnect message release
« Reply #2 on: December 13, 2013, 02:26:27 pm »
Though you'll have some other issues which I'll let you discover on your own, you're missing concatenation syntax within your string msg.
Missing several ".."
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Tetra

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Personal edit of Player Connect/Disconnect message release
« Reply #3 on: December 13, 2013, 02:29:29 pm »
Though you'll have some other issues which I'll let you discover on your own, you're missing concatenation syntax within your string msg.
Missing several ".."
I can't believe I didn't notice that! I don't actually know Lua so I was just guessing, but it seems obvious now. Is there any chance you could patch it up for me?

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Personal edit of Player Connect/Disconnect message release
« Reply #4 on: December 13, 2013, 04:21:48 pm »
Rather than hijacking a release thread with lots of code questions, you should take any questions you have to developers corner.
Splitting topic to keep it clean.

Personally, I would of rather him just post in the thread, but okay.

-----

All this was not tested, so it it doesn't work (and if it doesn't, I'll feel like a lua failure, because this is really easy..), just tell me.

CLIENT SIDE
Code: Lua
  1. // client side apple
  2.  
  3. // Spawn
  4. function player_spawn( data )
  5. local name = data:ReadString()
  6. local steamid = data:ReadString()
  7. local teamcolour = team.GetColor(data:ReadShort())
  8.         chat.AddText( Color( 255, 0, 255 ), "[Server] ", teamcolour, name, Color( 255, 255, 255 ), " has joined in the server. Their SteamID is: "..steamid )
  9. end
  10. usermessage.Hook("player_spawn", player_spawn)
  11.  
  12. // Disconnect
  13. function player_disconnect( data )
  14. local name = data:ReadString()
  15. local steamid = data:ReadString()
  16. local teamcolour = team.GetColor(data:ReadShort())
  17.         chat.AddText( Color( 255, 0, 255 ), "[Server] ", teamcolour, name, Color( 255, 255, 255 ), " has left the server. Their SteamID is: "..steamid" )
  18. end
  19. usermessage.Hook("player_disconnect", player_disconnect)
  20.  


SERVER SIDE
Code: Lua
  1. // server side apple
  2. AddCSLuaFile( "cl_player.lua"  )
  3.  
  4. //Spawn
  5. function FirstSpawn( ply )
  6.         timer.Simple( 3, function()
  7.         umsg.Start( "player_spawn")
  8.         umsg.String(ply:Nick())
  9.         umsg.String(ply:SteamID())
  10.         umsg.Short(ply:Team())
  11.         umsg.End()
  12. Msg("Player " .. ply:Nick() .. " has joined the server.\n")
  13. end)
  14. end
  15.  
  16. hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )
  17.  
  18.  
  19. //Disconnect
  20. function PlayerDisconnect( ply )
  21.         umsg.Start( "player_disconnect")
  22.         umsg.String(ply:Nick())
  23.         umsg.String(ply:SteamID())
  24.         umsg.Short(ply:Team())
  25.         umsg.End()
  26. Msg("Player " .. ply:Nick() .. " has left the server.\n")
  27. end
  28.  
  29. hook.Add( "PlayerDisconnected", "playerDisconnected", PlayerDisconnect )
  30.  
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

  • Print