• Print

Author Topic: Player Disconnect  (Read 4138 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Player Disconnect
« on: June 12, 2016, 10:47:42 am »
Code: Lua
  1. function playerDisconnected( ply )
  2.  
  3.  
  4.    for k,v in pairs( player.GetAll() ) do
  5.      
  6.       v:PrintMessage( HUD_PRINTTALK, ply:Nick() .. " has disconnected. Their SteamID is: " .. tostring( ply:SteamID() ) "." )
  7.  
  8.  
  9.    end
  10.        
  11. end
  12. hook.Add( "PlayerDisconnected", "leaveNotif", playerDisconnected )


I have a very simple code that's supposed to send a message to everyone when someone leaves, and giving their steamID. Right now, when someone leaves, I'm getting this in the server console:
 
Code: [Select]
Lua Error: [ERROR] addons/chatnotifications/lua/ulib/modules/player_disconnected.lua:5: attempt to call a string value
  1. fn - addons/chatnotifications/lua/ulib/modules/player_disconnected.lua:5
    2. unknown - addons/ulib/lua/ulib/shared/hook.lua:110

So I figured it had to do with the SteamID() part, so when I removed that it worked fine (said "name" has disconnected.) but then I put the ply:SteamID() back in and it didn't work. So I tried doing tostring( ply:SteamID() ) but that doesn't work either.. what do I do?
« Last Edit: June 12, 2016, 10:52:24 am by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Player Disconnect
« Reply #1 on: June 12, 2016, 11:49:00 am »
Make sure you're concatenating all the pieces that make up your string on line 6.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Player Disconnect
« Reply #2 on: June 12, 2016, 11:53:15 am »
Oh... duh... thanks lol
« Last Edit: June 12, 2016, 12:00:16 pm by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

  • Print