• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
Is it possible to have a clientside model(object) have physical attributes? The object would collide successfully with the ground/world and you'd have the ability to change that clientside model's velocity/angle velocity? Is this possible? The reason for this would be smoothing out lag on my gamemode for my car entities. [t]https://dl.dropboxusercontent.com/u/17839069/C_293.png[/t]
[QUOTE=EthanTheGreat;47706279]Is it possible to have a clientside model(object) have physical attributes? The object would collide successfully with the ground/world and you'd have the ability to change that clientside model's velocity/angle velocity? Is this possible? The reason for this would be smoothing out lag on my gamemode for my car entities. [t]https://dl.dropboxusercontent.com/u/17839069/C_293.png[/t][/QUOTE] How is your server FPS 11,111?
Okay so i have a spectate command for my gmod gamemode: --Spectate function chatCommand( ply, text, public ) if (string.sub(text, 1) == "!spectate_game") then ply:Spectate( 6 ) return(false) end end hook.Add( "PlayerSay", "chatCommand", chatCommand ); And im trying to make a join game command here is what i have: --Join game function chatCommand( ply, text, public ) if (string.sub(text, 1) == "!join_game") then ply:Spectate( 6 ) --what do i replace this with to unspectate return(false) end end hook.Add( "PlayerSay", "chatCommand", chatCommand ); thanks any help is appricieted
[QUOTE=EthanTheGreat;47706279]Is it possible to have a clientside model(object) have physical attributes? The object would collide successfully with the ground/world and you'd have the ability to change that clientside model's velocity/angle velocity? Is this possible? The reason for this would be smoothing out lag on my gamemode for my car entities. [t]https://dl.dropboxusercontent.com/u/17839069/C_293.png[/t][/QUOTE] You can use ClientsideModel and then create a physics object for it, but it'll only collide with the world and other clientside physics objects. Anything else, like a regular entity, will just pass through it. Something like this: [code]if SERVER then return end self.csmodel = ClientsideModel(self:GetModel()) if !util.IsValidProp(self:GetModel()) then self.csmodel:PhysicsInitBox(self.csmodel:GetModelBounds()) else self.csmodel:PhysicsInit(SOLID_VPHYSICS) end self.csmodel:GetPhysicsObject():Wake() self.csmodel:SetPos(wherever) self.csmodel:SetAngles(some_angle) //do things with self.csmodel[/code] Entity:DeleteOnRemove() only works serverside, though, so you'll need to set up something else to remove the clientside model once you don't need it. Maybe you can use the OnRemove hook or something, I don't know - the only time I ever used clientside props like these, I just had them expire on a timer.
Is there a way to prevent this problem? Where print(string.len("❤")) = 3? Well, more importantly do any string operation with it without it splitting into 3 characters. --Figured out something that solved my problem--
Any idea what is causing the text above players to not render in front of some entitys? [img]http://puu.sh/hKnzv/dfde4a410d.jpg[/img]
[QUOTE=101kl;47708020]Any idea what is causing the text above players to not render in front of some entitys? [img]http://puu.sh/hKnzv/dfde4a410d.jpg[/img][/QUOTE] Rendering order? Idk this happens with a lot of things
[QUOTE=101kl;47708020]Any idea what is causing the text above players to not render in front of some entitys? [img]http://puu.sh/hKnzv/dfde4a410d.jpg[/img][/QUOTE] Always use PostDrawTranslucentRenderables hook for 3D2D.
Is there a way to test binary modules without restarting completely?
[QUOTE=KillerLUA;47708865]Is there a way to test binary modules without restarting completely?[/QUOTE] change the level
Question, how do I reset an entity's material through my code? I'm trying to make a nextbot that's invisible, but only shows itself(aka changing the material back to normal) when it's about to strike it's target.
[QUOTE=A Fghtr Pilot;47711493]Question, how do I reset an entity's material through my code? I'm trying to make a nextbot that's invisible, but only shows itself(aka changing the material back to normal) when it's about to strike it's target.[/QUOTE] If I remember correctly, you call SetMaterial with an empty string: [code]Entity:SetMaterial("")[/code]
I am recording information from EntityTakeDamage, what is the simplest way to ensure the following information is recorded when the weapon is NULL (aka the player is not holding any weapon when damaged). [code] [1] = ent:GetActiveWeapon():GetClass() [/code] Would it be as simple as: [code] [1] = ent:GetActiveWeapon():GetClass() or nil [/code] ?
[lua]if not IsValid(ent:GetActiveWeapon()) then return end[/lua] [editline]oh[/editline] Oh, [IMG]http://www.facepunch.com/fp/ratings/book_error.png[/IMG] on my part.
[QUOTE=zerf;47713436][lua]if not IsValid(ent:GetActiveWeapon()) then return end[/lua][/QUOTE] This doesn't help me as I still want to make sure the damage information is recorded if ent:GetActiveWeapon() is NULL. I was hoping there was a simple way but I guess I will just have to do the ifthenelse.
[QUOTE=isjason;47713617]This doesn't help me as I still want to make sure the damage information is recorded if ent:GetActiveWeapon() is NULL. I was hoping there was a simple way but I guess I will just have to do the ifthenelse.[/QUOTE] [code] [1] = IsValid(ent:GetActiveWeapon()) and ent:GetActiveWeapon():GetClass() [/code] [URL="http://www.lua.org/pil/3.3.html"]Logical Operators[/URL]
[code]109: if e:IsValid() && e:Alive() then e:TakeDamageInfo(SomeDMG) end[/code] [quote=The Console][ERROR] gamemodes/base/gamemode/player.lua:205: Tried to use a NULL entity! 1. GetClass - [C]:-1 2. unknown - gamemodes/base/gamemode/player.lua:205 3. TakeDamageInfo - [C]:-1 4. v - lua/autorun/dkdr_some_plugin.lua:109 5. unknown - lua/includes/modules/hook.lua:84[/quote] [editline]13th May 2015[/editline] SomeDMG doesn't reference any entities. e is a Player
IsValid(e)
Getting some weirdness trying to draw a cylinder: [url]http://images.akamai.steamusercontent.com/ugc/27364382934711519/703832933037B3C5A14609835F9BA604A5D2A624/[/url] As you can see half the triangles are inverted and half not. Here's my code: [lua] function Cylinder(Radius, Height, Sides) local verts = {} local Theta --Current Angle local Inc --Angular increment local x --x coord local y --y coord local z --z coord local i local n --vertex normal local tu --U coord local tv --V coord local UStep --step between U coords --Cylinder Precision Inc = 2 * math.pi / Sides --where each side has two triangles Theta = 0 --Initial value UStep = 1 / Sides tu = 0 --Initial value for i=0, Sides do --Calculate Vertices x = Radius * math.cos(Theta) y = Height z = Radius * math.sin(Theta) --Make sure you normalize vertex cords to get proper normals n = Vector(x, 0, z):GetNormalized() --Vertex at the top of the cylinder --tv value is always 1for top vertices --Mesh.AddVertex x, 0, z, 0, tu, 1, n.x, n.y, n.z table.insert(verts, {pos=Vector(x, 0, z), u=tu, v=1, normal=Vector(n.x, n.y, n.z)}) --Vertex at the bottom of the cylinder --tv value is always 0 for bottom vertices --Mesh.AddVertex x, y, z, 0, tu, 0, n.x, n.y, n.z table.insert(verts, {pos=Vector(x, y, z), u=tu, v=0, normal=Vector(n.x, n.y, n.z)}) Theta = Theta + Inc tu = tu + UStep end return verts end local obj = Mesh() -- Create the IMesh object local cyl = Cylinder(30, 15, 30) for i,v in pairs(cyl) do v.pos:Rotate(Angle(0,0,90)) v.pos = v.pos + Vector(0,0,-100) end obj:BuildFromTriangles( cyl ) -- Load the vertices into the IMesh object hook.Add( "PostDrawOpaqueRenderables", "IMeshTest", function() --local mat = Material( "editor/wireframe" ) -- The material ( a wireframe ) local mat = Material( "models/props_combine/tprings_globe" ) render.SetMaterial( mat ) -- Apply the material obj:Draw() -- Draw the mesh end ) [/lua] I pretty much stole it from [url]http://wiki.truevision3d.com/tutorialsarticlesandexamples/building_a_cylinder[/url] Can anyone give me a hand here? I can't math and I just want to draw a damn cylinder.
[QUOTE=PortalGod;47714537]IsValid(e)[/QUOTE] That's so stupid though. Why does ent:IsValid() return an error if ent isn't valid? Regardless, I'll try it tomorrow.
[QUOTE=WalkingZombie;47714572]That's so stupid though. Why does ent:IsValid() return an error if ent isn't valid? Regardless, I'll try it tomorrow.[/QUOTE] Because you're essentially calling nil:IsValid() which doesn't exist because nil is not an object. IsValid( ent ) is the correct and safe usage and it's not stupid, it's logic.
[QUOTE=Ylsid;47714546]Getting some weirdness trying to draw a cylinder[/QUOTE] just glancing at it, you're adding vertices in pairs instead of triplets, imeshes only use triangles. the way I would do it is for each face (as opposed to each edge, like you're doing), do two sets of three points each to make a square (and make sure they go in clockwise order) also, is there a reason why you're doing Vector(n.x, n.y, n.z)?
Is there any official release for darkrp commands for ulx? Ive been looking for more in depth ones like rpsetteam and stuff.
[QUOTE=meowking1;47718031]Is there any official release for darkrp commands for ulx? Ive been looking for more in depth ones like rpsetteam and stuff.[/QUOTE] Or you could do it through the tab menu?
Seriously, why can't I find SurfaceID's indexed on the wiki? What are the SurfaceID's as to material types? Like, surface type, surface prop I guess too.
[url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/scripts/surfaceproperties.txt[/url]
what do I use with GetMaterialType then? I'm not seeing numeric indexs [editline]14th May 2015[/editline] or am I using the wrong function to get the material type? (concrete, wood, flesh, etc)? [editline]14th May 2015[/editline] I must be, but I need to find out this material type, concrete, wood, plastic, flesh, etc... for Props, NPC's, other Entities, and the World...
Bang! [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetMaterialType]Entity:GetMaterialType[/url] Pow! [url]http://wiki.garrysmod.com/page/Enums/MAT[/url] [editline]13th May 2015[/editline] Example for show: [lua] function BackwardsEnums(enumname) local backenums = {} for k, v in pairs(_G) do if type(k) == "string" and string.find(k, "^"..enumname) then backenums[v] = k end end return backenums end local MAT = BackwardsEnums("MAT_") local validclasses = {prop_physics = true, prop_physics_multiplayer = true, prop_dynamic = true} for k,v in pairs(ents.GetAll()) do if validclasses[v:GetClass()] then print(v:GetModel(), MAT[v:GetMaterialType()]) end end [/lua] Output is something like this: [code] models/props_interiors/furniture_couch01a.mdl MAT_DIRT models/props/cs_office/offinspd.mdl MAT_GLASS models/props/cs_office/offinspf.mdl MAT_GLASS models/props_wasteland/controlroom_desk001b.mdl MAT_METAL models/props_junk/wood_crate002a.mdl MAT_WOOD models/props_junk/wood_crate002a.mdl MAT_WOOD models/props_junk/wood_crate001a_damaged.mdl MAT_WOOD models/props_wasteland/controlroom_desk001a.mdl MAT_METAL models/props_wasteland/controlroom_chair001a.mdl MAT_METAL models/props_c17/tools_wrench01a.mdl MAT_METAL models/props/cs_office/radio.mdl MAT_COMPUTER models/props_junk/pushcart01a.mdl MAT_METAL models/props_wasteland/kitchen_shelf001a.mdl MAT_METAL models/props_wasteland/cafeteria_table001a.mdl MAT_WOOD models/props_c17/furniturecouch001a.mdl MAT_DIRT models/props_c17/furnituretable003a.mdl MAT_WOOD models/combine_gate_vehicle.mdl nil models/props_junk/sawblade001a.mdl MAT_METAL models/props/cs_office/offinspf.mdl MAT_GLASS models/props_junk/wood_crate001a.mdl MAT_WOOD ... [/code]
Is it possible to give a [URL="http://wiki.garrysmod.com/page/Category:RichText"]RichText[/URL] a text shadow, in anyway?
[QUOTE=UnderYouFive;47722592]Is it possible to give a [URL="http://wiki.garrysmod.com/page/Category:RichText"]RichText[/URL] a text shadow, in anyway?[/QUOTE] Not that I'm aware, unless you program one yourself (not hard)
Sorry, you need to Log In to post a reply to this thread.