You can use add a BuildBonePositions callback in Deploy and remove it in Holster. You will have to network to the client to add the callback since those methods aren't guaranteed to always be called clientside.
Thanks man, ill try that.
My entity is on a base that has ENT.SomeVar = true.
If I do
[code]print(scripted_ents.Get("my_ent").SomeVar)[/code]
I get true.
if I do
[code]for entClass, entInfo in pairs(scripted_ents.GetList()) do
if entClass == "my_ent" then
print(entInfo.SomeVar)
end
end[/code]
I get nil.
Also if I do print(entinfo.t.SomeVar) I still get nil, excepted for on the base entity.
scripted_ents.GetList only returns the ENT tables, however scripted_ents.Get returns the ENT table merged with all the base class functions (as noted on the wiki). Entities themselves do this searching when they're created.
Using NetworkVars or NW2Vars is fine, the engine won't network every tick. Just make sure you set it shared to prevent prediction errors.
I'm not sure if this will fix your issue, but instead of manually saving the older render target and setting the render target after your renderview, try using.
render.PushRenderTarget
render.PopRenderTarget
These are generally more stable so it might get it to work properly.
Uh... so I've gone through a few different steps trying to debug why my zombies' max health isn't being updated. I commented out all print functions that were working.
In other words, if the print function isn't commented out that's because I've never seen it print.
function ZombieMaxHealthify()
-- print("ZMH")
for k, v in pairs(ents.GetAll()) do
local z = v
local class = z:GetClass()
-- print("Ent Spam Lul"..class)
if class == "worldspawn" then return end
print(z:GetClass())
if ( not (string.find( string.lower(class), "crab", 1 ) or string.find( string.lower(class), "zombi", 1 )) ) or string.find( string.lower(class), "pois", 1 ) then return end
if z:Health() > z:GetMaxHealth() then z:SetMaxHealth(z:Health()) end
print("Success!")
end
end
So... I put
if class == "worldspawn" then return end
in because that was the only class I saw in the console.
So my question: Why is for loop ONLY finding worldspawn and no other entities?
It's being called from a think hook:
hook.Add( "Think", "ThisIsSomethingUniqueLUL", function()
ZombieMaxHealthify()
return returns from the function, thus exiting the loop. You'll either want to use goto/labels or the continue keyword.
"if possible" ... it's not possible yet, but in time it will be. Thanks.
for k, v in pairs(ents.GetAll()) do;
local z = v;
local class = z:GetClass();
-- print("Ent Spam Lul"..class);
if class == "worldspawn" then continue end;
print(z:GetClass())
added the ; to be sure the {} formatting thing didn't squish it together.
I spawn npc_zombie but it never prints npc_zombie so my problem still exists
You have another return on the line below that.
I remember a while ago I created a weapon that shot combine balls. I was having difficulty getting the balls to be the right size. There was some sort of way that I changed some engine variables to get it working, if I remember right, but I don't remember how I did that.
Then my question becomes, is there something I can do with zombies to force their movement type? The way they slump around and such? Some animations are faster than others. (for instance, forcing zombie soldiers to always run, forcing them to pull out a grenade, or just forcing a regular zombie to use its fastest movement animation)
I'm dying over here. None of these print, yet the new insert is being properly added to the SQL table. All I'm trying to do is get the auto increment ID of the item I just inserted, but none of these are returning anything after I run the query.
local q = Game_DB:query(string.format("INSERT INTO `Ammo_DB` ( `Amount` ) VALUES ( '%s' )",
Game_DB:escape(tostring(amount))
))
q.onAborted = function(q)print("Aborted")
print(q)
end
q.onSuccess = function(q, data)
print("success")
print(q)
end
q.onData = function(q, data)
print("data found")
print(q, data)
end
q.onError = function(q, err, sql)
print("error")
print(q, err, sql)
end
q:start()
Alright... I'm not good at making gamemodes and I'm too lazy to look up the tutorials at the moment. I'll look up the tutorials later though. Why did I say that? Well...
I'm creating SWEPS and Autorun scripts so I can test things in Sandbox, things that will matter for my gamemode when I do manage to make it. The following code doesn't do what I wanted it to do.
cvars.AddChangeCallback( "ddl_zedlvl", function( cvname, lastLevel, cLevel )
local goalLevel = math.max( tonumber(cLevel), 0 );
local zedHealth = GetConVar("sk_zombie_health");
if goalLevel < 11 then zedHealth:SetInt(50*goalLevel);
else zedHealth:SetInt(math.floor(500*math.pow(1.05,goalLevel-10)));
end
The semicolons are not in the actual code...
There are more variables I tried to change, other health variables in the console. None of them seem to change, so... how can I get them to change?
Set their health as soon as they are created in GM/OnEntityCreated
Wow... that's exactly the function I was trying to find last night. How did I miss that?
https://static-cdn.jtvnw.net/emoticons/v1/360/1.0
Thank you!!
Interesting...
] setzedlvl 50
Forcing Stats for Survival Level 50
zNewLevel < 51 (50)
Fast Zombie spawned, setting health based on level 50
but NewHP = 266
NPC npc_fastzombie stuck in wall--level design error at (3163.20 -483.98 -447.97)
zNewLevel < 51 (50)
Fast Zombie spawned, setting health based on level 50
but NewHP = 266
(then I killed it)
(I did not spawn another)
zNewLevel < 51 (50)
Fast Zombie spawned, setting health based on level 50
but NewHP = 266
I don't get why it's printing after I kill the zombie...
So... shortly after 2,000,000,000 (2 billion) to 2,200,000,000 (2.2 Billion) I've noticed... Npc health values flip to be negative until shooting them, then capped at some number in that range. I haven't been getting the same number in my tests which is why I'm giving a range.
Why would an NPC have this much health? Well, with my zombie related gamemode ideas their health just keeps going up with each round... and while it won't be until hundreds of rounds in that this number would be reached, I don't want to abandon the idea despite how unlikely it is that anyone would ever get to that high of a round alone, or even in a squad of 4 (or maybe more) (let alone even play my gamemode...)
Mainly I want to know, why do the numbers start going negative? Especially considering that "Infinity" is 2^1024 which is a number I can't get any digital calculator to tell me... 2 billion is nowhere near that large.
Health is networked as a 32 bit signed integer, thus the high limit is 2^31-1 or 2147483647. It wraps around because this is how integer arithmetic works and the result is called an integer overflow.
The reason your "Infinity" number is 2^1024 (really 2 ^ 1023), is because that's a floating point number of type double.
Anyone know how I can use Lua and control points to change particle effect systems, such as the size or color of a 'fire' effect?
I'm having a terrible time with ents.findinbox ents.FindInBox
I'm trying to to make it so it draws a rectangle in front of a car. So as the car moves new zombies can be found. This is what i've tried
local x = jeep:GetPos().x
local y = jeep:GetPos().y
ents.FindInBox(Vector(x,0, 0) + Vector(-8584.15, 13658.57, 1066.03) , Vector(x,0, 0) + Vector(-9089.27, 13651.65, 1044.29) )
However nothing ever gets found in this box. I SUCK with XYZ so i'd appreciate a hand please
If you're getting a box in front of a jeep, why have you locked the vectors to a specific area?
I fixed it anyway thanks
What's the worst-case scenario that can arise from spawning about 100 entities at once that are all present at the same time?
I'm trying to make a functional chess board, and I'm just doing dumb shit and I'm wondering if this would be a viable way to do stuff.
Anyone know how to make a DModelPanel parented to a DPanel which is parented to a DIconLayout appear properly? They seem to not work well together and the model only appears for about a frame or so before becoming no longer visible. I've checked that the size, pos, zpos, and parent were all still properly set after PerformLayout finished its thing but still cant figure it out. Mind you the same thing works fine if I use a DImage, DLabel, etc. Its just DModelPanel.
Could you improve efficiency by using a pre-compiled C function instead of an interpreted Lua function
for even general arithmatical operations?
I take that the physics sound scripts from gmod have a hard coded set channel, meaning there is no way of say, making a step sound set to CHAN_STATIC?
Turns out I was cleaning up all clientside models without a parent in my other addon and it was fucking lots of things up! Oops.
[</DLib>] addons/MyAddon/lua/autorun/ddl_plystats.lua:7: attempt to index field "GetNWFloat" of a nil value (probably (*temporary)?)
1. error - [C]:-1
2. __index - lua/dlib/core/funclib.lua:39
3. GetStamina - addons/MyAddon/lua/autorun/ddl_plystats.lua:7
4. nextevent - addons/MyAddon/lua/autorun/ddl_plystats.lua:36
5. unknown - lua/dlib/modules/hook.lua:573
Line 36:
local cStamina = ply:GetStamina()
Line 5 through 9:
function PLAYER:GetStamina()
local plr = self.Player
if !plr:GetNWFloat("ddlStamina") then plr:SetNWFloat("ddlStamina",100) end;
return plr:GetNWFloat("ddlStamina",0)
end
Line 2:
local PLAYER = FindMetaTable( "Player" )
So... What did I do wrong?
Make sure that ply variable at line 36 is valid since it seems like it is referring to an invalid player. Also you don't use SetupDataTable on players and you also don't use it for NWVars. You use SetupDataTable on entities with NetworkVar.
Well the function seems to exist for Players, Entities, and Weapons. I suppose each is in a way an Entity, but that still includes Players.
PLAYER/SetupDataTables
ENTITY/SetupDataTables
WEAPON/SetupDataTables
Sorry, you need to Log In to post a reply to this thread.