• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Is it possible to get a players name from a SteamID if they aren't connected to the server? Edit: Or even if they are connected actually
[QUOTE=prang123;46643471]Is it possible to get a players name from a SteamID if they aren't connected to the server? Edit: Or even if they are connected actually[/QUOTE] If they're connected loop over all players, else you'll have to store the steamIDs yourself or use the [url=https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29]steam api[/url]
How to use a custom HUD on a fretta gamemode? and, how to check for the current gamemode?
Copy cl_hud.lua from the fretta base and put it in your gamemode. Make sure to addCslua and include it
How would I go about drawing shapes over players onto a render.RenderView? I can't seem to figure out how to take the position of the player from the RenderView and put it on the client's screen
How can I update a DFrame every frame/0.04 sec? I'm using a progress bar (draw.RoundedBox) inside my mainframe.Paint = function(). I'll need this to animate the frame and update the progress bar
I suck at math so.. I've got a grid: [lua] x = max x size y = max y size cube = (x*0.0355) * (y*0.046) [/lua] Basically this, I need to find out how many cubes fit in the grid. I can count them all but I am not sure if the same number of cubes stay on another resolution
[QUOTE=arcaneex;46656045]I suck at math so.. I've got a grid: [lua] x = max x size y = max y size cube = (x*0.0355) * (y*0.046) [/lua] Basically this, I need to find out how many cubes fit in the grid. I can count them all but I am not sure if the same number of cubes stay on another resolution[/QUOTE] 28.1690140845 * 21.7391304348 cubes why are you using such weird numbers?
Cubes and grid size depends on resolution. what do you mean by 28.1690140845 * 21.7391304348 cubes
[QUOTE=arcaneex;46656106]Cubes and grid size depends on resolution. what do you mean by 28.1690140845 * 21.7391304348 cubes[/QUOTE] x * 0.0355 is the same as x/28.1690140845, so there are can be 28.1690140845 cubes on that row and I meant why are you using 0.0355 and 0.046
[QUOTE=arcaneex;46656045]I suck at math so.. I've got a grid: [lua] x = max x size y = max y size cube = (x*0.0355) * (y*0.046) [/lua] Basically this, I need to find out how many cubes fit in the grid. I can count them all but I am not sure if the same number of cubes stay on another resolution[/QUOTE] [lua] local w = 500 -- Container size local h = 500 local a = 64 -- One icon size local b = 64 local wa = math.floor( w / a ) -- How many icons will be able to fit in one row local hb = math.floor( h / b ) -- How many icons will fit in one column local total = wa * hb -- Total amount of icons to fix in the container [/lua] ??? (Assuming spacing/padding is 0)
Does anyone know how to set the color on a ClientsideModel? entity:SetColor() simply does nothing, maybe I'm calling it in the wrong place? here's the code. [lua] self.ExtraParts = { ["Hair"] = {bone = "headgear", isattachment = true, Pos = Vector(0,0,0), Ang = Angle(0,0,0), model = "models/fallout/player/hair/haircurly.mdl", color = Color(255,0,0,255)} } -- this table is in a different place in the code, but this is just for reference. for _, part in pairs(self.ExtraParts) do if not part.entity then part.entity = ClientsideModel(part.model, RENDERGROUP_TRANSLUCENT) part.entity:SetNoDraw(true) end if part.entity then local attachment local partpos if part.isattachment then attachment = self.Entity:LookupAttachment(part.bone) partpos = self.Entity:GetAttachment(attachment) else attachment = self.Entity:LookupBone(part.bone) partpos = self.Entity:GetBonePosition(attachment) end part.entity:SetRenderOrigin(partpos.Pos) part.entity:SetRenderAngles(partpos.Ang) part.entity:DrawModel() part.entity:SetColor(Color(255,0,0,255)) end end [/lua] Also [QUOTE=Exho;46653608]How would I go about drawing shapes over players onto a render.RenderView? I can't seem to figure out how to take the position of the player from the RenderView and put it on the client's screen[/QUOTE] Did you try [url]http://wiki.garrysmod.com/page/Vector/ToScreen[/url] ?
Docking fucks up GetSize? [lua] local pnl = {} function pnl:Init() self:DockMargin(4,4,4,4) self:Dock(FILL) end vgui.Register('Facepunch',pnl,'DFrame') ... local fp = vgui.Create('Facepunch') print(Facepunch:GetSize()) //64 24 [/lua]
Is there a way to disable scrolling through weapons for all players?
[QUOTE=SwikCoder;46656502]Is there a way to disable scrolling through weapons for all players?[/QUOTE] You could hide the weapon selector using HUDShouldDraw. [QUOTE=arcaneex;46656490]Docking fucks up GetSize? local pnl = {}function pnl:Init() self:DockMargin(4,4,4,4) self:Dock(FILL)endvgui.Register('Facepunch',pnl,'DFrame')...local fp = vgui.Create('Facepunch')print(Facepunch:GetSize())//64 24 [/QUOTE] You are not setting the size anywhere, nor do you set the parent. Also your code won't even compile because you do Facepunch:GetSize() instead of fp:GetSize() [QUOTE=bizzclaw;46656389]Does anyone know how to set the color on a ClientsideModel? entity:SetColor() simply does nothing, maybe I'm calling it in the wrong place? here's the code. self.ExtraParts = { ["Hair"] = {bone = "headgear", isattachment = true, Pos = Vector(0,0,0), Ang = Angle(0,0,0), model = "models/fallout/player/hair/haircurly.mdl", color = Color(255,0,0,255)} } -- this table is in a different place in the code, but this is just for reference. for _, part in pairs(self.ExtraParts) do if not part.entity then part.entity = ClientsideModel(part.model, RENDERGROUP_TRANSLUCENT) part.entity:SetNoDraw(true) end if part.entity then local attachment local partpos if part.isattachment then attachment = self.Entity:LookupAttachment(part.bone) partpos = self.Entity:GetAttachment(attachment) else attachment = self.Entity:LookupBone(part.bone) partpos = self.Entity:GetBonePosition(attachment) end part.entity:SetRenderOrigin(partpos.Pos) part.entity:SetRenderAngles(partpos.Ang) part.entity:DrawModel() part.entity:SetColor(Color(255,0,0,255)) end end Also Did you try [URL]http://wiki.garrysmod.com/page/Vector/ToScreen[/URL] ?[/QUOTE] Try setting the color BEFORE drawing the model.
About not compiling its just an example code I wrote How do I get its size then without GetSize()?
[QUOTE=Robotboy655;46656621] Try setting the color BEFORE drawing the model.[/QUOTE] thanks, but that didn't make a difference, I tried setting it before drawing the model, after, when it's first created, ect. It doesn't seem to make a difference. I tried printing the table from GetColor() after drawing the model, and it does print the values I set, it's just not displaying a different color. Color : r = 255 b = 0 a = 255 g = 0 This is in a derma menu by the way, I'm making a new panel based on DModelPanel so that it supports multiple ClientsideModels in it.
Is there a way to make a player switch there weapon to the next one in there inventory? I've been trying to find a way to do this, but have not been successful. If someone can help it would be very appreciated.
[lua]player:ConCommand("invnext") player:ConCommand("invprev")[/lua]
[QUOTE=Robotboy655;46656621]You could hide the weapon selector using HUDShouldDraw. [/QUOTE] This won't help, they could still rotate through their weapons with the scroll.
[QUOTE=SwikCoder;46656860]This won't help, they could still rotate through their weapons with the scroll.[/QUOTE] Just remembered there's this hook: [url]http://wiki.garrysmod.com/page/GM/PlayerSwitchWeapon[/url]
[QUOTE=Robotboy655;46656880]Just remembered there's this hook: [url]http://wiki.garrysmod.com/page/GM/PlayerSwitchWeapon[/url][/QUOTE] I'm not sure how that would be of use though.
[QUOTE=SwikCoder;46657138]I'm not sure how that would be of use though.[/QUOTE] Did you bother to open the link? Did you bother to read what the hook does? Do you know how to code?
-snip-
I have a module in the addons folder under lua/includes/modules and name it in the code as module( "moduletest" ) but whenever I try to call a function from it, moduletest is nil... No lua errors or anything
[QUOTE=Exho;46657609]I have a module in the addons folder under lua/includes/modules and name it in the code as module( "moduletest" ) but whenever I try to call a function from it, moduletest is nil... No lua errors or anything[/QUOTE] Try module(string, package.seeall)
I didn't think about putting this question here first but here it is. I'm trying to write a script to stop prop pushing but it isn't working. I think the shouldcollide hook is broken. It seems to be getting run even when there's no collision. Any alternative ideas? [lua] hook.Add("PhysgunPickup", "NoPropPush", function(ply, ent) ent.IsPhysgunned = true ent:SetCustomCollisionCheck(true) end) hook.Add("PhysgunDrop", "NoPropPush", function(ply, ent) ent.IsPhysgunned = nil ent:SetCustomCollisionCheck(false) end) local function stopPropPush(prop, attacked) local owner = prop:CPPIGetOwner() local victim if attacked:IsPlayer() then victim = attacked else victim = attacked:CPPIGetOwner() end if IsValid(owner) and IsValid(victim) and owner~=victim then timer.Simple(0,function() if prop:IsValid() then local physobj = prop:GetPhysicsObject() if physobj:IsValid() then owner:PrintMessage(HUD_PRINTCENTER, "Your prop froze because it hit someone's stuff") physobj:EnableMotion(false) end end end) end end hook.Add("ShouldCollide","DontPropPush", function(ent1, ent2) if ent1.IsPhysgunned then stopPropPush(ent1, ent2) end if ent2.IsPhysgunned then stopPropPush(ent2, ent1) end end) [/lua] [editline]6th December 2014[/editline] [QUOTE=SwikCoder;46656796]Is there a way to make a player switch there weapon to the next one in there inventory? I've been trying to find a way to do this, but have not been successful. If someone can help it would be very appreciated.[/QUOTE] Use [url]http://wiki.garrysmod.com/page/Player/GetWeapons[/url] to get a list of the player's weapons. Use [url]http://wiki.garrysmod.com/page/Player/GetActiveWeapon[/url] to find in the list where the current weapon is Use [url]http://wiki.garrysmod.com/page/Player/SetActiveWeapon[/url] to equip the next weapon in the list
I'm making a tool that involves selecting a bunch of entities and I want them to have halos with the color based on a NetworkInt on them. What would be the best way to handle this? Looping through every entity, checking if GetNWInt doesn't return the fallback and applying the color based on the int? Like this: [lua]CLASSTOCOLOR = {} CLASSTOCOLOR[0] = Color(255,255,255,255) CLASSTOCOLOR[1] = Color(255,0,0,255) CLASSTOCOLOR[2] = Color(0,255,0,255) CLASSTOCOLOR[3] = Color(0,0,255,255) CLASSTOCOLOR[4] = Color(0,255,255,255) hook.Add( "PreDrawHalos", "AddHalos", function() for _, ent in pairs( ents.GetAll( ) ) do if ent:GetNWInt( "EntityType", -1 ) > 0 then halo.Add( {ent}, CLASSTOCOLOR[ent:GetNWInt("EntityType")], 5, 5, 2 ) end end end[/lua] I feel like that is a awful way to do it
Entity take damage crashes game [CODE] function ENT:OnTakeDamage( dmginfo ) -- React physically when shot/getting blown self:TakePhysicsDamage( dmginfo ) self:TakeDamageInfo( dmginfo ) end[/CODE] self:TakeDamageInfo( dmginfo ) is what causes the crash...is this being used incorrectly? Trying to get the entity to take damage as a player would but it does not....
I should add that this is for a developer tool that would only be used on singleplayer and not that often [editline]7th December 2014[/editline] There goes my automerge
Sorry, you need to Log In to post a reply to this thread.