• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
If performance ends up being an issue, experiment with using ProjectedTextures instead of dlights.
I found projected textures being noticeably worse than dlights, but i suppose it does depend on the FOV/size of the lamp/light. Settled on lights anyway, with the number I'm using performance is still smooth on my laptop and I'm pretty happy with how its worked out. Cheers for yall input
GM:PlayerStepSoundTime About this, why does this never work when i try to use it? I've done this in Murder and my own gamemode and this simply doesn't work for me. There is only one facepunch thread I can find about this but they didn't get much of an answer. I don't believe Murder messes with this either, and my gamemode certainly did not mess with it because it didnt work anyway.
Check if ply is valid before doing anything in your HUDPaint hook since HUDPaint starts being called before the player finishes initializing/becoming valid.
Use GM:InitPostEntity
I want to use either TeslaZap or TeslaHitboxes. This is the code I have right now and no effects are happening: if !IsValid(self) then return end self:EmitSound("Town.d1_town_01_ball_zap1") local FX = "TeslaZap" local vPoint = self:GetPos() local effectdata = EffectData() effectdata:SetOrigin( vPoint ) self:GetPhysicsObject():ApplyForceCenter(Vector(0,0,420/2)) timer.Simple( 1/3, function() if IsValid(self) then util.Effect( FX, effectdata ) SafeRemoveEntity(self) end end ) How can I get TeslaZap and/or TeslaHitboxes to work? To get rid of the need for timer.Simple I'm likely to move this function into a think hook.
So i wanted to save custom Icons to files based off DModelPanel but i can't figure out how to capture just the model with a transparent background.
SetModel() doesn't work on client-side with LocalPlayer, it's refresh bones. But it's work with another players on client-side. It work for LocalPlayer only in hook PreRender, but without player animation. P.S. models precached on both sides
So I gave up on doing TeslaZap and used TeslaHitBoxes since... that seemed to be easier for some reason. timer.Simple( 3, function() if !IsValid(self) then return end self:EmitSound("Streetwar.d3_c17_11_crane_magnet_switchon") local FX = "TeslaHitBoxes" local vPoint = self:GetPos() local effectdata = EffectData() effectdata:SetOrigin( vPoint ) effectdata:SetStart( vPoint ) effectdata:SetEntity( self ) effectdata:SetRadius( 10 ) effectdata:SetMagnitude( 10 ) effectdata:SetScale( 10 ) self:GetPhysicsObject():ApplyForceCenter(Vector(0,0,420/2)) -- This is a grenade. util.Effect( FX, effectdata ) -- Since this is a grenade I think it would be better to do this in Think, for prediction? timer.Simple( 1/3, function() -- Then some stuff happens So there's the new code . Is there anything I could remove or do better? And should I move this into a Think hook for prediction purposes?
ply is undefined var. Use LocalPlayer() local modelpanel hook.Add("InitPostEntity", "Model on HUD", function() if !IsValid(modelpanel) then local modelpanel = vgui.Create("DModelPanel") modelpanel:SetSize(80, 80) modelpanel:SetModel(LocalPlayer:GetModel()) end end)
You need to define it inside InitPostEntity. LocalPlayer's return isn't valid until then.
Remove the local in front of "modelpanel" inside the hook btw or else the outside local won't be updated.
Is there a way to check if a func_tank* entity is active using Lua?
Having an obnoxious issue with PhysObj:UpdateShadow() https://puu.sh/z0veO/5241c577b2.webm As you can see in about the 22 seconds mark of the video, I'm getting an ENORMOUS collision response from moving the physobj using UpdateShadow. No idea why this might be happening... any thoughts?
So I have been trying to make some interesting looking entities by creating client props and parenting them to the main entity like this: // In cl_init ENT:Initialize() block. local Funnel = ents.CreateClientProp("prop_dynamic");   Funnel:SetModel("models/hunter/tubes/tube4x4x1to2x2.mdl");   Funnel:SetModelScale(0.25)     Funnel:SetPos(self:GetPos()+(self:GetUp()*35));     Funnel:SetMaterial("phoenix_storms/concrete0")     Funnel:SetAngles(self:GetAngles()+Angle(0, 0, 180));     Funnel:SetParent(self);     Funnel:Spawn(); Which works well, but occasionally the client props forget where they were attached and just group together in this big clump. https://i.imgur.com/HBUPMYi.jpg This happens seemingly randomly while playing, and I am not quite sure what the cause is, or how to fix it. It happens on every entity that I make using the above method, and it doesn't matter how complex the design - An entity with one client prop is affected the same way as an entity with 20. If anyone has come across this issue before and knows of a solution then I would be exremely grateful. Thanks!
I'm not sure if this will actually fix your issues, but here are 2 things that you should be doing regardless: Use Entity:LocalToWorld and Entity:LocalToWorldAngles instead of messing around with GetUp() and all that jazz. It's more readable, it's easier to tweak, just use it. Use ClientsideModel instead of ents.CreateClientProp. My understanding is that CreateClientProp creates a physical prop while ClientsideModel creates just the renderable model with no attached physics model. You don't need the physics anyway since you're parenting it to a real entity. This actually might be the source of your issue, though I kind of doubt it is.
While I am not sure if this has fixed my issue or not, it has certainly made my code a lot cleaner and more efficient. Thank you!
im trying to make a police system using VJBase and i ran into a big problem i have a global table of wanted players and i am using this on the SNPC function ENT:CustomOnThink()    self.VJ_AddCertainEntityAsEnemy = PNPC_Wanted_Players  end as you can guess the PNPC_Wanted_Players is from my system the problem is that when i try to do it like this the players gets inserted into the table multiple times which doesnt happen if i use table.merge but if i use that the npcs wont know when the players not in the table so they will continue to attack.
All depends on where you're doing it. Show us some code.
I asked if theres a way to check if a FUNC_TANK is active using Lua. I also want to know if theres a way to check if the turret npc's are active. Without knowing this, the thing I'm making will deactivate then reactivate them even if they weren't active in the first place
I have no idea why this isn't working. I tested this addon with a lad in a peer-to-peer server, but only the host can execute the function "MSCSwear" so that the other player can hear the sound. When the non-host player tries to do that it is done on client side for some reason. Might also be that only the first player on the server can properly do it, not sure since the host is always the one who connects first. if ( CLIENT ) then CreateClientConVar( "cl_msc_swearpitch", "100", true, true ) end function MSCSwear( ply, line ) if not ply:Alive() then return end local pitch = ply:GetInfoNum( "cl_msc_swearpitch", 100 ) local playline = MscLines[line] local desibels = playline.loudness local subtitle = playline.text local linelength = playline.length -- other players hear this only when executed by the hosting player ply:EmitSound ( playline.directory, desibels, pitch, 1, CHAN_VOICE ) if ( SERVER ) then net.Start( "MSCsubtitles" ) net.WriteString ( subtitle ) net.Send( ply ) timer.Simple( linelength * 1.5, function()  net.Start( "MSCsubtitles" ) net.WriteString ( "" ) net.Send( ply ) end ) end end local function MSCRandomline(ply, com, args) MSCSwear ( ply, math.random( 1, 16 ) ) end -- this is the command we used to call the function above concommand.Add( "msc_swear", MSCRandomline ) Heres a link to the full code if this isn't enough: [Lua] Garbage Another link to a (un)related clientside code: [Lua] Clientside Garbage
How can I return the vector only?: Entity
local v = ent:GetBonePosition return v
In the case you only want the first return, you can do return (ent:GetBonePosition())
Lua nub here but somehow this looks simple to me. Entity:GetBonePosition returns two values; a Vector and an Angle. code_gs has a one up on me here, but this should get you both variables: local vec, ang = ent:GetBonePosition(n) So... if code_gs is correct, then you just won't get angle that way. What I wrote returns both vector and angle, but if all you want is vector hmm. I'm actually thinking this out as I type it to be honest. It makes me ask a question of NeatNit and code_gs. Wouldn't just doing local v = ent:GetBonePosition return a table? {vector=vec,angle=ang}?
Both of those would return a Vector, since you are only assigning the first return value of GetBonePosition, which is a Vector. The parentheses don't do anything, it just makes code look neater sometimes
Yes but not in the way you're expecting it to. Lua functions can have multiple return values, however you can't store multiple returns in a single variable (side from storing them in a table etc). local function test() return 1, 2 end local a = test() print(a) -- We only get "1" printed because we only stored the first return value local a, b = test() print(a, b) -- We get "1" and "2" printed because we've stored both the return values print(test()) -- This is the same as the above, test is returning 2 values and we're passing them as arguments to print -- Now, to only print the first return value without using variables we could do print((test())) -- Notice we wrap the test call in parentheses which forces it into an expression which will return only the first value I'm guessing you mean in the way they were used here they don't matter, if not then no. Parentheses can be used to force a variable list of arguments into only the first one.
Wow I did not know that, thanks for the information
Im trying to make a system that will save some strings on a table in the player object but when i create it like this ply.SomeRandomTable= {} it sometimes works and sometimes doesnt.Generally doesnt work the reason i dont use file.write or SetPData is i want the data to be temporary and manually handling a mass table just seems inefficient to me.I also tried defineing a class based on player_default class and creating the table in there and assigning it to the player but that didnt work at all.I dug a lot of old posts about netvars and classes but these threads just confused me more im kinda obsessed about optimization so please help. I dont wanna be spoonfed i just want to be pointed in the right direction for this.
Would anyone happen to know how I may be able to detect if a player is receiving a weapon through the fadmin command /giveweapon?
Sorry, you need to Log In to post a reply to this thread.