• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=keeperman;49639828][URL]https://facepunch.com/showthread.php?t=1192696&p=36482713&viewfull=1#post36482713[/URL] [editline]31st January 2016[/editline] I get an error whenever I call the DTBool on an entity in the world through a autorun script. attempt to call method 'GetDTBool' (a nil value) [code]local entity = ents.FindByClass("entity") local bool1 = entity:GetDTBool(0) local bool2 = entity:GetDTBool(2) if bool1 and not bool2 then --code end[/code][/QUOTE] FindByClass returns a table of entities, not just one.
:snip: nevermind
You know how when you look around in game your player model turns with it (not just his head, the whole body), how can I do that in lua? Ent:SetAngle() doesn't seem to be doing anything. I'm trying to do this to a clientside model btw.
Any way to force my hud under the default darkrp scoreboard? Already using SetZPos and ParentToHUD on the root hud elements.
[QUOTE=Kogitsune;49640588]FindByClass returns a table of entities, not just one.[/QUOTE] oh ok, how do I get the variable of each of them?
[QUOTE=keeperman;49642381]oh ok, how do I get the variable of each of them?[/QUOTE] You loop through them.
I'm trying to make my accessories file less large using loops to do most of the work for me. For some reason this doesn't work and I'm not quite sure why. (unexpected symbol near 'for') Example: [code] Accessories = { for i=0, 4 do ["beanie2_gta_skin" ..tostring(i)] = { type = "Model", model = "models/modified/hat04.mdl", bone = "ValveBiped.Bip01_Head1", rel = "", pos = Vector(5.714, -2, 0), angle = Angle(0, -74, -90), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = i, bodygroup = {} }, end } [/code]
[QUOTE=kpjVideo;49643471]:snip:[/QUOTE] You can't include a for loop to a table. Do it outside the table. [CODE]for i=0, 4 do Accessories["beanie2_gta_skin" ..i] = { type = "Model", model = "models/modified/hat04.mdl", bone = "ValveBiped.Bip01_Head1", rel = "", pos = Vector(5.714, -2, 0), angle = Angle(0, -74, -90), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = i, bodygroup = {} }, end[/CODE] Note: most of the time you can just concatenate numbers without tostring
[QUOTE=BillyOnWiiU;49643478]You can't include a for loop to a table. Do it outside the table.[/QUOTE] -snip- Thanks man :3
[QUOTE=kpjVideo;49643482]-snip- Thanks man :3[/QUOTE] [code] Accessories = { Data = { } } function Accessories:Define( name, data ) --Validate the input - set defaults that are missing, etc --Then, self.Data[ name ] = data end function Accessories:Exists( name ) return self.Data[ name ] ~= nil end function Accessories:GetField( name, field ) if not self:Exists( name ) then return else return self.Data[ name ][ field ] end end for i = 0, 4 do Accessories:Define( "beanie2_gta_skin" .. i, { type = ... } ) end[/code] Something like that would probably work. Abstract away directly touching the data, make helper functions to improve quality of life, etc. Also, :ninja:'d for longer reply.
-snip- apparently, I was running DX 7, just used -dxlevel 98 in start up commands.
Can anyone explain what I'm doing wrong? [code] local entity = ents.FindByClass("entity") for k, v in pairs( entity ) do local bool2 = entity:GetDTBool(2) local bool1 = entity:GetDTBool(0) end[/code]
[QUOTE=keeperman;49649848]Can anyone explain what I'm doing wrong? [code] local entity = ents.FindByClass("entity") for k, v in pairs( entity ) do local bool2 = entity:GetDTBool(2) local bool1 = entity:GetDTBool(0) end[/code][/QUOTE] In this code entity is your table and v is your value from the table, so replace entity with v within the loop.
I have a problem. Every time I do npc:AddEntityRelationship( player, D_HT, 0 ), the enemy will completely ignore other NPC's, an he will only try to kill the player. Even if I enable ai_ignoreplayers and then I disable it, the enemy will target the player again. Changing the priority doesn't seems to do anything. Any ideas?
[QUOTE=bigdogmat;49650104]In this code entity is your table and v is your value from the table, so replace entity with v within the loop.[/QUOTE] oh yea thanks The entity doesn't pass on the boolean so it just says false even though it should be true
Slight bump on this - Ethics aside (assuming there's a disclaimer and such), how effective is render.Capture at detecting hacks? Are there any effective/known ways of avoiding it or are their choices to return nothing or garbage?
Is there anyway to allow a player to see around their entire body left and right but not up and down? Similar to how prisoner pods work in a CalcView. -sorry for so many posts in this thread recently, hopefully last thing I'll need to ask for :3-
Having an issues was making items on pointshop2 then i got this error! " [ERROR] lua/vgui/dimage.lua:153: attempt to index local 'Mat' (a nil value) FixVertexLitMaterial - lua/vgui/dimage.lua:153 SetImage - lua/vgui/dimage.lua:131 SetItem - addons/pointshop2/lua/ps2/modules/pointshop2/hat/cl_dpointshophatinvicon.lua:19 getCrashsafeIcon - addons/pointshop2/lua/kinv/items/pointshop/sh_base_hat.lua:159 unknown - addons/pointshop2/lua/kinv/client/cl_ditem.lua:168 " The point shop won't close now and it lags the game its also unuseable any help would be great!
Is there a hook or way to run code once the player is 100% done connecting, after they loaded all of the player entities.
Run a function, if the LocalPlayer() it's not valid, then run a timer inside linked into the function parsing the player as argument
[QUOTE=YourStalker;49653218]Is there a hook or way to run code once the player is 100% done connecting, after they loaded all of the player entities.[/QUOTE] [CODE]hook.Add( "InitPostEntity", "something", function() ply = LocalPlayer() -- Do stuff end )[/CODE]
[QUOTE=MaxShadow;49653478][/QUOTE] Players aren't 100% loaded in that
[QUOTE=YourStalker;49653679]Players aren't 100% loaded in that[/QUOTE] I believe Acecool made something that added a hook called PlayerFullyConnected. Sadly I think the links died, but his explanation may be of use: [url]https://facepunch.com/showthread.php?t=1416484[/url]
Trying to make this SWEP be useable two times for the whole team. How I'm doing this is I'm counting the number of traitors and adding 2. However, when I try to print the values in console, they return nil. Any ideas? Here's where I print my values... [code] function SWEP:PrimaryAttack() print (numberOfTraitors) print (numberTefibLimit) if CLIENT then return end local tr = util.TraceLine({ start = self.Owner:EyePos(), endpos = self.Owner:EyePos() + self.Owner:GetAimVector() * 80, filter = self.Owner }) if IsValid(tr.Entity) and tr.Entity:GetClass() == "prop_ragdoll" then if not tr.Entity.uqid then self:FireError("FAILURE - SUBJECT BRAINDEAD") return end local ply = player.GetByUniqueID(tr.Entity.uqid) if IsValid(ply) then self:BeginDefib(ply, tr.Entity) else self:FireError("FAILURE - SUBJECT BRAINDEAD") return end else self:FireError("FAILURE - INVALID TARGET") end end [/code] Here's my code for the numbers check. [code] if (SERVER) then hook.Add( "TTTBeginRound", "NumberOfTypes", function() local numberOfTraitors = 0 local numberOfPlayers = 0 for k, v in pairs( player.GetAll() ) do if v:IsTraitor() and v:Alive() then numberOfTraitors=numberOfTraitors+1 end if v:Alive() and !v:IsSpec() then numberOfPlayers=numberOfPlayers+1 end end timer.Simple( .5, function() PrintMessage( HUD_PRINTTALK, "Traitors: "..numberOfTraitors ) PrintMessage( HUD_PRINTTALK, "Number of Players: "..numberOfPlayers ) end ) local numberTefibLimit = numberOfTraitors + 2 PrintMessage( HUD_PRINTTALK, "Number of Traitors Allowed: "..numberTefibLimit ) end ) end [/code] Here's my altered error message in Think... [code] function SWEP:Think() if CLIENT then return end if self:GetDefibState() == STATE_PROGRESS then if not IsValid(self.Owner) then self:FireError() return end if not (IsValid(self.TargetPly) and IsValid(self.TargetRagdoll)) then self:FireError("ERROR - SUBJECT BRAINDEAD") return end local tr = util.TraceLine({ start = self.Owner:EyePos(), endpos = self.Owner:EyePos() + self.Owner:GetAimVector() * 80, filter = self.Owner }) if tr.Entity ~= self.TargetRagdoll then self:FireError("ERROR - TARGET LOST") return end if numberOfTraitors == numberTefibLimit then self:FireError("ERROR - TOO MANY TRAITORS") return end if CurTime() >= self:GetDefibStartTime() + 5 then if self:HandleRespawn() then self:FireSuccess() else self:FireError("ERROR - INSUFFICIENT ROOM") return end end self:NextThink(CurTime()) return true end end [/code] And here's where I produce the amount of traitors and adding and stuff... [code] function SWEP:HandleRespawn() local ply, ragdoll = self.TargetPly, self.TargetRagdoll local spawnPos = self:FindPosition(self.Owner) if not spawnPos then return false end local credits = CORPSE.GetCredits(ragdoll, 0) local health = 50 if ragdoll:GetRole() == "ROLE_INNOCENT" or ragdoll:GetRole() == "ROLE_DETECTIVE" then numberOfTraitors = numberOfTraitors + 1 end ply:SpawnForRound(true) ply:SetCredits(credits) ply:SetRole(ROLE_TRAITOR) ply:SetHealth(health) SendFullStateUpdate() ply:SetPos(spawnPos) ply:SetEyeAngles(Angle(0, ragdoll:GetAngles().y, 0)) ragdoll:Remove() return true end [/code] If you need any addition code to help, I'll be more than happy to provide it.
the client doesn't load/init the other players until you get in their pvs onentitycreated is a really useful hook
I'm not getting any output in my server console. Wiki link [URL="http://wiki.garrysmod.com/page/GM/ShowSpare1"]ShowSpare1[/URL][LUA]if SERVER then hook.Add( "ShowSpare1", "fbkjftgi", function( ply ) print( "A player hit F3 ("..ply:SteamID()..")" ) end) end[/LUA]
The booleans always give me false even though it should be true [code] local entity = ents.FindByClass("entity") for k, v in pairs( entity ) do local bool1 = v:GetDTBool(2) local bool2 = v:GetDTBool(0) end[/code]
ez stuff from a noob with weapons: How do I play an ACT_ when doing primary attack, for everyone (not just client) to see? Do I really have to go for k,v in pairs(player.GetAll()) to execute clientside code on each of them for something like that? I think I've tried every single function with 'anim' on its name from the wiki, and none of them do anything when called serverside.
[QUOTE=Coment;49657717]ez stuff from a noob with weapons: How do I play an ACT_ when doing primary attack, for everyone (not just client) to see? Do I really have to go for k,v in pairs(player.GetAll()) to execute clientside code on each of them for something like that? I think I've tried every single function with 'anim' on its name from the wiki, and none of them do anything when called serverside.[/QUOTE] [url]https://wiki.garrysmod.com/page/Enums/GESTURE[/url]
[QUOTE=keeperman;49657754]run it through console?[/QUOTE] It's not one of the standard ones, but ACT_FLINCH_HEAD. (A shame, because it would've been a nice solution)
Sorry, you need to Log In to post a reply to this thread.