Ulysses

General => Developers Corner => Topic started by: TheSabreSlicer on January 18, 2014, 04:56:34 PM

Title: Noclip Kill Prevention
Post by: TheSabreSlicer 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.
Title: Re: Noclip Kill Prevention
Post by: Decicus 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 )
Title: Re: Noclip Kill Prevention
Post by: TheSabreSlicer on January 19, 2014, 11:03:24 AM
Thanks, this will do.  :) Have a karma.
Title: Re: Noclip Kill Prevention
Post by: TheSabreSlicer 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!"?
Title: Re: Noclip Kill Prevention
Post by: Decicus 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 )
Title: Re: Noclip Kill Prevention
Post by: TheSabreSlicer 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?
Title: Re: Noclip Kill Prevention
Post by: Bytewave 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.
Title: Re: Noclip Kill Prevention
Post by: TheSabreSlicer on January 19, 2014, 11:58:35 AM
I'm pretty sure its "slay", but I don't know what to put in the ()
Title: Re: Noclip Kill Prevention
Post by: Decicus 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.
Title: Re: Noclip Kill Prevention
Post by: Bytewave 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