[QUOTE=RedNinja;48422419][code]
include("tr_allowed_entities.lua")
hook.Add( "OnEntityCreated", "tr_SetColCheck", function(ent)
if trunk_entities[ent:GetClass()] then
ent:SetCustomCollisionCheck(true)
ent:SetNWBool("tr_Storable",true)
end
end )
hook.Add( "ShouldCollide", "tr_ColCheck", function(ent1,ent2)
if (ent2:IsVehicle() and ent1:GetNWBool("tr_Storable")) then
ent1:Remove()
end
end )
[/code]
I'm trying to remove entities that touch a car. The thing is, without them even touching they get removed if the car comes near them. How could I fix that? I want it to remove them only when it really colides.[/QUOTE]
You should use the Collision entity callback on the vehicle.
[QUOTE=James xX;48422471]You should use the Collision entity callback on the vehicle.[/QUOTE]
Tried that too.
[url]http://pastebin.com/ERXHaQ9y[/url]
It never prints "its okay".
[QUOTE=Mista Tea;48420706]So, this has been plaguing me forever.
I have a MySQL server with a schema whose default Collation is [B]utf8[/B]. All of my tables and columns are also set to [B]utf8[/B]. I use the [B]MySQLOO [/B]module that was picked up by Kingofbeast a while back.
Anyway, if some text like "[B]( ͡° ͜ʖ ͡°)[/B]" gets stored in the database via Lua, it gets stored as "[B]( ••° ͜ʖ ••°)[/B]".
Displaying that text on a webpage via PHP will print out ( ••° ͜ʖ ••°) instead of ( ͡° ͜ʖ ͡°).
However, if I directly insert ( ͡° ͜ʖ ͡°) into the MySQL database, it gets [B]stored [/B]as ( ͡° ͜ʖ ͡°) and [B]displays [/B]as ( ͡° ͜ʖ ͡°) on a PHP webpage.
I don't know if I am running into problems described in this [URL="http://lua-users.org/wiki/LuaUnicode"]lua-users wiki page about unicode in Lua[/URL] or if I am making a simple mistake. I really don't have a good understanding of character sets.
Has anyone else already dealt with this issue? Is there anything I can do about it?[/QUOTE]
Please use utf8mb4 or you won't be able to store 4-byte UTF-8 sequences.
[QUOTE=!cake;48422673]Please use utf8mb4 or you won't be able to store 4-byte UTF-8 sequences.[/QUOTE]
Every single query I did when my tables were using utf8mb4 took up to 4-5 seconds to complete asynchronously, compared to the usual milliseconds with utf8.
Is there anyway to get the angles of the world underneath an entity? I'm currently using a trace to get the position but I'd like the angle of the surface.
[QUOTE=Ronon Dex;48423645]Is there anyway to get the angles of the world underneath an entity? I'm currently using a trace to get the position but I'd like the angle of the surface.[/QUOTE]
Something like this?
[code]
tr.HitNormal:Angle()
[/code]
[QUOTE=RedNinja;48424460][vid]http://webm.host/29ebe/vid.webm[/vid]
How do I fix this DModelPanel? :([/QUOTE]
By either giving each model a preset fov, objcet offset and camera position or making a better algorithm to generate all 3.
[QUOTE=Robotboy655;48424475]By either giving each model a preset fov, objcet offset and camera position or making a better algorithm to generate all 3.[/QUOTE]
No idea really. Does anyone have anything that works? My code should work though
:snip:
Okay, so I'm working on a SWEP, and I'm using a custom reload code.
[code]function SWEP:Think()
self.Weapon:ReloadThink()
if self:GetNextIdle() ~= 0 and self:GetNextIdle() < CurTime() then
self:SendWeaponAnim( ACT_VM_IDLE )
self:SetNextIdle( 0 )
end
if !self:Sprinting() and self.Owner:KeyDown(IN_SPEED) and self.Owner:GetVelocity():Length() > self.Owner:GetWalkSpeed() then --if self.Owner:KeyDown( bit.bor(IN_FORWARD,IN_BACK,IN_MOVELEFT,IN_MOVERIGHT) ) and self.Owner:KeyDown( IN_SPEED ) and !self:Sprinting() then
if self:GetNWBool( "IronSights" ) then
self:SetNWBool( "IronSights", false )
if SERVER then
self.Owner:SetFOV( 0, 0.50 )
end
end
self:SetSprinting( true )
elseif self:Sprinting() and !self.Owner:KeyDown(IN_SPEED) or self:Sprinting() and self.Owner:GetVelocity():Length() <= self.Owner:GetWalkSpeed() then--elseif !self.Owner:KeyDown( bit.bor(IN_FORWARD,IN_BACK,IN_MOVELEFT,IN_MOVERIGHT) ) and self:Sprinting() then
self:SetSprinting( false )
end
end
function SWEP:Reload()
if self.Weapon:Clip1() == self.Primary.ClipSize then return end
self.Weapon:DoReload()
end
function SWEP:DoReload()
if self.ReloadTime then return end
if self:GetNWBool( "IronSights" ) == true then self:SetNWBool( "IronSights", false ) if SERVER then self.Owner:SetFOV( 0, 0.50 ) end end
local time = self.Weapon:StartWeaponAnim( ACT_VM_RELOAD )
if self.Reloading == false then self.Reloading = true end
self.Weapon:SetNextPrimaryFire( CurTime() + time + 0.100 )
self.ReloadTime = CurTime() + time
self:SetNextIdle( CurTime() + time )
end
function SWEP:ReloadThink()
if self.ReloadTime and self.ReloadTime <= CurTime() then
self.ReloadTime = nil
if self.Reloading == true then self.Reloading = false end
self.Weapon:SetClip1( self.Primary.ClipSize )
end
end
function SWEP:StartWeaponAnim( anim )
if IsValid( self.Owner ) then
local vm = self.Owner:GetViewModel()
local idealSequence = self:SelectWeightedSequence( anim )
local nextSequence = self:FindTransitionSequence( self.Weapon:GetSequence(), idealSequence )
if nextSequence > 0 then
vm:SendViewModelMatchingSequence( nextSequence )
else
vm:SendViewModelMatchingSequence( idealSequence )
end
return vm:SequenceDuration( vm:GetSequence() )
end
end
[/code]
But, I realized I just made a [b][i]fatal[/i][/b] error.
[code]function SWEP:ReloadThink()
if self.ReloadTime and self.ReloadTime <= CurTime() then
self.ReloadTime = nil
if self.Reloading == true then self.Reloading = false end
self.Weapon:SetClip1( self.Primary.ClipSize )
end
end[/code]
I forgot to set the reserve ammunition that the player has. Now, I know how to do this, but I don't know what I'd use to set the reserve ammunition just like DefaultReload does.... It's hard to explain but someone might as well know... help?
Is there anyway to get date/time creation of a txt file inside data after it's been made? I know I could write os.time()/os.date to the file itself which I'm probably gonna do but curious if there'd be another way
Not that I can see - the only thing we have exposed is the last modified time.
Found what you referring to, it'll do, ty
[QUOTE=NiandraLades;48426627]Found what you referring to, it'll do, ty[/QUOTE]
What exactly was he referring to?
-snip-
Moved to its own thread, probably won't be a quick solution.
I just updated my server and I'm getting a segmentation fault upon starting the servers now. Any idea?
[editline]11th August 2015[/editline]
/home/steam/gmodserver/srcds_run: 1: /home/steam/gmodserver/srcds_run: gdb: not found
OS is Linux. Why am I getting this since the new update?
[editline]11th August 2015[/editline]
installed gdb again, now I'm getting this error:
Segmentation fault (core dumped)
BFD: Warning: /home/steam/gmodserver/core is truncated: expected core file size >= 243343360, found: 1245184.
Cannot access memory at address 0xf77e0908
Cannot access memory at address 0xf77e0904
debug.cmds:1: Error in sourced command file:
Cannot access memory at address 0xffc34264
[editline]11th August 2015[/editline]
Fixed.
You need to copy steamcmd linux32 folder to your servers/bin folder.
I saw in the patch notes that the render.Capture() bug where it couldn't capture larger than the client's screen resolution was fixed. I am probably doing something horribly wrong, but does anyone know why won't this work?
[code]
concommand.Add( "rt_test", function()
local tw, th = 2048, 2048
local newrt = GetRenderTarget( "test_rt", tw, th, false )
hook.Add( "HUDPaint", "TestRenderTarget", function()
local oldw, oldh = ScrW(), ScrH()
render.PushRenderTarget( newrt )
render.SetViewPort( 0, 0, tw, th )
cam.Start2D()
render.Clear( 0, 0, 0, 255 )
local data = render.Capture( {
format = "jpeg",
quality = "100",
x = 0,
y = 0,
w = tw,
h = th,
} )
cam.End2D()
render.SetViewPort( 0, 0, oldw, oldh )
render.PopRenderTarget()
if not data then print( "Nope" ) end
hook.Remove( "HUDPaint", "TestRenderTarget" )
end )
end )
[/code]
It fails if either dimension is larger than my screen resolution.
Having an issue with a few playermodels I've recently been retexturing.
For some reason in game the models get randomly dark and bright. It's really odd and I was told it may have to do with the VMTs or even how I imported the VTFs but I am not sure.
How do I remove Derma_DrawBackgroundBlur() after I have called it?
I have it in a main DFrame:Paint() function but when I remove the DFrame the blur stays, how do I get rid of it again?
Ive tried to remove it both with DFrame:Remove() and with the X button but it doesnt go away.
DFrame:SetBackgroundBlur( false ) :P
[QUOTE=Mooda Looda;48441133]DFrame:SetBackgroundBlur( false ) :P[/QUOTE]
Wouldnt that only affect DFrame:SetBackgroundBlur(true)?
Doesnt work anyways, tried DFrame.OnClose = function() and function PANEL:OnClose(), nether worked with your suggestion.
This is more of a question than a problem.
So, is there any advantage of using [url=http://wiki.garrysmod.com/page/Entity/DispatchTraceAttack]Entity:DispatchTraceAttack[/url] as compared to my current melee code? I noticed TTT uses in it their knife code.
My code:
[code] self:EmitSound( "weapons/knife/knife_slash"..math.random( 1, 2 )..".wav" )
local tracedata = {}
tracedata.start = self.Owner:GetShootPos()
tracedata.endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 75
tracedata.filter = self.Owner
tracedata.mins = Vector( -8, -8, -8 )
tracedata.macs = Vector( 8, 8, 8 )
if ( self.Owner:IsPlayer() ) then
self.Owner:LagCompensation( true )
end
local tr = util.TraceHull( tracedata )
if tr.Hit then
self:EmitSound( "weapons/knife/knife_hit"..math.random( 1, 4 )..".wav" )
end
if IsValid( tr.Entity ) then
self:SendWeaponAnim( ACT_VM_HITCENTER )
else
self:SendWeaponAnim( ACT_VM_MISSCENTER )
end
if tr.Hit and tr.HitNonWorld and IsValid( tr.Entity ) then
if tr.Entity:IsNPC() then
local dmg = DamageInfo()
dmg:SetAttacker( self.Owner )
dmg:SetInflictor( self )
dmg:SetDamage( 46 )
dmg:SetDamageType( DMG_SLASH )
tr.Entity:TakeDamageInfo( dmg )
end
end
if ( self.Owner:IsPlayer() ) then
self.Owner:LagCompensation( false )
end[/code]
This is in a primary attack func, btw.
Can someone explain to me why this code isn't working in the PlayerSPawn hook?
This is supposed to prevent the player from spawning until they use the character creation menu.
It isn't giving me errors and it prints 0 when I run the "print(ply.HasJoined)".
Code:
[lua]
--Prevent player from spawning if they have not joined recently
print(ply.HasJoined)
if ply.HasJoined == 0 then
print(ply.HasJoined)
umsg.Start( "cc", ply )
umsg.End()
end
[/lua]
Edit ----------------------
Solved I am a idiot I forgot it returned a string value.
[QUOTE=bran92don;48442640]Can someone explain to me why this code isn't working in the PlayerSPawn hook?
This is supposed to prevent the player from spawning until they use the character creation menu.
It isn't giving me errors and it prints 0 when I run the "print(ply.HasJoined)".
Code:
[lua]
--Prevent player from spawning if they have not joined recently
print(ply.HasJoined)
if ply.HasJoined == 0 then
print(ply.HasJoined)
umsg.Start( "cc", ply )
umsg.End()
end
[/lua]
Edit ----------------------
Solved I am a idiot I forgot it returned a string value.[/QUOTE]
Dont use user messages
[QUOTE=Voluptious;48441151]Wouldnt that only affect DFrame:SetBackgroundBlur(true)?
Doesnt work anyways, tried DFrame.OnClose = function() and function PANEL:OnClose(), nether worked with your suggestion.[/QUOTE]
Seems like you are calling this function without arguments.
[CODE]Derma_DrawBackgroundBlur(YourPanel, 0)[/CODE]
Stupid question, but how would you kill an NPC within Lua?
[QUOTE=Exploderguy;48442763]Dont use user messages[/QUOTE]
Why not? I could have sworn I read in the update thread that he made them just as efficient as nets in one of the past updates?
Plus I am only using that to load one simple function on the client.
[QUOTE=MPan1;48443387]Stupid question, but how would you kill an NPC within Lua?[/QUOTE]
:snip: It was my custom bullshit.
Sorry, you need to Log In to post a reply to this thread.