• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
Still wondering why theres no DMG_FREEZE or DMG_SLOWFREEZE in Garry's Mod. In Hammer editor, I have the properties of a trigger_hurt entity open right now. One of the damage types is FREEZE, and another is SLOWFREEZE. Why don't these seem to exist in gmod lua? SLOWFREEZE sets the damagetype value to 4194304 and FREEZE sets it to 16. I don't know if there's any relation at all, but the dmg enums list on the wiki says 16 is DMG_VEHICLE and 4194304 is DMG_REMOVENORAGDOLL
I'm getting an unfinished string error on line 41. I can't seem to spot anything out of the ordinary. Can any of you help me out? [code] ------------------------------------------------{- -- Initialization  -- ------------------------------------------------}- util.AddNetworkString("PrintMSG") local normal = Color(255, 165, 0) local person = Color(160, 82, 45) ------------------------------------------------{- -- META FUNCTION: Print Custom Message -- ------------------------------------------------}- local pl = FindMetaTable("Player") function pl:PrintCustomMessage(...) net.Start("PrintMSG") net.WriteTable({...}) net.Send(self) end ------------------------------------------------{- -- FUNCTION: Send Request To Player -- ------------------------------------------------}- local function SendRequestToPlayer(sender, requested) requested:SetNWString("PlayerRequesting", sender:Name()) requested:SetNWBool("HasRequest", true) sender:SetNWString("PlayerSending", requested:Name()) sender:SetNWBool("SentRequest", true) end ------------------------------------------------{- -- FUNCTION: Send Request -- ------------------------------------------------}- hook.Add("PlayerSay", "TPA", function(ply, text) if not ply:IsValid() or not ply:IsPlayer() then return end if(string.sub(string.lower(text), 1, 4) == "/tpa") then for k,v in pairs(player.GetAll()) do if(string.sub(text, 5) == v:Name()) then SendRequestToPlayer(ply, v:Name()) v:PrintCustomMessage(person, ply:Name(), normal, "has sent you a TPA request. Type /tpaa to accept,  or /tpad to deny.")  ply:PrintCustomMessage(normal, "You have sent ",  person, v:Name(), normal, "a TPA request. Type /tpac to cancel.") end end end end) ------------------------------------------------{- -- FUNCTION: Message Player -- ------------------------------------------------}- hook.Add("PlayerInitialSpawn", "MessagePlayerOnJoin", function(ply) ply:PrintCustomMessage(normal, "This server is using ", person, "Dr.Seagulls TPA mod.") end) [/code]
Because DMG_FREEZE and DMG_SLOWFREEZE are HL1 things, but you exect them in HL2. https://github.com/ValveSoftware/halflife/blob/master/cl_dll/health.h#L39 https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/game/shared/shareddefs.h#L403
Half-Life Source?
https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/server/hl1/hl1_player.cpp#L30 https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/client/hl1/hl1_hud_damagetiles.cpp#L164
I think this is a linux issue with autorefresh. You can probably safely ignore it; everything seems to work perfectly fine when this happens.
Im very very new to lua and i've been trying to use surface.PlaySound but i keep getting attempt to index global a nil value for "surface." im currently too stupid to figure out how to fix it too
Sometimes you just need a second set of eyes to look at the problem. I can't tell you how many times I've started shouting out loud to my co worker about a problem I've been working on for 20 minutes and solve it mid-rant. Anyway, your issue is you're calling the surface library on the serverside. That library only exists on the clientside.
d'oh bugger me thanks! Gotta learn some time :P
#define DMG_FREEZE DMG_VEHICLE #define DMG_SLOWFREEZE DMG_DISSOLVE Ok... I guess this explains why DMG_DISSOLVE does considerably less damage to health than it does to armor lol. I was hoping there was something better but I guess not. Thanks for the references
You will have to due to how the armour system is implemented. There's nothing wrong with using SetHealth/SetArmor - that's how damage is applied internally, anyway.
Here's the part that confuses me. Some things don't do a full 1 HP of damage, but taking enough will eventually add up to 1. I thought HP and AP worked on integer systems but that suggests a hidden float value. I don't think I can SetHealth to float values though... Oh well. I've found something that works for what I wanted.
https://github.com/VSES/SourceEngine2007/blob/master/se2007/game/server/baseentity.h#L1057 All integers. CBaseEntity::TakeHealth accepts a float for the damage to take, but it's implicitly converted to an int thru addition.
Which is why it confuses me taking 0.1 damage 10 times will remove 1 HP, but taking 0.1 damage 9 times wont. I didn't bother to click, tho. Anyway I have another problem. How could I write bullet penetration code? That is, when a bullet hits a wall I want it to go through the wall if it's thin enough. I started with this: local penetPower = math.min(DMG/180,1)/180 -- Max 180 local remPower = math.max(0,DMG-180)/54 -- Max 234-180=54 local Penetrace = util.TraceLine( { start = tr.HitPos+( tr.Normal ), endpos = tr.HitPos+( tr.Normal * (4+(penetPower*16)+(remPower*10)) ), -- Max Penetration would be 30 filter = {}, ignoreworld = true } ) local LeftSolid = Penetrace.FractionLeftSolid print("LeftSolid: "..LeftSolid) I wrote that and tested. I always get "LeftSolid: 0" so I'm sure I'm starting wrong.
Could someone possibly explain what exactly Player:KillSilent() does and how it differs from Player:Kill()? I know it calls the GM:PlayerSilentDeath hook instead but what exactly is different? My guess (and correct me if I’m wrong) is that for any death but from Player.KillSilent, every player on the server is informed that someone died. For a silent kill nobody knows and is able to find out?
I'm trying to save and load vectors into a table but don't know how to extract the key/value data like table[1].x , table[1].y etc. I'm pretty sure I'm not saving information to the table the correct way but any help is appreciated. What I'm doing is using a SWEP to place and save spawn locations for a map config, saving the table to a JSON string and loading/converting back to a table. Everything works! But I don't know how to get the values from each key back into a vector. local spawn_pos = {} function SWEP:PrimaryAttack() -- making the vectors and adding to a table called spawn_pos     local tr = self.Owner:GetEyeTrace()     if ( tr.HitNonWorld ) then return end     if ( IsFirstTimePredicted() ) then         if !table.HasValue(spawn_pos,tr.HitPos) then -- no two vectors will be the same             table.insert(spawn_pos,tr.HitPos)         end     end end -- Further in the code within the secondary fire function save_btn.DoClick = function() newsave = util.TableToJSON(spawn_pos) if !file.Exists( "tast/"..game.GetMap()..".txt", "DATA" ) then file.Write("tast/"..game.GetMap()..".txt", newsave ) else file.Write( "tast/"..game.GetMap()..".txt", newsave ) end end -- init.lua loading mapname.txt and reading converting back into a table if file.Exists( "tast/"..game.GetMap()..".txt", "DATA" ) then loadsave = file.Read( "tast/"..game.GetMap()..".txt", "DATA" ) currsave = util.JSONToTable(loadsave) PrintTable(currsave) -- My original data is back key/value but I don't know how to get the values back into vectors for setting positions like example currsave[1].x currsave[1].y end
Really, if you strip away all Lua code, Kill and KillSilent are just two different options that call different hooks. The base Lua code is what makes it "silent," and thus won't display a kill notification also done in Lua.
I swear I tried that already.. *facepalm* Thanks code_gs concommand.Add("REMOVE",function( ply )     if ply:IsAdmin() then         if file.Exists( "tast/"..game.GetMap()..".txt", "DATA" ) then             loadsave = file.Read( "tast/"..game.GetMap()..".txt", "DATA" )             currsave = util.JSONToTable(loadsave)             local vec = currsave[1]             PrintTable(currsave)             print("------------------------")             print(vec.y)         end     end end) -- Console Output ] REMOVE 1    =    7.724800 -13.564000 -12799.968750 2    =    -14.042800 48.442501 -12799.968750 3    =    -4.239200 160.339203 -12799.968750 4    =    94.036697 201.022507 -12799.968750 5    =    131.300995 133.809097 -12799.968750 6    =    83.596397 106.443703 -12799.968750 ------------------------ -13.5640001297
Quick question i made a menu with different checkboxes but thay all start checked is there any way i can make then start unchecked? I know you can i just can't seem to find anything about it? So for example i would like this to start unchecked panel:AddControl("CheckBox", { Label = "Show wireframes", Command = "mat_wireframe 1", })
You should be using http://wiki.garrysmod.com/page/Category:DForm instead of ControlPanel. But if you want to use ControlPanel, just do this: local check = panel:AddControl("CheckBox", { Label = "Show wireframes", Command = "mat_wireframe 1", }) check:SetChecked(true)
I guess I'll change my question from 'How do I do bullet penetration' to 'how do I trace through a solid object?' With my attempt: local penetPower = math.min(DMG/180,1)/180 -- Max 180 local remPower = math.max(0,DMG-180)/54 -- Max 234-180=54 local Penetrace = util.TraceLine( { start = tr.HitPos+( tr.Normal ), endpos = tr.HitPos+( tr.Normal * (4+(penetPower*16)+(remPower*10)) ), -- Max Penetration would be 30 filter = {}, ignoreworld = true } ) local LeftSolid = Penetrace.FractionLeftSolid print("LeftSolid: "..LeftSolid) it always prints "LeftSolid: 0", which I assume means it's not tracing through the solid, but instead stopping where it begins, since it's already in a solid object. Furthermore, I am only tracing through world objects. (which is why I thought ignoreworld would help) I'm trying to calculate at what point the trace exits the solid, if that wasn't clear, which is impossible if the trace doesn't even go through the solid.
I recommend using a loop to test the contents of a point until you're through the wall, then tracing from there. local maxThiccness = 20 --max distance to penetrate through a wall local hitPos = Vector() --the end of your original trace, wherever it landed local dir = Vector() --the direction of your original trace. for dist=0, maxThiccness, .5 do if bit.band(util.PointContents(hitPos + dir * dist), CONTENTS_EMPTY) == CONTENTS_EMPTY then --we've made it through the wall. --do our trace from the other end of the wall ([hitPos + dir * dist] is the startpos.) end end
You can avoid that since the area between walls is non-solid, and just trace starting a little inside the wall.
The exact issue, though. There's a value "FractionLeftSolid" which, according to the wiki, states the fraction of the trace where the trace exits a solid. The issue is, I'm trying to use that and I always get 0.
Anyone have any link references on how to do/use the headcrab canister entity in lua ? I'm searching Github but can't find anything.
Is there any way to get a spherical trace like in other game engines, or are lines and aabb hulls all we have?
There used to be a headcrab canister launcher swep. You'd point at a location and click, and a canister would come down. Steam Workshop Extract that and you can rummage through its code to find out how they did it
That's all that's available.
Maybe FractionLeftSolid doesn't work if you have ignoreworld = true since it never cared about the solid world anyway.
That's a good thought, but the only reason I put it there was because I was getting 0 lol
Sorry, you need to Log In to post a reply to this thread.