• Print

Author Topic: Death Notify  (Read 4860 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Death Notify
« on: June 11, 2016, 05:27:54 pm »
I'm trying to make a death notification thing for TTT and right now I have:


Code: Lua
  1. function notifyDeath( victim, inflictor, attacker )
  2.  
  3.  
  4.         if victim == attacker then
  5.  
  6.  
  7.                 victim:PrintMessage( HUD_PRINTTALK, "You killed yourself. Good job." )
  8.  
  9.  
  10.         elseif !attacker:IsPlayer() then
  11.  
  12.  
  13.                 victim:PrintMessage( HUD_PRINTTALK, "You probably fell to your death." )
  14.  
  15.  
  16.         elseif attacker:GetRole() == ROLE_TRAITOR then
  17.  
  18.  
  19.                 ULib.tsayColor( victim, "You were killed by " .. Color( 255, 0, 0 ) .. attacker:Nick() .. Color( 255, 255, 255 ) .. " who was a " .. Color( 255, 0, 0 ) .. "Traitor!" )
  20.  
  21.  
  22.         elseif attacker:getRole() == ROLE_INNOCENT then
  23.  
  24.  
  25.                 ULib.tsayColor( victim, "You were killed by " .. Color( 0, 255, 0 ) .. attacker:Nick() .. Color( 255, 255, 255 ) .. " who was an " .. Color( 0, 255, 0 ) .. "Innocent!" )
  26.  
  27.  
  28.         elseif attacker:getRole() == ROLE_DETECTIVE then
  29.  
  30.  
  31.                 ULib.tsayColor( victim, "You were killed by " .. Color( 0, 0, 255 ) .. attacker:Nick() .. Color( 255, 255, 255 ) .. " who was a " .. Color( 0, 0, 255 ) .. "Detective!" )
  32.  
  33.  
  34.         end
  35.  
  36.  
  37. end
  38. hook.Add( "PlayerDeath", "deathNotif", notifyDeath )


but it's not working... right now I have it in
Code: [Select]
garrysmod/addons/deathnotify/lua/autorun, is this the right place to put it or what? There were no errors in the console (neither client nor server) but I'm getting no message in the chat.


I've only tried killing myself as I didn't have anyone to test it on at the time..
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Death Notify
« Reply #1 on: June 11, 2016, 06:29:19 pm »
While I can't say for certain what your issue is, you'll probably run into this in the future as an issue, so I'll point it out now:
You're concatenating Color values, not providing them in the arguments list that tsayColor expects (see ULib.tsayColor(ply, wait, ...)). Instead of using .. between strings and color values, use ,.
bw81@ulysses-forums ~ % whoami
Homepage

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Death Notify
« Reply #2 on: June 11, 2016, 06:37:51 pm »
While I can't say for certain what your issue is, you'll probably run into this in the future as an issue, so I'll point it out now:
You're concatenating Color values, not providing them in the arguments list that tsayColor expects (see ULib.tsayColor(ply, wait, ...)). Instead of using .. between strings and color values, use ,.

Ooooh, I'll try that out, thanks.




Alright, so I tried that


and again, nothing. So I tried maybe deathnotify/lua/ulx/autorun and put in that same code, again, didn't work. I'm not getting errors, it's just not showing up.



Any idea where I need to put it?
« Last Edit: June 24, 2016, 11:42:52 pm by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Death Notify
« Reply #3 on: June 11, 2016, 08:19:28 pm »
What folder do I put it in?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline dankpepe

  • Jr. Member
  • **
  • Posts: 51
  • Karma: 1
Re: Death Notify
« Reply #4 on: June 11, 2016, 08:59:18 pm »
Try garrysmod/addons/whatever/lua/autorun/server

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Death Notify
« Reply #5 on: June 11, 2016, 10:18:57 pm »
ULib doesn't have an autorun folder, except to start ULib.
Place ulib code in a non ULib folder and you're likely to try to load it before ULib loads, which would cause errors in server and or game console about ULib function not being known.
You'll want /addons/<myaddon>/lua/ulib/modules/
See what_is_this.txt
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Death Notify
« Reply #6 on: June 11, 2016, 10:21:13 pm »
Oh ok, I'll try it tomorrow.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

  • Print