• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
How can I make a ragdoll sit on a chair? I'm thinking SetLocalPos to the parent chair but unsure how to get the ragdoll to sit in the position I want then get the local position. Maybe there's a better way?
[QUOTE=blackwidowman;52739948]How can I make a ragdoll sit on a chair? I'm thinking SetLocalPos to the parent chair but unsure how to get the ragdoll to sit in the position I want then get the local position. Maybe there's a better way?[/QUOTE] That's a tricky sort of question. It'd be great if you could play animations on ragdolls (such as a sitting animation for example), but then my death animation addon would've been finished 2 years ago. The only way I can think of doing it is by using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/PhysObj/SetPos]PhysObj:SetPos[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/PhysObj/SetAngles]PhysObj:SetAngles[/url] on each of the ragdoll's bones. However, this would probably differ from model to model. The other option is to just spawn them above the chair and hope they slump into it.
Hello, I have a perplexing issue, here it is in totality... I am creating a map that is based on the idea of recursion(things inside of things, inside of things, etc.). So I created the main play/build area outside of a middle cube like a cage/tank(this also borders the whole map) and inside that cube is the sky_camera, however you can see the play/build are from the sky_camera which place the play area in the skybox. The effect this creates is seeing anything you place also out in the skybox 64x it's normal size. So I am making an entity to package with the map, this entity redraws everything at 1/64th scale inside the center box/tank/cage. The method i'm using is creating a Client side model for each renderable entity, then drawing that model at 1/64th scale offset from the rerender entity. This seems to work fine for most things, except ragdolls / things with multiple bones entities (npc, vehicles, etc). All of the later are rendered in their basic pose for ragdolls and npc's it's a t-pose. Also for some odd reason some client entities are being flagged for crazy physics and being removed, specifically the front tires from the sCars cars, but they are still there so it's weird to drive with invisible tires. I've used the console commands to disable the crazy physics remove, but i don't know why this is happening. [b] To Summarize: Questions: [/b] 1. How to copy the bone angles from an entity to a client side model 2. Why things are getting crazy physics Here is my code, i've tried may things for the pose issues... [code] --rerender entity -- This entity will redraw all entities at 1/64th their original size include ("shared.lua") ENT.scale = 0.015625 -- 1/64 function ENT:Initialize() -- Set the renderbounds so it draws properly self:SetRenderBounds(Vector(-1024,-1024, -1024), Vector( 1024, 1024, 1024)) end function ENT:Draw() -- request a render of all opaque entities and entities marked both self:RenderStuff(RENDERGROUP_OPAQUE) end function ENT:DrawTranslucent() -- request a render of all translucent entities and entities marked both self:RenderStuff(RENDERGROUP_TRANSLUCENT) end function ENT:RenderStuff(rendGroup) -- Loop through all entities for k,ent in pairs(ents.GetAll()) do -- check entities validity if IsValid(ent) then -- make sure it's not ourselves, or a client side model, or the world. if ent != self && ent:GetClass() != "class C_BaseFlex" && !ent:IsWorld() then -- Check that it falls in to the proper render groups if (ent:GetRenderGroup() == rendGroup) || (ent:GetRenderGroup() == RENDERGROUP_BOTH) then -- Check if this entity already has a client side model for drawing, and if it does -- make sure it's valid if ent.csModel && IsValid(ent.csModel) then -- Setup a matrix to render the client model scaled down. local mat = Matrix() mat:SetAngles( ent:GetAngles()) -- mimic the current angles mat:Scale( Vector( self.scale, self.scale, self.scale ) ) -- set the proper scale mat:SetTranslation(self:GetPos() + (ent:GetPos() * self.scale)) -- translate world origin to our origin and scale position vector -- I'm trying this at the moment -- if I just let it render it'll be t-posed or frozen, but in the right spot and scale -- if it's a rag object setup it's bones first if ent.csModel.isRag then -- since it's the same model we just do a 1:1 copy of all bones -- take the position from the model so it doesn't change -- but modify the angle to copy entity it goes to. local boneCount = ent:GetBoneCount() for bIndex = 0, boneCount - 1 do local entBonePos, entBoneAng = ent:GetBonePosition(bIndex) local entModelPos, entModelAng = ent.csModel:GetBonePosition(bIndex) ent.csModel:SetBonePosition(bIndex, entModelPos, entBoneAng) --print("ent: " .. tostring(ent)) --print("entBonePos: " .. tostring(entBonePos)) --print("entBoneAng: " .. tostring(entBoneAng)) --print("model: " .. tostring(ent.csModel)) --print("entModelPos: " .. tostring(entModelPos)) --print("entModelAng: " .. tostring(entModelAng)) end end -- enable the matrix and render ent.csModel:EnableMatrix("RenderMultiply", mat) ent.csModel:DrawModel() ent.csModel:DisableMatrix("RenderMultiply") else -- this happens if there is no client side model for this entity -- first we get the model of the entity, one way or the other local entModel = ent:GetModel() or ent.model -- Check if the model string we have is not nil/empty/invalid/error if entModel != nil && entModel != "" && util.IsValidModel(entModel) && entModel != "models/error.mdl" then --It's a good model reference so create a client side model of it -- and attach it to the entities table. ent.csModel = ClientsideModel(entModel) ent.csModel.owner = ent -- Cross reference so the model know's who it goes to. ent.csModel:SetNoDraw(true) -- make sure we don't draw it till we want to. ent.csModel:SetSkin(ent:GetSkin()) -- set the skins to match -- Check if the model is a valid ragdoll (has multiple connect bones that can move/rotate) -- set .isRag accordingly if util.IsValidRagdoll(entModel) then ent.csModel.isRag = true else ent.csModel.isRag = false end -- this is a custom function that will check for the client side model being detached from it's entity. self:KillCSModelOnRemove(ent, ent.csModel) end end end end end end end function ENT:KillCSModelOnRemove(ent, csModel) -- check if entity is invalid if !IsValid(ent) then -- check if entity has a valid client side model if IsValid(csModel) then -- make sure the client side model has the Remove function (maybe over safe, but i had random errors) if csModel.Remove then -- Call Remove to kill the client side model, then bounce out so this doesn't repeat. csModel:Remove() return end end end -- If the entity is still valid then rerun ourself in 1 second to check again. timer.Simple(1, function() self:KillCSModelOnRemove(ent, csModel) end) end [/code] Any help is appreciated, thank you. [b] EDITED: [/b] Also I am swamped/spammed in the console with: SetBonePosition: Bone is unwriteable [b] EDITED: [/b] And just to be clear here's a video [video] [url]https://www.youtube.com/watch?v=E-R5KsT3NHk[/url] [/video]
Does setting 10 different variables to every single player impact performance in any way?
[QUOTE=Thiefdroid;52741941]Does setting 10 different variables to every single player impact performance in any way?[/QUOTE] Well, it runs __newindex 10 times per player. It totally depends on how often you are doing this, and even then your question of whether it "impact[s] performance" is still very vague. Actual code may help.
[QUOTE=code_gs;52741967]Well, it runs __newindex 10 times per player. It totally depends on how often you are doing this, and even then your question of whether it "impact[s] performance" is still very vague. Actual code may help.[/QUOTE] Well I'm making a script for my server that adds players to a list by setting variables to them when they do stuff like getting headshots, kill people through walls, snap their view in a very un-natural way etc. Is there a more effective way of doing this? (Also 10 is a bit of an over exaggeration as it will be max 5)
Just store the players in a list -- don't store the variables on them.
Either way I think the checks you have to do to decide when to set these variables makes the action of actually setting them pretty negligible, and the ones that are easier to determine (like headshot) are rare enough that it should never be noticable. Disclaimer: I could be wrong.
Hey guys, I'm not really confurtable with trace I want a trace to ignore 'things' with NODRAW texture and Skybox texture ... I tried to play with the masks without success ... [CODE] local trb = util.TraceLine( { start = ren.origin, endpos = ren.origin + ren.angles:Forward() * 10000, filter = function( ent ) if ( ent:GetClass() == "prop_physics") then return true end end, mask = MASK_VISIBLE } ) [/CODE] (When I print trb.HitTexture it tell me TOOLS/TOOLSNODRAW or the skybox texture)
Hey guys, I often play Sandbox with friends, and we often want to change server settings without asking our host to "quickly type sv_cheats 1" whilst he is working on something. We currently use a LUA script which the host executes to give everybody "superadmin", but we still can't execute stuff like sv_cheats 1, is there any user group or way to make everybody able to type server operator only commands?
You could write a console command that runs whatever is passed to it if a user is a super admin
[CODE] rdm = true mdr = false function DataInserter(firstjoiner) local playersteamid = firstjoiner:SteamID() if (mdr) then return end else print(playersteamid) end end hook.Add("PlayerInitialSpawn", "PlayerInitalSpawnFunc", DataInserter) [/CODE] Output: [ERROR] lua/autorun/testingthings.lua:12: 'end' expected (to close 'function' at line 5) near 'else' 1. unknown - lua/autorun/testingthings.lua So I've already googled a long time, and searched for syntax errors, but I just don't get it. I tried adding an "end" to after "else", before "else", an additional "end" at the end of the code and none of it worked. Happy for any help there is.
[QUOTE=Banana Lord.;52743500]You could write a console command that runs whatever is passed to it if a user is a super admin[/QUOTE] But everybody is Superadmin already, but Superadmins can't type server operator only commands
[QUOTE=Oly;52743505] Output: [ERROR] lua/autorun/testingthings.lua:12: 'end' expected (to close 'function' at line 5) near 'else' 1. unknown - lua/autorun/testingthings.lua So I've already googled a long time, and searched for syntax errors, but I just don't get it. I tried adding an "end" to after "else", before "else", an additional "end" at the end of the code and none of it worked. Happy for any help there is.[/QUOTE] [CODE] rdm = true mdr = false function DataInserter(firstjoiner) local playersteamid = firstjoiner:SteamID() if (mdr) then return else print(playersteamid) end end hook.Add("PlayerInitialSpawn", "PlayerInitalSpawnFunc", DataInserter) [/CODE] "if (mdr) then return [B]end[/B]" => you closed the if statement too early
[QUOTE=guigui30110;52743356]Hey guys, I'm not really confurtable with trace I want a trace to ignore 'things' with NODRAW texture and Skybox texture ... I tried to play with the masks without success ... [CODE] local trb = util.TraceLine( { start = ren.origin, endpos = ren.origin + ren.angles:Forward() * 10000, filter = function( ent ) if ( ent:GetClass() == "prop_physics") then return true end end, mask = MASK_VISIBLE } ) [/CODE] (When I print trb.HitTexture it tell me TOOLS/TOOLSNODRAW or the skybox texture)[/QUOTE] I don't think you can make traces work like that. Best solution would be if the trace hits a nodraw/skybox, retrace from the hit point of the previous trace and continue going.
How can I do the following? In this case I want it to print 26.2 [code] local tablez = { 12, 53, 2, 64 } local values = table.concat( tablez, "+" ) print(values/#tablez) -- Error (ofc) [/code] [B]Edit:[/B] Solved it. [code] local tablez = { 12, 53, 2, 64 } local value = 0 for i=1,#tablez do value=value+tablez[i] end print(value/(#tablez+1)) [/code]
[QUOTE=Gabs;52743510]But everybody is Superadmin already, but Superadmins can't type server operator only commands[/QUOTE] Right, I understand you. What I'm trying to say is writing something like this: [lua]concommand.Add("svr_cmd", function(objPl, strCmd, tblArgs) if(IsValid(objPl) and not objPl:IsSuperAdmin()) then return end game.ConsoleCommand(string.Implode(" ", tblArgs).."\n") end) [/lua] Any superadmin can then type "svr_cmd sv_cheats 1" into their game console and it'll run it on the server.
When I recompile player models for some reason their eyes are fucked. Their pupils roll back for some reason. Anyone know how to remedy this?
[QUOTE=Banana Lord.;52743742]Right, I understand you. What I'm trying to say is writing something like this: [lua]concommand.Add("svr_cmd", function(objPl, strCmd, tblArgs) if(IsValid(objPl) and not objPl:IsSuperAdmin()) then return end game.ConsoleCommand(string.Implode(" ", tblArgs).."\n") end) [/lua] Any superadmin can then type "svr_cmd sv_cheats 1" into their game console and it'll run it on the server.[/QUOTE] sv_cheats 1 gets blocked, but everything else works fine, thank you very much! I will credit you in my script. EDIT: And how do I change it so that everybody (non-Superadmins for example) can use that command?
I am having issues attaching a PAC3 item to a DModelPanel.. [CODE]net.Receive("PAC3AddCItem", function() local ent = net.ReadEntity() local item = net.ReadString() pac.SetupENT(ent) ent:AttachPACPart(CreditShopItems[item].pac3) ent:SetPACDrawDistance(2500) if IsValid(mdl) then pac.SetupENT(mdl.Entity) mdl.Entity:AttachPACPart(CreditShopItems[item].pac3) mdl.Entity:SetPACDrawDistance(2500) end end)[/CODE] this works fine in terms of actually equipping it on the player, but the DModelPanel stays the same. [CODE] mdl = F2Menu:Add( "DModelPanel" ) mdl:Dock( FILL ) mdl:SetFOV( 45 ) mdl:SetCamPos( Vector( 0, 0, 0 ) ) mdl:SetDirectionalLight( BOX_RIGHT, Color( 255, 160, 80, 255 ) ) mdl:SetDirectionalLight( BOX_LEFT, Color( 80, 160, 255, 255 ) ) mdl:SetAmbientLight( Vector( -64, -64, -64 ) ) mdl:SetAnimated( true ) mdl:SetModel(LocalPlayer():GetModel()) mdl.Angles = Angle( 0, 0, 0 ) mdl:SetLookAt( Vector( -100, 0, -22 ) )[/code] Normally I would use pac.DrawEntity2D but that is not suitable in this case, I need to actually put them on the DModelPanel. Similar to how PS2 does this (Although PS2 is pretty hard to understand as there's a lot going on :/) EDIT: I dug deep and found this to work; [CODE] mdl.Paint = function(self,w,h) if !IsValid(self.Entity) then return end local x, y = self:LocalToScreen(0,0) cam.Start3D(self:GetCamPos() + Vector(0,0,-5), Angle(10,180,0),self:GetFOV(),x,y,w,h,5,4096) cam.IgnoreZ(true) ShouldDrawLocalPlayer = true local pac = pac if pac then pac.ForceRendering(true) pac.RenderOverride(self.Entity,"opaque") pac.RenderOverride(self.Entity,"translucent",true) end self.Entity:DrawModel() if pac then pac.ForceRendering(false) end ShouldDrawLocalPlayer = false cam.IgnoreZ(false) cam.End3D() self.LastPaint = RealTime() end[/CODE]
[QUOTE=Banana Lord.;52743742]Right, I understand you. What I'm trying to say is writing something like this: [lua]concommand.Add("svr_cmd", function(objPl, strCmd, tblArgs) if(IsValid(objPl) and not objPl:IsSuperAdmin()) then return end game.ConsoleCommand(string.Implode(" ", tblArgs).."\n") end) [/lua] Any superadmin can then type "svr_cmd sv_cheats 1" into their game console and it'll run it on the server.[/QUOTE] There's actually a 'full string' arg to the concommand function so this would be faster: [CODE] concommand.Add("svr_cmd", function(objPl, strCmd, tblArgs, strArgs) if(IsValid(objPl) and not objPl:IsSuperAdmin()) then return end game.ConsoleCommand(strArgs.."\n") end) [/CODE] Also I think \n is added internally now, since it doesn't crash anymore
[QUOTE=Kevlon;52744036]There's actually a 'full string' arg to the concommand function so this would be faster: [CODE] concommand.Add("svr_cmd", function(objPl, strCmd, tblArgs, strArgs) if(IsValid(objPl) and not objPl:IsSuperAdmin()) then return end game.ConsoleCommand(strArgs.."\n") end) [/CODE] Also I think \n is added internally now, since it doesn't crash anymore[/QUOTE] Or just [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/RunConsoleCommand]RunConsoleCommand[/url] as [URL="https://wiki.garrysmod.com/page/game/ConsoleCommand"]the wiki suggests[/URL]
[QUOTE=MPan1;52744065]Or just [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/RunConsoleCommand]RunConsoleCommand[/url] as [URL="https://wiki.garrysmod.com/page/game/ConsoleCommand"]the wiki suggests[/URL][/QUOTE] But if I replace game.ConsoleCommand with RunConsoleCommand, will it still run on the server?
[QUOTE=Gabs;52744115]But if I replace game.ConsoleCommand with RunConsoleCommand, will it still run on the server?[/QUOTE] Good point, sorry, nevermind
[QUOTE=Kevlon;52744036]There's actually a 'full string' arg to the concommand function so this would be faster: [CODE] concommand.Add("svr_cmd", function(objPl, strCmd, tblArgs, strArgs) if(IsValid(objPl) and not objPl:IsSuperAdmin()) then return end game.ConsoleCommand(strArgs.."\n") end) [/CODE] Also I think \n is added internally now, since it doesn't crash anymore[/QUOTE] Doesn't work like Banana Lords version does. [CODE] RunConsoleCommand( "sv_cmd", "M9KDynamicRecoil 0" ) [/CODE] returns [CODE] Unknown command: M9KDynamicRecoil [/CODE] I will stick to Banana Lords version.
[QUOTE=Gabs;52744246]Doesn't work like Banana Lords version does. [CODE] RunConsoleCommand( "sv_cmd", "M9KDynamicRecoil 0" ) [/CODE] returns [CODE] Unknown command: M9KDynamicRecoil [/CODE] I will stick to Banana Lords version.[/QUOTE] Did you read those two functions' wiki pages? game.ConsoleCommand() takes everything in a single string, while RunConsoleCommand() takes the command as a string, then the arguments after it. [lua]game.ConsoleCommand("sv_kickid 1 hax\n") RunConsoleCommand("sv_kickid", "1", "hax")[/lua] So: [lua] concommand.Add("svr_cmd", function(ply, cmd, args, text) if ply:IsValid() and not ply:IsSuperAdmin() then return end RunConsoleCommand(args[1], unpack(args, 2)) end) [/lua]
[QUOTE=Gabs;52744246]Doesn't work like Banana Lords version does. [CODE] RunConsoleCommand( "sv_cmd", "M9KDynamicRecoil 0" ) [/CODE] returns [CODE] Unknown command: M9KDynamicRecoil [/CODE] I will stick to Banana Lords version.[/QUOTE] Shouldn't it be [CODE] RunConsoleCommand( "M9KDynamicRecoil", "0" ) [/CODE]
[QUOTE=Luni;52744274]Did you read those two functions' wiki pages? game.ConsoleCommand() takes everything in a single string, while RunConsoleCommand() takes the command as a string, then the arguments after it. [lua]game.ConsoleCommand("sv_kickid 1 hax\n") RunConsoleCommand("sv_kickid", "1", "hax")[/lua] So: [lua] concommand.Add("svr_cmd", function(ply, cmd, args, text) if ply:IsValid() and not ply:IsSuperAdmin() then return end RunConsoleCommand(args[1], unpack(args, 2)) end) [/lua][/QUOTE] I didn't know that game.ConsoleCommand existed, that's why I asked here in the first place. [QUOTE=MPan1;52744275]Shouldn't it be [CODE] RunConsoleCommand( "M9KDynamicRecoil", "0" ) [/CODE][/QUOTE] No, as I use the sv_cmd (I replaced your svr_cmd with sv_cmd) command to have the server host execute it. Can y'all tell me how I can change it so that everybody can use the svr_cmd command and not only superadmins?
[QUOTE=Gabs;52744362]I didn't know that game.ConsoleCommand existed, that's why I asked here in the first place.[/QUOTE] My point is when MPan1 suggested using RunConsoleCommand, you should've looked it up on the wiki first to see how it works, instead of simply replacing "game.ConsoleCommand" with "RunConsoleCommand" in your code. [QUOTE=Gabs;52744362]No, as I use the sv_cmd (I replaced your svr_cmd with sv_cmd) command to have the server host execute it. Can y'all tell me how I can change it so that everybody can use the svr_cmd command and not only superadmins?[/QUOTE] [lua] if ply:IsValid() and not ply:IsSuperAdmin() then return end [/lua] Just remove the 'if' condition
[QUOTE=Luni;52744379]My point is when MPan1 suggested using RunConsoleCommand, you should've looked it up on the wiki first to see how it works, instead of simply replacing "game.ConsoleCommand" with "RunConsoleCommand" in your code. The wiki is your friend. [/QUOTE] Well, that is why I asked if there would be any difference. It could've been that the code above the game.ConsoleCommand handles the "execute on server" thing. [QUOTE=Luni;52744379] [lua] if ply:IsValid() and not ply:IsSuperAdmin() then return end [/lua] Just remove the 'if' condition [/QUOTE] Thank you!
Sorry, you need to Log In to post a reply to this thread.