• Print

Author Topic: Custom command to execute damage logs?  (Read 6016 times)

0 Members and 1 Guest are viewing this topic.

Twistedwheelbarrow

  • Guest
Custom command to execute damage logs?
« on: August 16, 2013, 10:32:45 am »
I'm trying to add a command called !dmg that prints the damage logs to the console... It won't work.

function DamageLogs( ply, text, _ )

    if ( string.sub( string.lower( text ), 1, 7 ) == "!dmg" ) then
      ply:ConCommand( "ttt_print_damagelog" )
      return false
    end
   
end
hook.Add( "PlayerSay", "Damagelogs )

Any ideas? :3

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Custom command to execute damage logs?
« Reply #1 on: August 16, 2013, 10:46:21 am »
Although I might be wrong, I believe the hook.Add should be:

Code: Lua
  1. hook.Add("PlayerSay", "Damagelogs", DamageLogs)

That is probably what is messing it up.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Twistedwheelbarrow

  • Guest
Re: Custom command to execute damage logs?
« Reply #2 on: August 16, 2013, 11:33:57 am »
No, that worked fine! Do you have any idea how I would do this with "ttt_print_traitors" but have it only print the traitors and not the innocents?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Custom command to execute damage logs?
« Reply #3 on: August 16, 2013, 12:53:54 pm »
You would have to modify the command "ttt_print_traitors". By default, that prints the roles of everyone (although detectives are still counted as innocents).

Although, I'll try to look into it and see what I can do.

After looking into it, I didn't really understand anything of it (still pretty noob-ish at Lua), but if you want to have a look, the command file is inside <GMod server dir>\gamemodes\terrortown\gamemode\admin.lua.
« Last Edit: August 16, 2013, 12:59:02 pm by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom command to execute damage logs?
« Reply #4 on: August 16, 2013, 02:30:52 pm »
If you guys search from the front forum page for ttt_print_damagelog, you'll probably find any number of the 5 or 6 times that particular command has been discussed.
Though, I'm pretty sure the traitor one hasn't, but might lead you to further ideas.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Custom command to execute damage logs?
« Reply #5 on: August 16, 2013, 04:27:39 pm »
if ( string.sub( string.lower( text ), 1, 7 ) == "!dmg" ) then


That's matching the first 7 characters of text.. and comparing it to !dmg which is only 4.

if ( string.sub( string.lower( text ), 1, 4 ) == "!dmg" ) then
is what it should be.

Twistedwheelbarrow

  • Guest
Re: Custom command to execute damage logs?
« Reply #6 on: August 21, 2013, 01:28:06 pm »
Sorry to re-open this, but I've been stuck on this for days. The command works, but I can't make it work with my  rank system.

My ranks are as follows:

Owner (Superadmin)
Co-Owner
Admin (Admin)
Moderator
Executive
Clan Member
User

I want the damagelogs to be usable by anyone from clan member upwards, or usable by anyone, mid-round, as long as they're dead. I literally can't figure out how this is done... I've crashed the server so much trying to fix things

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Custom command to execute damage logs?
« Reply #7 on: August 21, 2013, 10:57:27 pm »
You'd have to go into <GMod dir>\gamemodes\terrortown\gamemode\admin.lua and change something in line 108.

By default, it should say something like this:
Code: Lua
  1. if (not IsValid(ply)) or ply:IsSuperAdmin() or GetRoundState() != ROUND_ACTIVE then

This might be a ridiculous way of doing it, but it should work fine as long as you have ULib/ULX on the server.
Code: Lua
  1. if (not IsValid(ply)) or GetRoundState() != ROUND_ACTIVE or ply:IsUserGroup("Clan Member") or ply:IsUserGroup("Executive") or ply:IsUserGroup("Moderator") or ply:IsAdmin then

That should allow every single group to use the command whether they're dead or not, not sure if inheritance is counted here, and I'm not sure how well "Clan Member" will work, since it has a space in it (I believe I've seen some issues with spaces in group names). At least those groups that are above "admin"/inherit from "admin" should have access anytime.

Although, I'm not sure if this is the right way to do it, to check if someone is alive and allow them to use it if they're dead, you could use this:
Code: Lua
  1. if (not IsValid(ply)) or GetRoundState() != ROUND_ACTIVE or ply:IsUserGroup("Clan Member") or ply:IsUserGroup("Executive") or ply:IsUserGroup("Moderator") or ply:IsAdmin or ply:Alive() = "false" then
Then again, I'm not sure if I used "ply:Alive" correct. Some other Lua pro will have to fix that issue if I used it the wrong way.
« Last Edit: August 21, 2013, 11:00:02 pm by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Custom command to execute damage logs?
« Reply #8 on: August 22, 2013, 05:25:00 am »
i think its
Code: Lua
  1. ply:Alive == false
but dont hold me to that.
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

  • Print