I'm having a problem with DModelPanel. I've programmed a derivative of DModelPanel that allows for 2 models to be drawn instead of just the one. I'm using this to make a hat editor for the gamemode I'm making. The problem is, when I press escape (to enter the gmod console), the model continues to spin, but the hat does not.
[Lua]
function PANEL:LayoutEntity( Entity )
if ( self.bAnimated ) then
self:RunAnimation()
end
Entity:SetAngles( Angle( 0, RealTime() * 10, 0 ) )
local pos, ang = self:CalculateOffset( self.Entity:GetBonePosition( self.BoneID ) )
self.HatEntity:SetPos( pos )
self.HatEntity:SetAngles( ang )
self.HatEntity:SetModelScale( self:GetHatScale(), 0 )
end
[/lua]
I'm guessing that the bone positions don't get updated when in the menu. Is there any way to solve this?
[QUOTE=Llamalord;47520999]FindInBox when used client side doesn't table the player even if they are in the specified area. Does anyone know of another way of seeing if the clientside player is inside a specific box besides using distance from entity?
EDIT:
I found a fix where you create a PhysicsInitBox and SetCollisionBounds for the entity and make the collision between the player no collide. Then make a StartTouch() and you can now detect when a player is in the box you created.[/QUOTE]
That's so hacky.
Do something like this instead:
[lua]
function IsInBox( mins, maxs, point )
if point.x >= mins.x and point.x <= maxs.x then
if point.y >= mins.y and point.y <= maxs.y then
if point.z >= mins.z and point.z <= maxs.z then
return true
end
end
end
return false
end
--example:
IsInBox( Vector( -100,-100,-100 ), Vector( 100,100,100 ), LocalPlayer():GetPos() )
[/lua]
How can I wake NPCs that I've spawned up? Testing with an npc_zombie, SetLastPosition, NavSetGoal, and SetSchedule haven't been working (or I haven't been using them correctly). Basically I want them to act as if someone just shot them from far away. Anything that will make them move.
-snip-
[editline]15th April 2015[/editline]
Why would the reload animation not consistently play? Sometimes it does nothing.
[code] function SWEP:Think( )
if self.Owner:GetActiveWeapon( ).PrintName ~= self.PrintName then return end -- Q&D check because SWEP:Think( ) runs even if weapon isn't out
if self.DATA.Reloading == true then
if self.DATA.Reload.StartAnimTime and CurTime( ) >= self.DATA.Reload.StartAnimTime then
print( "RELOAD: START" )
self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_START )
self.DATA.Reload.ReloadAnimTime = CurTime( ) + self.DATA.Reload.StartAnimDur
self.DATA.Reload.StartAnimTime = nil
end
if self.DATA.Reload.ReloadAnimTime and CurTime( ) >= self.DATA.Reload.ReloadAnimTime then
print( "RELOAD: RELOAD" )
self.DATA.Reload.ReloadAnimTime = nil
if self:Clip1( ) < self.Primary.ClipSize then
self:SendWeaponAnim( ACT_VM_RELOAD )
self:SetClip1( self:Clip1( ) + 1 )
self.DATA.Reload.ReloadAnimTime = CurTime( ) + self.DATA.Reload.ReloadAnimDur
else
self.DATA.Reload.FinishAnimTime = CurTime( )
end
end
if self.DATA.Reload.FinishAnimTime and CurTime( ) >= self.DATA.Reload.FinishAnimTime then
print( "RELOAD: FINISH" )
self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
self.DATA.Reload.FinishAnimTime = nil
self.DATA.Reloading = false
end
end
end[/code]
How would I draw a player's model without calling the Pre- and PostPlayerDraw hooks?
Oh, to clarify with my last thing - it's not really the code that matters. The Reload animation just doesn't want to consistently play.
Not sure if this is an easy thing or not, but how would I make a player be able to use bloc animations when their model is set to a ragdoll, I think it uses act enums, anyone pointers?
Probably not possible but, is there a way to get metadata from an audio channel at all?
-snip-
Solved it literally two seconds after posting this. Awesome.
[QUOTE=Karp;47535691]Why doesn't this table work? I'm stumped.[lua]local facepunch = {}
facepunch = {
'admins' = 5,
'users' = 25,
'guests' = 500,
}[/lua]I get this error.
It's frustrating me, because it's probably something [I]really simple[/I] but I can't find a solution. It's killing me.[/QUOTE]
I think you need square brackets around the keys if it's a datatype.
ok basic question
resource.AddFile( "materials/vgui/LimbHUD/HeadFlesh.vmt" )
apparently doesn't work, i put it in lua/autorun/server/sv_limb_resource. I thought it automatically includes the vtf too
[QUOTE=ROFLBURGER;47536719]ok basic question
resource.AddFile( "materials/vgui/LimbHUD/HeadFlesh.vmt" )
apparently doesn't work, i put it in lua/autorun/server/sv_limb_resource. I thought it automatically includes the vtf too[/QUOTE]
I could very well be wrong, but I think it's the vtf that includes the vmt and not vice versa.
[QUOTE=r0uge;47537538]I could very well be wrong, but I think it's the vtf that includes the vmt and not vice versa.[/QUOTE]
I resource.AddFile both VMT and VTF and I don't have a problem, but I could be doing it wrong.
[QUOTE=wauterboi;47530806]-snip-
[editline]15th April 2015[/editline]
Why would the reload animation not consistently play? Sometimes it does nothing.[/QUOTE]
[QUOTE=wauterboi;47535299]Oh, to clarify with my last thing - it's not really the code that matters. The Reload animation just doesn't want to consistently play.[/QUOTE]
This [i]seems[/i] to happen fairly reliably if you send two reload animations in a row (see [url]http://facepunch.com/showthread.php?t=1315222[/url]). ACT_VM_IDLE in the middle fixes it, for an unknown value of 'fix'. Other animations probably work as well.
ENT:SetCollisionBoundsWS() seems to only be usable in ENT:Initialize(), how can I do this with a table spawn numerous entities of the same entity and set their collision bounds from a table value? I can't call the Initialize again?
[QUOTE=DarthTealc;47538327]Any tips on SetSubMaterial? I want to place a 'decal' on a player's shirt but I'm only able to replace the material completely. I tried creating a Lua material (with the aim of applying the current material + the 'decal') but I couldn't get it to apply.
Is that the way to go about it, or should I be using a different method?[/QUOTE]
Take with a grain of salt because I haven't ever done anything like this but I guess it would work:
You could get the default submaterial, create a render target (with the same width and height?), draw the default submaterial on the render target, then draw your decal on top, then use CreateMaterial and specify the rendertarget as texture (use ITexture:GetName() on the RT, then set that as $basetexture), then apply the newly created material to the model using SetSubMaterial.
[QUOTE=Luni;47538245]This [i]seems[/i] to happen fairly reliably if you send two reload animations in a row (see [url]http://facepunch.com/showthread.php?t=1315222[/url]). ACT_VM_IDLE in the middle fixes it, for an unknown value of 'fix'. Other animations probably work as well.[/QUOTE]
I tried playing IDLE immediately before but it didn't work. Perhaps, I'd have to put a delay in between. Will try.
[QUOTE=DarthTealc;47538427]That sounds promising but wouldn't it be a bit heavy? I might try it anyway and see how it goes. Though I have a feeling SetSubMaterial just doesn't like Lua-created materials :/[/QUOTE]
I don't think so, the GarryBoy emulator's display is an RT that's updated quite often and there isn't any major performance impact.
Could someone explain how to spawn an entity and run a trace and set the position of the entity to outside of the solid no matter the the vector?
I have made a net library and it keeps telling me that I am " Calling net.Start with unpooled message name"
I will leave my code down below thanks for the help
[B]Server side![/B]
[CODE] util.AddNetworkString( "SpawnRequest" )
net.Receive( "SpawnRequest", function( length, client )
local data = net.ReadString()
if data == "Soldier" then SpawnCombineS(client:GetEyeTraceNoCursor().HitPos+Vector(0,0,30)) end
end
-- The combine
function SpawnCombineS( pos )
NPC = ents.Create( "npc_combine_s" )
NPC:SetKeyValue("NumGrenades", "2")
NPC:SetPos( pos )
NPC:SetKeyValue( "ignoreunseenenemies", 0 )
NPC:SetKeyValue( "spawnflags", 512 )
NPC:Spawn()
end[/CODE]
[B]Client Side![/B]
[CODE]net.Start("SpawnRequest")
net.WriteString("Soldier")
net.SendToServer()[/CODE]
[QUOTE=LosttSpacee;47542661]I have made a net library and it keeps telling me that I am " Calling net.Start with unpooled message name"
I will leave my code down below thanks for the help
[B]Server side![/B]
[CODE] util.AddNetworkString( "SpawnRequest" )
net.Receive( "SpawnRequest", function( length, client )
local data = net.ReadString()
if data == "Soldier" then SpawnCombineS(client:GetEyeTraceNoCursor().HitPos+Vector(0,0,30)) end
end
-- The combine
function SpawnCombineS( pos )
NPC = ents.Create( "npc_combine_s" )
NPC:SetKeyValue("NumGrenades", "2")
NPC:SetPos( pos )
NPC:SetKeyValue( "ignoreunseenenemies", 0 )
NPC:SetKeyValue( "spawnflags", 512 )
NPC:Spawn()
end[/CODE]
[B]Client Side![/B]
[CODE]net.Start("SpawnRequest")
net.WriteString("Soldier")
net.SendToServer()[/CODE][/QUOTE]
[del]Not sure if it still does this but there should be a url given in that error as well. Try going to that...[/del]
Oh wait I'm an ass-hole. You're calling addnetworkstring so you shouldn't be getting that error. Are you sure your serverside file is running?
[QUOTE=mcd1992;47542943][del]Not sure if it still does this but there should be a url given in that error as well. Try going to that...[/del]
Oh wait I'm an ass-hole. You're calling addnetworkstring so you shouldn't be getting that error. Are you sure your serverside file is running?[/QUOTE]
It is because other functions in the server side file are working
[QUOTE=LosttSpacee;47542661]I have made a net library and it keeps telling me that I am " Calling net.Start with unpooled message name"
I will leave my code down below thanks for the help
[B]Server side![/B]
[CODE] util.AddNetworkString( "SpawnRequest" )
net.Receive( "SpawnRequest", function( length, client )
local data = net.ReadString()
if data == "Soldier" then SpawnCombineS(client:GetEyeTraceNoCursor().HitPos+Vector(0,0,30)) end
end
-- The combine
function SpawnCombineS( pos )
NPC = ents.Create( "npc_combine_s" )
NPC:SetKeyValue("NumGrenades", "2")
NPC:SetPos( pos )
NPC:SetKeyValue( "ignoreunseenenemies", 0 )
NPC:SetKeyValue( "spawnflags", 512 )
NPC:Spawn()
end[/CODE]
[B]Client Side![/B]
[CODE]net.Start("SpawnRequest")
net.WriteString("Soldier")
net.SendToServer()[/CODE][/QUOTE]
missing an ) on the end of the net.Receive function
I'm at a loss here. I've been experimenting with NWVars and I can't get the NWVarProxies to work.
After a quick search on the gmod github, I was introduced to the EntityNetworkedVarChanged hook. Through the gmod wiki, I copypasted and tested, on clientside, the example for the EntityNetworkedVarChanged hook:
[CODE]hook.Add("EntityNetworkedVarChanged","print out everything",print)[/CODE]
However, it doesn't work. Suspecting that it would be only accessible serverside (despite the hook being shared) I tried the same code serverside, but to no avail.
Has anyone had this problem before with the EntityNetworkedVarChanged hook not being called at all, or are there any easy, non-hacky replacements I can use?
[QUOTE=DarthTealc;47544002]I can't manage to use a Lua-created material with SetSubMaterial or SetMaterial on players. I thought I was creating bad Lua materials but I reduced the code to bare basics using an existing vmt material read into Lua and it doesn't work.
[code]LocalPlayer():SetMaterial( Material("brick/brick_model") )[/code]
That doesn't work. No errors, but the player model stays as normal.
[code]LocalPlayer():SetMaterial("brick/brick_model")[/code]
That does work, reading the vmt file directly. Applies a brick material to the whole player model.
Am I doing this wrong or is it simply not possible to apply a Lua material to a player?[/QUOTE]
dunno for sure, but have you tried to create the material inside a local?
[lua]
local mat = Material("brick/brick_model")
LocalPlayer():SetMaterial(mat)
[/lua]
Which hook are you calling it in?
If anyone recalls, a few weeks back I posted a few times about this exact issue - Using a material with a render target then using that render target in a new material. Ent:Set(Sub)Material does NOT work with created materials. Instead, you must use render.MaterialOverrideByIndex.
You can override ent:RenderOverride even for non-SENTs (i.e. Doors and Vehicles).
Is there any way to make brushes in lua?
Also, can set up one of the camera entities like in hammer and link it to existing screens on the map? Anything on the gmod wiki to point the way would help. I know these are all easily doable in hammer, but I'm curious.
[QUOTE=Sheeplie;47545457]Is there any way to make brushes in lua?
Also, can set up one of the camera entities like in hammer and link it to existing screens on the map? Anything on the gmod wiki to point the way would help. I know these are all easily doable in hammer, but I'm curious.[/QUOTE]
You could create meshes, and use Entity:PhysicsFromMesh?
[QUOTE=James xX;47545654]You could create meshes, and use Entity:PhysicsFromMesh?[/QUOTE]
They are gonna be actual entities and each will take its own entity index and that means if you make too many this way you won't be able to spawn anything.
So this isn't really good way to do complex geometry via simple primitives, you can try combining everything into one big mesh though but I'm not sure how physics engine is gonna react to it.
Sorry, you need to Log In to post a reply to this thread.