• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
I found latency between entity spawn and it apperaing on client. I have a .net msg to client with entity after entity spawning, but client sad that it was NULL. Is there's a fix to it? Or I need delay?
Delay, or create a queue system that keeps the net message data waiting until the entity is created.
It appears table.Merge does not copy sub-tables (if the destination is not a table) but merely hands over the reference to the table to dest[k]. How would I get about making sure that all tables are actually being deep cloned and being properly copied, I wrote this new function but it doesn't appear to work still. What am I miss? function table.NewMerge( dest, source )     for k, v in pairs( source ) do         if ( type( v ) == "table" && type( dest[ k ] ) == "table" ) then             -- don't overwrite one table with another             -- instead merge them recurisvely             table.NewMerge( dest[ k ], v )         else -- New Code             if (type( v ) == "table") then                 dest[k] = {};                 table.NewMerge( dest[k], v )                            end             dest[ k ] = v         end     end     return dest end
If you simply want a deep copy of a table use table.Copy, if not you'll have to explain what you want a bit more. The reason your edit above doesn't work is because you're still just setting the reference right below the if statement, move it into an else statement.
Good enough for me, the functionally I was looking for is for a cache system I'm working on so I want the cache to periodcally be updated and whatever wasn't in the cache to be sent to the player.
noise.xpos = math.Clamp(noise.xpos + math.random(-noiseRange, noiseRange), noise.originX - noiseRange, noise.originX + noiseRange) noise.ypos = math.Clamp(noise.ypos + math.random(-noiseRange, noiseRange), noise.originY - noiseRange, noise.originY + noiseRange) there's a bunch of boxes that are moved each frame either left or right and up are down. When there's a bunch of boxes, the noise appears in the shape of a square, however I want it to move more in a circular fashion. I'm not the best at math, so I'm having a hard time figuring this out. How could I make it so the boxes move in the shape of a circle?
Multiply the x and y components by the cosine and sine, respectedly of the angle you want the rotation to be. This csn be your random variable.
I will pay someone to figure this out (Seriously), I'm trying to find the difference between two tables. (It seems to work fine when I am one level deep and adds all the key/value pairs but once I recurse it just goes to shit. function table.FindDif( dif, tblA, tblB, parentDif, parentKey ) -- We look through Table A, Table A should have the most information. for k_tblA, v_tblA in pairs(tblA) do if (istable(v_tblA) && (istable(tblB[k_tblA]))) then if (dif == nil) then parentDif[parentKey] = {}; dif = parentDif[parentKey]; end table.MergeUncached( dif[k_tblA], v_tblA, tblB[k_tblA], dif, k_tblA ) if (dif && dif[k_tblA] && istable(dif[k_tblA]) && table.Count(dif[k_tblA])) then dif = nil; end else if (dif == nil) then parentDif[parentKey] = {}; dif = prev_dif[parentKey]; end if (tblB[k_tblA] == v_tblA) then continue; elseif (istable(v_tblA)) then dif[k_tblA] = table.Copy(v_tblA); else dif[k_tblA] = v_tblA; end end end end
In your dif sub-table, your first three checks are useless since you never set the table to nil, and you are doing no logical checks on the counted table. Really, if you just want to check the table is empty, you can just do: if (next(dif[k_tblA]) ~= nil) then
In a PreDrawHalos hook I am trying to pass a second render of an NPC's model. I don't want to create a duplicate model and align the bones etc if I don't have to... it looks like this: v:SetModelScale(1+.05*sS) v:SetupBones() halo.Add( {v}, sC, 4*sI, 4*sI, sP, true ) v:SetMaterial(sM,true) -- v:SetColor(sC) v:DrawModel() Which is wrapped within other functions, if statements, for loop(s). The halo's draw nicely, but the model doesn't draw at all. Earlier these are set: local shield = v:ddlGetShield() local sI = 0 -- shield Intensity local s = 1 -- shield Scale local sP = 5 -- shield Passes local sL = ( shield / shieldDefault[x] ) -- shield Level local sM = Material("models/alyx/emptool_glow.vmt") -- shield Material local sC = Color(255,255,255) local hitDiff = math.max( CurTime() - lastHurt, 0 ) Those variables are changed later. Why won't my model render?
Since the latest Garry's Mod update, I've seen problems in regard to CS:S world models on SWEPs, they're not rigging correctly and I'm not too sure as to why, is anyone else sharing this problem, and if so - is there any fix to this problem? https://cdn.discordapp.com/attachments/360750875087470593/423185309585637376/image.png
Are entity indices reused at somepoint? if so, how do I get a truly unique ID for an entity?
Yes if the slot is vacant. If it's map created, you can use Entity/MapCreationID, otherwise, the actual entity object acts as a unique handle.
If you truly need an id for it, Entity/GetCreationID
I'm not quite sure why I didn't think to ask here first. https://gmod.facepunch.com/f/gmoddev/rwmp/On-the-solving-of-higher-degree-polynomials/1/#unseen
Is there any way to fix this weird 3D2D stuff? I already tried using PreDrawOpaqueRenderables and PostDrawOpaqueRenderables. Are there any other hooks I could use? https://files.facepunch.com/forum/upload/185765/538af537-c3b7-4c5f-92e2-2f8684ba37ee/7b5b138328823232c5fe54f0bcf9bf8c.png
If this 3D2D is attached to an entity, you can do it in a SENT's Draw method.
It is not..
Then you should make it attached to some invisible SENT, since there's no way to implement non-entities into the standard render distance drawing.
That does fix it in most cases, but not in every case.. https://files.facepunch.com/forum/upload/185765/adc918d3-c326-470e-bd4e-c536ff55f29c/adb765983399b35fe6aa0c7bf85f5952.png
https://hastebin.com/nipohivigu.rb Can someone explain? (Everything here is serverside, and it's a brush entity) So after it sets up key values it's ok, it shows the whole table and it's contents. But after I print it in ENT:StartTouch() everything magically disappeared. How?
What is better for the performance (easier to compute) if x == 1000 then do_little_func end or if x >= 1000 then do_little_func end ? Additional info - this check will be running every minute on every player, x var is time spent on server.
Both use the fcomi instruction on x86 - they are the same speed.
Thanks c:
Back again. Wasn't exactly pretty but I nailed it. Tried the other approach but it made it even worse. So, I calculated the offset of all bones from bone 0, then moved everything to the target position + the offset calculated earlier. I made it a little prettier by using tables. Can't insert code because new facepunch update broke code inserts.
I have been working on a hud for my gamemode, (first time doing so) and whenever I alt tab all of my hud elements are set to their default values. My level is shown as 1, my xp bar is empty, but when i kill an enemy they are reverted back to what they should be. Anyone have any ideas?
Are bots sent net messages? Aka does the net library pretend to send bots net data?
No
Would it be more efficient to store a bunch of functions in a sequential table and then executing them all within a singular hook function (or) having a bunch of hook functions running on the same hook event?
Localizing functions like that eliminates hash table lookups which, yes, can save you some frame time. As for your hooks question, there may be something to be said about adding another loop to the hook call, but my confident answer would be that the difference in speed there would likely be negligible.
Sorry, you need to Log In to post a reply to this thread.