InfoGarry's Mod Script Thread
I'm 'onna revive this thing.
I wanted to see if someone made a breakthrough in converting the witnesses script?
I wanted to see if someone made a breakthrough in converting the witnesses script?
Did you ever get around to taking a look? In any event I stumbled across an old lua script that lets you measure distances. Only error it had is that it was trying to use a default font. Just spent about 10 hours in a server with this on. Works perfect as far as I can tell.
Bind a key to "distance_press". 1st click places 1st point, 2nd click 2nd point, 3rd clears points.
Code:
/**
Splambob's quick clientside distance script.
Bind a key to "distance_press" to use.
Press key twice to define two points, press again to remove results.
Outputs results to console for copy/pasta.
//*/
if not CLIENT then return end
local DistStage = 1
local DistVec1 = nil
local DistVec2 = nil
local DistShouldPaint = false
local DistBetween = 0
surface.CreateFont("InfoFont",{font = "ScoreboardText", size = 14, weight = 400, antialias = 1})
local InfoSep = 0 // Seperation between lines
local InfoXOff = 12 // Offsets from player centre
local InfoYOff = -11
surface.SetFont("InfoFont")
// IWidth is never used.
local IWidth, FontHeight = surface.GetTextSize("I")
local client = client or LocalPlayer()
/**
DistM_Init
Assigns local player to client variable after entity initialisation.
This is a bugfix.
//*/
function DistM_Init()
client = LocalPlayer()
end
hook.Add( "InitPostEntity", "DistM_RunInitHook", DistM_Init )
/**
DistM_Paint
Painty things.
//*/
function DistM_Paint()
if DistShouldPaint then
DistM_Stages[DistStage]()
local DrawDist = false
if DistVec2 != nil then
local ScrCen = DistVec2:ToScreen()
DrawDist = true
DistBetween = DistVec2:Distance(DistVec1)
DistM_DrawLine()
DistM_DrawBox(ScrCen)
DistM_DrawText(DistVec2, ScrCen, true, DistBetween)
end
if DistVec1 != nil then
local ScrCen = DistVec1:ToScreen()
DistM_DrawBox(ScrCen)
DistM_DrawText(DistVec1, ScrCen, DrawDist, DistBetween)
end
end
end
hook.Add( "HUDPaint", "DistThink", DistM_Paint )
function DistM_DrawLine()
surface.SetDrawColor( 255, 255, 255, 255) // colour of line between two points
local Scr1 = DistVec1:ToScreen()
local Scr2 = DistVec2:ToScreen()
surface.DrawLine(Scr1.x, Scr1.y, Scr2.x, Scr2.y)
end
function DistM_DrawBox(ScrVec)
surface.SetDrawColor( 0, 0, 0, 255) // colour of point dropshadow
surface.DrawOutlinedRect( ScrVec.x-7, ScrVec.y-7, 16, 16 )
surface.DrawOutlinedRect( ScrVec.x, ScrVec.y, 2, 2 )
surface.SetDrawColor( 255, 255, 0, 255) // colour of point marker
surface.DrawOutlinedRect( ScrVec.x-1, ScrVec.y-1, 2, 2 )
surface.DrawOutlinedRect( ScrVec.x-8, ScrVec.y-8, 16, 16 )
end
function DistM_ToVecString(Vec)
return "( "..(math****und(Vec.x*10)/10)..", "..(math****und(Vec.y*10)/10)..", "..(math****und(Vec.z*10)/10).." )"
end
function DistM_ToDistString(Dist)
return (math****und(Dist*10)/10).." glu ("..(math****und(Dist*0.01905*10)/10).." m)"
end
function DistM_DrawText(Vec, ScrVec, DispDist, Dist)
surface.SetFont("InfoFont")
surface.SetTextColor( 255, 255, 255, 255 )
local TextRow = 0
local PVec = DistM_ToVecString(Vec)
DistM_DrawInfoLine(PVec, TextRow, ScrVec)
TextRow = TextRow + 1
if DispDist then
local PDist = DistM_ToDistString(Dist)
DistM_DrawInfoLine(PDist, TextRow, ScrVec)
//TextRow = TextRow + 1 //uncomment this if adding more info
end
end
/**
DistM_DrawInfoLine(Str, Line, Vec) (v1)
Draws an info line given a specified line, string and box position.
Requires font info to be set up, except the position.
//*/
function DistM_DrawInfoLine(Str, Line, Vec)
local PNPos = Vector(Vec.x + InfoXOff, Vec.y + InfoYOff + (FontHeight + InfoSep)*Line, 0)
surface.SetTextPos( PNPos.x, PNPos.y )
surface.DrawText(Str)
end
DistM_Stages =
{
// If you want the point marker to be visible before placement, uncommand the below line
// and change all instances of "DistStage = 1" to "DistStage = 0"
//[0] = function() DistShouldPaint = true end,
[1] = function()
local vec1trace = LocalPlayer():GetEyeTrace()
DistVec1 = vec1trace.HitPos
DistShouldPaint = true
end,
[2] = function()
local vec2trace = LocalPlayer():GetEyeTrace()
DistVec2 = vec2trace.HitPos
DistShouldPaint = true
end,
[3] = function() end,
[4] = function()
DistShouldPaint = false
DistVec1 = nil
DistVec2 = nil
DistBetween = 0
DistStage = 1
end
}
/**
DistM_Command
Commandy things.
//*/
function DistM_Command(player,command,arguments)
DistM_Stages[DistStage]()
DistStage = DistStage + 1
if DistStage == 3 then
Dist = DistM_ToDistString(DistVec2:Distance(DistVec1))
VStr1 = DistM_ToVecString(DistVec1)
VStr2 = DistM_ToVecString(DistVec2)
Msg("\n-- Distance Measure Output: --\n\n")
Msg("\tDistance: "..Dist.."\n\n")
Msg("\tVector 1: "..VStr1.."\n")
Msg("\tVector 2: "..VStr2.."\n\n")
Msg("------------------------------\n")
end
end
concommand.Add( "distance_press", DistM_Command )
Small annoying flashlight spam when you hold down H.
Yes this has been done before, yes you may not like H as spam key (change it yourself as well as "lenny_flashlight" if you dont like it) and yes it may not be perfect.
Code:
CreateClientConVar("lenny_flashlight", 0, true, false)
function Flashspam()
if GetConVar("lenny_flashlight"):GetInt() == 1 then
if input.IsKeyDown(KEY_H) then
RunConsoleCommand("impulse", "100")
return end
end
end
hook.Add("Think", "Flspam", Flashspam )
You can find all my other scripts here: https://github.com/LennyPenny/LennysUtilities/tree/master/Lenny's_Scripts/lua/Lenny
They are not perfect, not original and not optimized.
Thanks for contributing. I'll be testing out your triggerbot on a DarkRP server. Never did fancy aimbots quite as much as triggerbots.
Will also test the updated witnesses script and report back on that.
EDIT: triggerbot and witnesses script confirmed working. using BindToggle (I think that comes from Fptje's Small Scripts. Not sure since it's been ages since I've played a game of Gmod without it on) to make turning it off and on bound to 1 key makes for some slick toggling.
Will also test the updated witnesses script and report back on that.
EDIT: triggerbot and witnesses script confirmed working. using BindToggle (I think that comes from Fptje's Small Scripts. Not sure since it's been ages since I've played a game of Gmod without it on) to make turning it off and on bound to 1 key makes for some slick toggling.
Yeah the aimbot is pretty shit and I'm not going to make it any better I guess, not so much my thing and there's plenty alternatives out there.
Just note that these are pretty much my first lua scripts and some of them have big problems.
Just note that these are pretty much my first lua scripts and some of them have big problems.
Fixed the witness script from Hermy11 I think:
Just had to remove ":normalize()" in line 24.
Awesome script Henry11, keep it coming!
Code:
local Cap = math.cos(math.rad(45))
local Offset = Vector(0, 0, 32)
local Trace = {}
function Draw()
local Time = os.time() - 1
local Witnesses = 0
local BeingWitnessed = true
local Texture = surface.GetTextureID("gui/silkicons/emoticon_smile")
if Time < os.time() then
Time = os.time() + .5
Witnesses = 0
BeingWitnessed = false
for k, pla in pairs(player.GetAll()) do
if pla:IsValid() and pla != LocalPlayer() then
Trace.start = LocalPlayer():EyePos() + Offset
Trace.endpos = pla:EyePos() + Offset
Trace.filter = {pla, LocalPlayer()}
TraceRes = util.TraceLine(Trace)
if !TraceRes.Hit then
if (pla:EyeAngles():Forward():Dot((LocalPlayer():EyePos() - pla:EyePos())) > Cap) then
Witnesses = Witnesses + 1
BeingWitnessed = true
end
end
end
end
end
surface.SetFont("BudgetLabel")
if BeingWitnessed then
surface.SetTextColor(255, 000, 000, 255)
Texture = surface.GetTextureID("gui/silkicons/exclamation")
else
surface.SetTextColor(000, 255, 000, 255)
Texture = surface.GetTextureID("gui/silkicons/emoticon_smile")
end
local Text = "Witnesses: "..tostring(Witnesses)
local Width, Height = surface.GetTextSize(Text)
surface.SetDrawColor(80, 80, 80, 180)
surface.DrawRect(ScrW()/2 - (Width/2 + 24), 4, Width + 28, Height + 8)
surface.SetDrawColor(0, 0, 0, 255)
surface.DrawOutlinedRect(ScrW()/2 - (Width/2 + 24), 4, Width + 28, Height + 8)
surface.SetTexture(Texture)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(ScrW()/2 - (Width/2 + 20), 8, 16, 16)
surface.SetTextPos(ScrW()/2 - Width/2, 8)
surface.DrawText(Text)
end
hook.Add("HUDPaint", "WitnessesBox", Draw)
Awesome script Henry11, keep it coming!
Similar Threads
Hack RequestsGarry's Mod Lua script that shoots the weapon when aiming to someones head.
2 Garry's Mod Discussions & HelpGarry's Mod scripting - HUDPaint not called?
7 C++/C ProgrammingC++ Script Help - Garry's Mod - Forcing r_drawothermodels 2
3 ExploitsGarry's Mod 11 DarkRP RCON ExploitAG 3 GeneralGarry's Mod Meatspin
8
