• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Is there an alternative Particle Editor from the default Valve particle editor?
How can I prevent the primary fire of a weapon from being used? I tried returning early in the primary fire function, but that just made a few more problems of its own.
I would actually love an answer to zeaga's question myself. I feel if :PrimaryAttack() doesn't run, the gun wouldn't alert nearby NPC's to your presence, making silenced weapons a possibility. So again, I believe I second the question, is there a way to by all means prevent that function from running at all?
[QUOTE=WalkingZombie;46211847]I would actually love an answer to zeaga's question myself. I feel if :PrimaryAttack() doesn't run, the gun wouldn't alert nearby NPC's to your presence, making silenced weapons a possibility. So again, I believe I second the question, is there a way to by all means prevent that function from running at all?[/QUOTE] [url]http://wiki.garrysmod.com/page/WEAPON/CanPrimaryAttack[/url]
This question may be hard to word but I need help checking a int and a bool then setting the bool globally on a weapon that hasn't been spawned yet, from the gamemode. Say I have weapon_zs_akbar, I want to check if SWEP.IsUnlocked is true in that class if it isn't then change it to true afterwards enable it to be purchased from say the ZS pointshop. I have no idea how exactly to do this without spawning the entity
[QUOTE=Tomelyr;46212051][url]http://wiki.garrysmod.com/page/WEAPON/CanPrimaryAttack[/url][/QUOTE] Thanks so much. It's embarrassing how often my questions are answered with a simple link to the wiki. I swear I look but apparently I'm an idiot. I actually used this function to implement a ConVar for TTT called 'ttt_no_weapon_fire_during_prep' that prevents players from firing while the round is in preparation.
[code]local splash = Material("gmachines/splash.png")[/code] [code]function ENT:Draw() render.MaterialOverrideByIndex(1, splash) self.BaseClass.Draw(self) end[/code] [img]http://i.imgur.com/3pS9y50.png[/img] What am I doing wrong?
is it possible to run a serverside function on the client and retrive the output? I want to run a function that retrives my perks list from an array so i can show it to the client the perk list should be the same on all clients so it seems stupid to network the same array to all clients if i can just retrive it when i need it oh and how do I align the text inside DButton to the left insted of center?
I have a Derma Menu that is being called via KEY_C & KEY_F4, here is the bind code: [code] //Menu Key Bind local FKeyMenus = { KEY_F4 = phm_1; KEY_C = phm_1; }; hook.Add( "PlayerBindPress", "PlayerBindPressFKeyMenus", function( _p, _bind, _pressed ) local _key = "KEY_" .. string.upper( input.LookupBinding( _bind ) ); local _func = FKeyMenus[ _key ]; if ( _func ) then _func( LocalPlayer() ); else print("Function either not listed or already executed")//Debug Print end end); [/code] I am having issue with setting that KEY_C & KEY_F4 will open and close the menu.
[lua]local LazyTab = vgui.Create("DPanelList") LazyTab:SetPos(0, 0) LazyTab:SetSize(mainpanel2:GetWide(), mainpanel2:GetTall()) LazyTab:SetSpacing(5) LazyTab:EnableHorizontal(false) LazyTab:EnableVerticalScrollbar(true) mainpanel2:AddSheet( "Primary", LazyTab, "icon16/shield.png", false, false, nil ) mainpanel2:AddSheet( "Handgun", LazyTab, "icon16/wrench.png", false, false, nil ) FamasButton = vgui.Create("DImageButton", LazyTab) FamasButton:SetMaterial("vgui/famas.vmt") FamasButton:SizeToContents() FamasButton.DoClick = function() print("yay") end [/lua] This is problematic. I have these tabs and I want FamasButton to be in Handgun tab (just testing tabs right now) but it's only in "Primary" tab. If I click the Handgun tab, the FamasButton image flashes for just a second and then it goes blank. Even if I return to the Primary tab, the FamasButton just flashes quickly and there is no button there like it should be. I just want to parent the FamasButton to either Primary tab or Handgun tab but I can't??? (I've tried instead of LazyTab, Handgun with and without quotes)
[QUOTE=Lizart;46213069]is it possible to run a serverside function on the client and retrive the output? I want to run a function that retrives my perks list from an array so i can show it to the client the perk list should be the same on all clients so it seems stupid to network the same array to all clients if i can just retrive it when i need it oh and how do I align the text inside DButton to the left insted of center?[/QUOTE] You can't receive data from the server if it isn't networked obviously. That would defeat the purpose. You could network it when the client requests it, though it is probably easier to just network it from the beginning. Depending on how often changes are made and large your tables are, it might be more efficient to just send the deltas on updates.
I'm creating a window on hover, but it I can't get it to the front. If I do MakePopup, and exit my cursor it returns error it can't find Close, how can I make it visible to the front? I tried MoveToFront with no succes. [code] function PANEL:Init() self:SetSize( 200, 200 ) self:ShowCloseButton(false) self:SetTitle("") --self.Paint = function() end self.ModelView = vgui.Create("MModelPanel", self) self.ModelView:Dock(FILL) end function PANEL:SetModel(model) self.ModelView:SetModel(model) end [/code]
Im using a for loop to create a lot of DButtons with different text. how would I later edit one of the buttons color/text? I cant just use button:SetText("new text") because every button created in the loop is named button
[QUOTE=Lizart;46216663]Im using a for loop to create a lot of DButtons with different text. how would I later edit one of the buttons color/text? I cant just use button:SetText("new text") because every button created in the loop is named button[/QUOTE] Save them in a table.
[QUOTE=HumbleTH;46216769]Save them in a table.[/QUOTE] I allready have a table containing the text and other information for the buttons. could you give me an example?
Show your code
[code] //change text function local function changeperkname() perkslistskill:SetText("test") end //loop perksarray = LocalPlayer():GetNetVar( "perkstable" ) for k,v in pairs(perksarray) do perkslistskill = vgui.Create( "DButton", perkslist ) perkslistskill:SetText(v['perkname'] ) perkslistskill:SetPos( 0,20*k) perkslistskill:SetFont('Trebuchet22') perkslistskill:SetColor(Color(255,255,255,255)) end [/code] I shorted the code down for readability but it should give you a clear example of what im trying to do edit: nevermind i figured it out, I just pasted the code into its own function and then ran that function again to update text.
[QUOTE=Tomelyr;46212051][URL]http://wiki.garrysmod.com/page/WEAPON/CanPrimaryAttack[/URL][/QUOTE] OH SHIT! If I would've known that ages ago, that would've helped me out so much! With more than just silenced weapons! Thank you!!!!!! :dance: [editline]12th October 2014[/editline] Preparing for 1m dumb ratings. But hey, if that does it, wouldn't doing this have the exact same effect? [lua]function SWEP:PrimaryAttack() return end[/lua]
[QUOTE=RonanZer0;46214557][lua]local LazyTab = vgui.Create("DPanelList") LazyTab:SetPos(0, 0) LazyTab:SetSize(mainpanel2:GetWide(), mainpanel2:GetTall()) LazyTab:SetSpacing(5) LazyTab:EnableHorizontal(false) LazyTab:EnableVerticalScrollbar(true) mainpanel2:AddSheet( "Primary", LazyTab, "icon16/shield.png", false, false, nil ) mainpanel2:AddSheet( "Handgun", LazyTab, "icon16/wrench.png", false, false, nil ) FamasButton = vgui.Create("DImageButton", LazyTab) FamasButton:SetMaterial("vgui/famas.vmt") FamasButton:SizeToContents() FamasButton.DoClick = function() print("yay") end [/lua] This is problematic. I have these tabs and I want FamasButton to be in Handgun tab (just testing tabs right now) but it's only in "Primary" tab. If I click the Handgun tab, the FamasButton image flashes for just a second and then it goes blank. Even if I return to the Primary tab, the FamasButton just flashes quickly and there is no button there like it should be. I just want to parent the FamasButton to either Primary tab or Handgun tab but I can't??? (I've tried instead of LazyTab, Handgun with and without quotes)[/QUOTE] Anyone? Does anybody know how to properly use DPropertySheet or whatever the thing is called that has Derma tabs?
So we have had this problem for a while now... My friends and I want to change where our server shows up on the server list and cannot seem to find out how to do this even with hours of searching and trial and error. Is it in the server.cfg? Is it possible to do this without creating a whole new gamemode? We have Dark Rp and want to change it to something else. Any help is appreciated thank you in advance.
[QUOTE=Exho;46211022]So I used some code for my chat thingy (it was under the "PostDrawOpaqueRenderables" hook and a Cam.Start3d2d) and threw it under a HUDPaint hook. For whatever reason it just spams the table on and on and on which didnt happen in the other hook. I tried a couple hacky methods of stopping the spam from happening to no real avail. [IMG]http://i.gyazo.com/9c4a0c90c5de0c6a90f95da3725124de.png[/IMG] Code, minus some extra stuff [code] local ob = ply:GetObserverTarget() if ob and IsValid(ob) and ob:IsPlayer() and ob:Alive() then ply = ob if not ply.Spectators then ply.Spectators = {} end table.insert(ply.Spectators, "Name 1") table.insert(ply.Spectators, "Name 2") table.insert(ply.Spectators, "Name 3") table.insert(ply.Spectators, "Name 4") table.insert(ply.Spectators, "Name 5") table.insert(ply.Spectators, "Name 6") table.insert(ply.Spectators, "Name 7") table.insert(ply.Spectators, "Name 8") end if ply.Spectators then local buffer = 20 local width = 100 local height = 150 local x = 10 local y = (ScrH()/2) - (height/2) draw.RoundedBox( 0, x, y, width, height, Color( 44, 44, 44, 175 ) ) draw.AAText( "Spectators:", "Deathrun_Spec", x + (width/2), y, Color(255,255,255,255), TEXT_ALIGN_CENTER ) local buffer = 20 local width = 100 local height = 150 local x = 10 local y = (ScrH()/2) - (height/2) draw.RoundedBox( 0, x, y, width, height, Color( 44, 44, 44, 175 ) ) draw.AAText( "Spectators:", "Deathrun_Spec", x + (width/2), y, Color(255,255,255,255), TEXT_ALIGN_CENTER ) for k, v in pairs(ply.Spectators) do draw.DrawText( v, "Deathrun_Spec", x + (width/2), y + buffer, Color(255,255,255,255), TEXT_ALIGN_CENTER ) buffer = buffer + 15 end end [/code][/QUOTE] Okay, I tried counting the loops in the table but then it doesnt update the table correctly..
PS_HasItemEquipped returns nil value [lua]local CrossMat = "crosshairs/rocket.png" ITEM.Price = 0 ITEM.Name = "Crosshair Test" ITEM.Material = CrossMat if CLIENT then if LocalPlayer():PS_HasItemEquipped('crosshairtest') then function ITEM:HUDPaint() if not LocalPlayer():Alive() then return end if LocalPlayer():Team() == TEAM_SPEC then return end if isstring( CrossMat ) then if string.find( CrossMat, ".png" ) then CrossMat = Material( CrossMat, "nocull" ) else CrossMat = Material( CrossMat ) end end surface.SetMaterial( CrossMat ) surface.SetDrawColor(255,255,255) surface.DrawTexturedRectRotated(ScrW()/2,ScrH()/2,32,32,0) end end end[/lua]
-snip-
Is there any way to scale the viewmodel? I would like to reduce the size of the weapons (and hands) on screen. Everything I tried, didn't work at all. I also tried with CalcView but it's too ugly..
[QUOTE=Exho;46217410]Okay, I tried counting the loops in the table but then it doesnt update the table correctly..[/QUOTE] i have a feeling that the first half of your code is being run again, which adds the names to the table but doesn't clear the previous one try replacing [LUA]if not ply.Spectators then ply.Spectators = {} end[/LUA] with [LUA]ply.Spectators = {}[/LUA] and see if it makes a difference also try drawing #ply.Spectators
[QUOTE=rejax;46219513]i have a feeling that the first half of your code is being run again, which adds the names to the table but doesn't clear the previous one try replacing [LUA]if not ply.Spectators then ply.Spectators = {} end[/LUA] with [LUA]ply.Spectators = {}[/LUA] and see if it makes a difference also try drawing #ply.Spectators[/QUOTE] You know, its both under a HUDPaint so that might end up being it..
Hey, I want to do a HUD that isn't just circles and squares, preferable without using materials (unless it is genuinely better) I'm trying to do something like this: [img]http://puu.sh/caEDN/3c6bddc490.png[/img] Would I be using Polygons to do this and if so, is there any resources for using them?
[QUOTE=NiandraLades;46222347]Hey, I want to do a HUD that isn't just circles and squares, preferable without using materials (unless it is genuinely better) I'm trying to do something like this: [img]http://puu.sh/caEDN/3c6bddc490.png[/img] Would I be using Polygons to do this and if so, is there any resources for using them?[/QUOTE] You can either use polygons or an png image/texture. Texture is easier, polygons are harder to get right, and [B]might[/B] be slower, but they don't require anything to be downloaded. [url]http://wiki.garrysmod.com/page/surface/DrawPoly[/url]
[QUOTE=NiandraLades;46222347]Hey, I want to do a HUD that isn't just circles and squares, preferable without using materials (unless it is genuinely better) I'm trying to do something like this: [img]http://puu.sh/caEDN/3c6bddc490.png[/img] Would I be using Polygons to do this and if so, is there any resources for using them?[/QUOTE] [url=https://www.youtube.com/watch?v=zFnwXZhqMGk]This should help tremendously with polys[/url]
Why won't particle effects work in a start touch hook? code: [lua] function ENT:StartTouch(ent) if ent:IsValid() and ent:IsPlayer() then //add variable if it doens't exist if !ent.cookies then ent.cookies = 0 end //Add more cookies ent.cookies = ent.cookies + 1 print("adding cookie points") //Cookie effects ParticleEffect( "halloween_explosion_bits", ent:GetPos()+Vector(0,0,64), ent:GetAngles()) //Send usermessage to the playerscreen with updated cookie amount //Check if the player has reached a certain amount of cookies if ent.cookies%10 == 0 then //Add points end self:Remove() //Remove itself end end [/lua] ---------edit-------------- It fixed itself after a restart.
Sorry, you need to Log In to post a reply to this thread.