Author Topic: Noclip Kill Prevention  (Read 3819 times)

0 Members and 1 Guest are viewing this topic.

Offline TheSabreSlicer

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Noclip Kill Prevention
« on: January 18, 2014, 04:56:34 PM »
Does anyone know a script or something that will warn players when they attempt to kill someone while they are in noclip? It would be nice if it would disable noclip when they shot or something, or maybe just warned them in chat or with a popup.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Noclip Kill Prevention
« Reply #1 on: January 19, 2014, 10:00:29 AM »
This will check whenever someone gets hurt, and if whoever attacks them is in noclip, it will turn off the attackers noclip.
I've attached the file, just place in <GMod dir>/lua/autorun/server/
Code: [Select]
function NoClipDamage( vic, att )
if att:GetMoveType() == MOVETYPE_NOCLIP then
att:SetMoveType( MOVETYPE_WALK )
end
end
hook.Add( "PlayerHurt", "NoClipDamage", NoClipDamage )
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline TheSabreSlicer

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Noclip Kill Prevention
« Reply #2 on: January 19, 2014, 11:03:24 AM »
Thanks, this will do.  :) Have a karma.

Offline TheSabreSlicer

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Noclip Kill Prevention
« Reply #3 on: January 19, 2014, 11:18:06 AM »
Is there a way to tell the player it will be taken away if they abuse it when it is detected?
And tell admins that "Player X is damaging others in Noclip!"?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Noclip Kill Prevention
« Reply #4 on: January 19, 2014, 11:25:01 AM »
Yes. This will notify admins, as well as print to the attacker's chat that they shouldn't do it anymore if they want to keep their NoClip feature.
Attached an updated file.
Code: [Select]
function NoClipDamage( vic, att )
if att:GetMoveType() == MOVETYPE_NOCLIP then
att:SetMoveType( MOVETYPE_WALK )
ulx.asay( nil, att:Nick() .. " is attacking other players while NoClipping!" )
att:ChatPrint( "You are attacking players while noclipped! If you continue doing this, then you will get this feature removed." )
end
end
hook.Add( "PlayerHurt", "NoClipDamage", NoClipDamage )
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline TheSabreSlicer

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Noclip Kill Prevention
« Reply #5 on: January 19, 2014, 11:51:01 AM »
And what part of the script would I need to edit to slay the abuser instead of setting their travel state?

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Noclip Kill Prevention
« Reply #6 on: January 19, 2014, 11:55:35 AM »
And what part of the script would I need to edit to slay the abuser instead of setting their travel state?
Code: [Select]
att:SetMoveType( MOVETYPE_WALK )I think you would replace:
Code: [Select]
SetMoveType( MOVETYPE_WALK )with:
Code: [Select]
Kill()...but I'm not sure.
bw81@ulysses-forums ~ % whoami
Homepage

Offline TheSabreSlicer

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Noclip Kill Prevention
« Reply #7 on: January 19, 2014, 11:58:35 AM »
I'm pretty sure its "slay", but I don't know what to put in the ()

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Noclip Kill Prevention
« Reply #8 on: January 19, 2014, 12:49:23 PM »
No, just change
Code: [Select]
att:SetMoveType( MOVETYPE_WALK )with
Code: [Select]
att:Kill()and thats it.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Noclip Kill Prevention
« Reply #9 on: January 19, 2014, 01:08:22 PM »
No, just change
Code: [Select]
att:SetMoveType( MOVETYPE_WALK )with
Code: [Select]
att:Kill()and thats it.
I knew it! :D
bw81@ulysses-forums ~ % whoami
Homepage