• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
I want to make a menu for my scoreboard, like a side one with various information. I can do this fine, however I'd like so players can still move their cursor around the world and looking around when pressing tab, like they do normally when using the scoreboard What's the general method to do this? Thanks!
I want to make it so that when someone buys a gun from the pointshop (TTT), it will strip his weapon and give him what he bought (Right now if he buys an m16 and he has a shotgun the points are taken but nothing happens). Will this code work? I can't test it (long story) so yea :P [CODE]function ITEM:OnBuy(ply) for k,v in pairs(ply:GetWeapons()) do if(v.Kind == self.Slot) then ply:StripWeapon( v.Gun ) ply:PS_HolsterItem( v.Gun ) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end[/CODE] Ofc I mean to replace the original function ITEM:OnBuy(ply) with that one
[QUOTE=JasonMan34;45603343]I want to make it so that when someone buys a gun from the pointshop (TTT), it will strip his weapon and give him what he bought (Right now if he buys an m16 and he has a shotgun the points are taken but nothing happens). Will this code work? I can't test it (long story) so yea :P [CODE]function ITEM:OnBuy(ply) for k,v in pairs(ply:GetWeapons()) do if(v.Kind == self.Slot) then ply:StripWeapon( v.Gun ) ply:PS_HolsterItem( v.Gun ) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end[/CODE] Ofc I mean to replace the original function ITEM:OnBuy(ply) with that one[/QUOTE] Instead of going with slot, do ITEM.Kind = WEAPON_PRIMARY, then check if v.Kind == self.Kind
[QUOTE=HumbleTH;45603415]Instead of going with slot, do ITEM.Kind = WEAPON_PRIMARY, then check if v.Kind == self.Kind[/QUOTE] Excuse me, but I am completely lost when it comes to k,v in pairs, and I am probably really really dumb right now, but do you mean something like this? [CODE]function ITEM:OnBuy(ply) for k,v in pairs(ply:GetWeapons()) do ITEM.Kind = WEAPON_PRIMARY if(v.Kind == self.Kind) then[/CODE]
Is there anyway I can generate the unique ID from someones steamId. I don't know the algorithm for it and I didn't see it anywhere on the wiki.
[QUOTE=JasonMan34;45603487]Excuse me, but I am completely lost when it comes to k,v in pairs, and I am probably really really dumb right now, but do you mean something like this? [CODE]function ITEM:OnBuy(ply) for k,v in pairs(ply:GetWeapons()) do ITEM.Kind = WEAPON_PRIMARY if(v.Kind == self.Kind) then[/CODE][/QUOTE] Where you set the item's name, model, etc, do ITEM.Kind = WEAPON_PRIMARY In your OnBuy function: [lua] for k, v in pairs( ply:GetWeapons() ) do // k stands for key, v for value if v.Kind == self.Kind then ply:StripWeapon( v.ClassName ) end end [/lua] The pointshop item id is the item's file name. So, to holster the PS item, you could use a table like this: [lua] local ids = { weapon_zm_rifle = "rifle", // etc } // then, in OnBuy function: ply:PS_HolsterItem( ids[v.ClassName] ) [/lua]
[QUOTE=bran92don;45603659]Is there anyway I can generate the unique ID from someones steamId. I don't know the algorithm for it and I didn't see it anywhere on the wiki.[/QUOTE] Generate? As in print in the console? Or what? Anyways this should help [url]http://wiki.garrysmod.com/page/Player/UniqueID[/url] [url]http://wiki.garrysmod.com/page/GM/PlayerAuthed[/url] [editline]6th August 2014[/editline] [QUOTE=HumbleTH;45603727] The pointshop item id is the item's file name. So, to holster the PS item, you could use a table like this: [lua] local ids = { weapon_zm_rifle = "rifle", // etc } // then, in OnBuy function: ply:PS_HolsterItem( ids[v.ClassName] ) [/lua][/QUOTE] So if I want to do this for example on the m16, it would be something like this? [CODE]local ids = { weapon_ttt_m16 = "m16" } function ITEM:OnBuy(ply) for k, v in pairs( ply:GetWeapons() ) do if v.Kind == self.Kind then ply:StripWeapon( v.ClassName ) ply:PS_HolsterItem( ids[v.ClassName] ) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end[/CODE]
[QUOTE=JasonMan34;45603732]Generate? As in print in the console? Or what? Anyways this should help [url]http://wiki.garrysmod.com/page/Player/UniqueID[/url] [url]http://wiki.garrysmod.com/page/GM/PlayerAuthed[/url] [editline]6th August 2014[/editline] [/QUOTE] Thing is I need to generate it without the player being on the server.
So I made two weapons with detachable silencers on them. Is there a way I can hide the primaryattack from NPC's? (they don't hear sound) I'm pretty sure I can imitate the effect of a real silencer by changing the sound level, but otherwise I can't get primaryattack to run anything clientside?
[QUOTE=bran92don;45603659]Is there anyway I can generate the unique ID from someones steamId. I don't know the algorithm for it and I didn't see it anywhere on the wiki.[/QUOTE] [lua]local uniqueID = util.CRC("gm_" .. steamID .."_gm")[/lua]
How would i get the position of a weapon on the ground? Whenever a weapon leaves the hands of a player through drop weapon the weapon becomes a null entity.
Where's the source to context (the top bar when pressing C) menu? Gonna look if I can make NPCs spawned with toolgun obey weapon overrides from there EDIT: It appears it already works. Only if you, for example, select shotgun and use "spawn using toolgun" and then change NPC weapon override to smg, the toolgun still spawns shotgun NPCs
Ok ive got this is lua/autorun/shared.lua but it doesnt work [CODE] if SERVER then function afkTHING (ply) timer.Create( "Slay", 40, 0, function() local pos = ply:GetPos() if ply:GetPos() !=< Vector(1,0,0) then timer.Start("Slay") ply:KillSilent() ply:Spectate( 5 ) elseif ply:GetPos =< Vector (1,0,0) then timer.Stop("Slay") end end ) hook.Add( "Think", "Afker", afkTHING ) end [/CODE] Any way i can fix it. Cant find the errors because my sandbox is broke and has too many :L
[QUOTE=Skate;45605227]:words:[/QUOTE] You forgot to end your main function. The only thing you ended was the timer. after the line [lua]end )[/lua] you will need another "end" for the first function. Here, this will run your code; [lua]if SERVER then function afkTHING (ply) timer.Create( "Slay", 40, 0, function() local pos = ply:GetPos() if ply:GetPos() !=< Vector(1,0,0) then timer.Start("Slay") ply:KillSilent() ply:Spectate( 5 ) elseif ply:GetPos =< Vector (1,0,0) then timer.Stop("Slay") end end ) end hook.Add( "Think", "Afker", afkTHING ) end[/lua]
[QUOTE=aurum481;45605150]Where's the source to context (the top bar when pressing C) menu? Gonna look if I can make NPCs spawned with toolgun obey weapon overrides from there[/QUOTE] [del]For the module: [B]garrysmod/garrysmod/lua/includes/modules/properties.lua[/B] For the properties themselves (to see how to make them): [B]garrysmod/garrysmod/lua/autorun/properties/[/B][/del] Woops, totally misread that. I'll try to find the menu at the top, if it's available. [B]--Edit--[/B] Found it[B]. [/B]The module: [B]garrysmod/garrysmod/lua/includes/modules/menubar.lua[/B] The options being added to the menubar: [B]garrysmod/garrysmod/lua/autorun/menubar.lua[/B] I just used Notepad++ and searched garrysmod/lua for one of the various drawing options listed in the menu (like "Draw Toolgun Help").
Can someone figure a way to do this: Check how much damage a player has dealt to the other team. Was trying it last night, no luck.... so if ply: has dealt this much damage eg 15 then ... and no I dont want to check if anothers players health is at 15 for an optional way. Its for a gamemode im trying :)
[URL="http://wiki.garrysmod.com/page/GM/PlayerHurt"]this[/URL] provides damage taken (dealt damage) You can also use entity take damage
What would be a good way of getting the direction of a location with two vectors; the first vector being the position from where the direction is being measured from and the second vector being the position from where the direction is retrieved from. E.g - Finding the direction of Vector( 0, 50, 0 ) from Vector( 0, 0, 0 ).
[QUOTE=AnonTakesOver;45608011][URL="http://wiki.garrysmod.com/page/GM/PlayerHurt"]this[/URL] provides damage taken (dealt damage) You can also use entity take damage[/QUOTE] Yeah I used entity take damage after posting the the thread after :L One last thing I set up a test server for stuff and I get an error with my really shitty afk thing. shared.lua: [CODE] if SERVER then function afkTHING (ply) timer.Create( "Slay", 5, 0, function() local pos = ply:GetPos() if ply:GetPos() not <= Vector(1,0,0) then --this line timer.Start("Slay") ply:KillSilent() ply:Spectate( 5 ) elseif ply:GetPos not <= Vector (1,0,0) then --this line timer.Stop("Slay") end end ) end hook.Add( "Think", "Afker", afkTHING ) end [/CODE] "then expected near not" i dont want a then next to not other wise its not going to work?
[QUOTE=Skate;45608259]Yeah I used entity take damage after posting the the thread after :L One last thing I set up a test server for stuff and I get an error with my really shitty afk thing. shared.lua: [CODE] if SERVER then function afkTHING (ply) timer.Create( "Slay", 5, 0, function() local pos = ply:GetPos() if ply:GetPos() not <= Vector(1,0,0) then --this line timer.Start("Slay") ply:KillSilent() ply:Spectate( 5 ) elseif ply:GetPos not <= Vector (1,0,0) then --this line timer.Stop("Slay") end end ) end hook.Add( "Think", "Afker", afkTHING ) end [/CODE] "then expected near not" i dont want a then next to not other wise its not going to work?[/QUOTE] Put the not before ply:GetPos()
[QUOTE=ShadowRanger;45608123]What would be a good way of getting the direction of a location with two vectors; the first vector being the position from where the direction is being measured from and the second vector being the position from where the direction is retrieved from. E.g - Finding the direction of Vector( 0, 50, 0 ) from Vector( 0, 0, 0 ).[/QUOTE] [code](vecReceive - vecMeasure):GetNormal()[/code]
How can I use lua to increase a player's microphone volume. The only relevant function I've found is [url=http://wiki.garrysmod.com/page/Player/VoiceVolume]VoiceVolume[/url] which seems like it can only return the volume not modify it.
[QUOTE=JasonMan34;45603732] So if I want to do this for example on the m16, it would be something like this? [CODE]local ids = { weapon_ttt_m16 = "m16" } function ITEM:OnBuy(ply) for k, v in pairs( ply:GetWeapons() ) do if v.Kind == self.Kind then ply:StripWeapon( v.ClassName ) ply:PS_HolsterItem( ids[v.ClassName] ) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end[/CODE][/QUOTE] Bump?
I am creating an entity and want to use another entity's ent:Fire() to be able to set something off in it. I am currently using this as code - [code] function ENT:AcceptInput( "Disconnect", act, call, data ) call.ConnectedAddons = call.ConnectedAddons = self.pbit constraint.RemoveConstraints( self, "Weld" ) timer.Simple( 10, function() self.attached = false end ) end [/code] and I am getting an error saying that there is a <name expected near "Disconnect". I am guessing you have to use an already defined input? or is there a way to define an input? [editline]k[/editline] nvm, I'm a fuckin retard and didn't understand at first what the wiki said about the hook xD
How can i get if a player is on thirdperson or not? EDIT: Why this code dont give a knife to the players? [CODE] OnStart = function(p,g) p:SetColor(Color(255,0,0,255)) g:SetColor(Color(255,0,0,255)) p:StripWeapons(); g:StripWeapons(); if not p:Crouching() then g:SetPos(p:GetPos()); end if SERVER then p:Give("jb_knife"); g:Give("jb_knife"); end end, OnGuardDied = function(self) activeLR:End(); end, OnPrisonerDied = function(self) activeLR:End(); end[/CODE]
I need help with a NPC I'm coding. Whenever I spawn it. Gmod freezes up on the spot. No errors, no "HL2.exe has stopped working" and when I ctrl+alt+del out of the game there's a black box in the top left corner of the screen. Here's the code [URL="http://pastebin.com/EE7r3XHj"]Pastebin[/URL] If it helps at all, the NPC uses nextbot AI.
How can I disable flags for func_buttons. For example I want to disable the Damage Activates flag but all I've been able to find is the flag for it: [url]https://developer.valvesoftware.com/wiki/Func_button[/url] [code] Flags 1 : Don't move 32 : Toggle 256 : Touch Activates 512 : Damage Activates 1024 : Use Activates 2048 : Starts locked 4096 : Sparks [/code] but I can't find how to change the flags in lua
you must set the flags using bit operators sum values that do you need and set the flags to the entity...Example, i want it toggable and this makes sparks, so: ent:SetKeyValue("spawnflags",tostring(32+4096))
[QUOTE=gonzalolog;45612817]you must set the flags using bit operators sum values that do you need and set the flags to the entity...Example, i want it toggable and this makes sparks, so: ent:SetKeyValue("spawnflags",tostring(32+4096))[/QUOTE] Don't know why you were rated disagree but the code worked fine, thanks for the help.
[QUOTE=Adzter;45612783]How can I disable flags for func_buttons. For example I want to disable the Damage Activates flag but all I've been able to find is the flag for it: [url]https://developer.valvesoftware.com/wiki/Func_button[/url] [code] Flags 1 : Don't move 32 : Toggle 256 : Touch Activates 512 : Damage Activates 1024 : Use Activates 2048 : Starts locked 4096 : Sparks [/code] but I can't find how to change the flags in lua[/QUOTE] if you only want to change the one flag and you don't want to touch the others, you'd have to get the "spawnflags" keyvalue from [url=http://wiki.garrysmod.com/page/GM/EntityKeyValue]GM:EntityKeyValue[/url] and then do [lua]ent:SetKeyValue("spawnflags", bit.band(oldflags, bit.bnot(512)))[/lua]
Sorry, you need to Log In to post a reply to this thread.