General > Developers Corner
Noclip Kill Prevention
TheSabreSlicer:
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.
Decicus:
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: ---function NoClipDamage( vic, att )
if att:GetMoveType() == MOVETYPE_NOCLIP then
att:SetMoveType( MOVETYPE_WALK )
end
end
hook.Add( "PlayerHurt", "NoClipDamage", NoClipDamage )
--- End code ---
TheSabreSlicer:
Thanks, this will do. :) Have a karma.
TheSabreSlicer:
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!"?
Decicus:
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: ---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 )
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version