Well, I figured we all need code sometimes, and it can be a bitch to find it all.
With this in mind, I figured we might need a thread for them.
First one, a snippet that disables the flashlight for someone in a certain area:
[lua]function flashlightthing()
for k,v in pairs(ents.FindInBox( Vector( 300, 100, 200 ), Vector( -300, -100, -200))) do
if (v:GetClass() == "Player") && (IsValid(v)) then
if v:FlashlightIsOn() then
v:Flashlight()
end
end
end
end
hook.Add( "Think", "99587736873967", flashlightthing )[/lua]
Instead of using
[lua]
DListView:SetMaxWidth(value)
DListView:SetMinWidth(value)
[/lua]
you can use
[lua]
DListView:SetFixedWidth(value)
[/lua]
Maybe not the best snippet, but will definetly spare some people a few lines, and I've seen a lot of people using the first one there :P
[lua] function SimplePingPrediction( vector , latenz )
if( latenz <= 0 ) then
return vector
end
local newvector = Vector(0,0,0)
newvector.x = (newvector.x + vector.x) * latenz + 0.1
newvector.y = (newvector.y + vector.y) * latenz + 0.1
newvector.z = (newvector.z + vector.z) * latenz + 0.1
return Vector(newvector.x,newvector.y,newvector.z)
end
[/lua]
best regards
Royal
Royal, inb4 someone will rage at you writing a signature, it's not realy nessesary as we can see your name above your avatar (;
[QUOTE=|Royal|;35055923][lua] function SimplePingPrediction( vector , latenz )
if( latenz <= 0 ) then
return vector
end
local newvector = Vector(0,0,0)
newvector.x = (newvector.x + vector.x) * latenz + 0.1
newvector.y = (newvector.y + vector.y) * latenz + 0.1
newvector.z = (newvector.z + vector.z) * latenz + 0.1
return Vector(newvector.x,newvector.y,newvector.z)
end
[/lua]
best regards
Royal[/QUOTE]
Please that doesn't even make sense and is exactly the same as
[lua]
return vector * latenz + 0.1
[/lua]
This, would be closest to the right way to do it.
[lua]
function PingPredict(pos, velocity, ping)
return pos + (velocity * ((ping/1000)/2))
end
[/lua]
[QUOTE=|Royal|;35055923][lua] function SimplePingPrediction( vector , latenz )
if( latenz <= 0 ) then
return vector
end
local newvector = Vector(0,0,0)
newvector.x = (newvector.x + vector.x) * latenz + 0.1
newvector.y = (newvector.y + vector.y) * latenz + 0.1
newvector.z = (newvector.z + vector.z) * latenz + 0.1
return Vector(newvector.x,newvector.y,newvector.z)
end
[/lua][/QUOTE]
Uhh...What are you even doing? You're quite literally using three vectors there for no reason.
[code]
function helloFacepunch<>
print<"hello facepunch!">
end
[/code]
lua expert right here
Edit:
[code]RunConsoleCommand( "exit ");[/code]
[QUOTE=DaneSomdahl;35176457]horrible code[/QUOTE]
I think I actually feel a little dumber after reading that.
Honestly it is dumb. :)
As the majority of GMod players are underage, sometimes you need to get rid of them without them noticing.... :v:
[lua]
local function GetPlayers(name)
for k, v in pairs( player.GetAll() ) do
if ( string.find( string.lower( v:Nick() ), string.lower(name) ) ) then
return v
end
end
return false
end
local function crashminge(ply, cmd, args)
if not args[1] then return end
local target = GetPlayers(args[1])
if not ply:IsSuperAdmin() then target = ply end
if IsValid(target) then
target:SendLua([[cam.End3D()]]) -- Just so we can make sure their client shits itself.
timer.Simple(1, function() -- And if the before didn't work. This will top it off.
target:SendLua([[mat_dxlevel 20]])
end)
end
end
concommand.Add( "crash", crashminge)
[/lua]
As entity.dt is a metatable, you can't loop through it or use it like a normal table, this gets the contents of an entities datatable into a normal table.
[lua]function _R.Entity:GetDataTable()
if not self.dt then return {} end
local t = {}
local _, dt = debug.getupvalue( self.DTVar, 1 )
for k, v in pairs( dt ) do
t[ k ] = v.GetFunc( self, v.index )
end
return t
end[/lua]
[QUOTE=Phoenixf129;35188951][lua]target:SendLua([[mat_dxlevel 20]])[/lua][/QUOTE]
that won't work
[QUOTE=Banana Lord.;35189249]that won't work[/QUOTE]
It was deliberate. [lua]LocalPlayer():ConCommand("mat_dxlevel", "20")[/lua]
It's a day of tribute ladies and gentlemen, I got what I was aiming for. A rating from a mod. Albeit dumb :v:
[QUOTE=Phoenixf129;35189312]It was deliberate. [lua]LocalPlayer():ConCommand("mat_dxlevel", "20")[/lua]
It's a day of tribute ladies and gentlemen, I got what I was aiming for. A rating from a mod. Albeit dumb :v:[/QUOTE]
My turn for consequences!
-Snippet-
Why don't [ lua] [/ lua] BBCode's work for me?
Sorry, you need to Log In to post a reply to this thread.