• What do you need help with? V3
    6,419 replies, posted
[QUOTE=G4MB!T;38204062]if you are inside a swep (IE PrimaryAttack) use: [lua] self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER); [/lua] else you can force it on the player by using [lua] ply:GetActiveWeapon():SendWeaponAnim(ACT_VM_HITCENTER) [/lua][/QUOTE] You may have misread my post, I need this for third person animations, not the view model.
[QUOTE=samm5506;38204248]You may have misread my post, I need this for third person animations, not the view model.[/QUOTE] You might not like this, but use SetWeaponHoldType("melee") on the weapon, then self.Owner:SetAnimation( PLAYER_ATTACK1 ), then set the holdtype back.
[QUOTE=skullorz;38204278]You might not like this, but use SetWeaponHoldType("melee") on the weapon, then self.Owner:SetAnimation( PLAYER_ATTACK1 ), then set the holdtype back.[/QUOTE] This is something I have tried, but unfortunately it's not exactly networked. I figure there's a better way to do this with animations so that it is networked.
[QUOTE=samm5506;38204305]This is something I have tried, but unfortunately it's not exactly networked. I figure there's a better way to do this with animations so that it is networked.[/QUOTE] You need to call that entire function shared
[QUOTE=skullorz;38204453]You need to call that entire function shared[/QUOTE] SWEP.PrimaryFire is only called on the client for the weapon owner.
I'm trying to get a bone position however it keeps telling me the boneindex is nil. I think it's because I'm calling it before the player has gotten any model yet but I'm unsure on how to fix it. If I hook it to ShowHelp or anything similar it works. I'm calling it in either the loadout or spawn hook. [editline]Edited:[/editline] Nvm, Got it. Is there any prettier way though? [lua]function RemoveHead( ply ) timer.Simple( 5, function() ply:ManipulateBoneScale( ply:LookupBone("ValveBiped.Bip01_Head1"), Vector(0,0,0)) end ) end hook.Add( "PlayerLoadout", "RemoveHead", RemoveHead)[/lua]
Garrysmod error when you try crack a keypad, any help would be greatly appreciated [lua] [ERROR] lua/includes/modules/timer.lua:62: timer.Create - called wrong! 1. error - [C]:-1 2. Create - lua/includes/modules/timer.lua:62 3. unknown - gamemodes/darkrp/entities/weapons/keypad_cracker/shared.lua:74 [/lua] Shared.lua for the keypad cracker ------------------------------------------------- [lua] if (SERVER) then AddCSLuaFile("shared.lua") end if (CLIENT) then SWEP.PrintName = "Keypad Cracker" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = true end -- Variables that are used on both client and server SWEP.Author = "Chief Tiger" SWEP.Instructions = "Left click to crack a keypad" SWEP.Contact = "" SWEP.Purpose = "" SWEP.ViewModelFOV = 62 SWEP.ViewModelFlip = false SWEP.ViewModel = Model("models/weapons/v_c4.mdl") SWEP.WorldModel = Model("models/weapons/w_c4.mdl") SWEP.Spawnable = false SWEP.AdminSpawnable = true SWEP.Sound = Sound("weapons/deagle/deagle-1.wav") SWEP.Primary.ClipSize = -1 -- Size of a clip SWEP.Primary.DefaultClip = 0 -- Default number of bullets in a clip SWEP.Primary.Automatic = false -- Automatic/Semi Auto SWEP.Primary.Ammo = "" SWEP.Secondary.ClipSize = -1 -- Size of a clip SWEP.Secondary.DefaultClip = -1 -- Default number of bullets in a clip SWEP.Secondary.Automatic = false -- Automatic/Semi Auto SWEP.Secondary.Ammo = "" SWEP.KeyCrackTime = 15 /*--------------------------------------------------------- Name: SWEP:Initialize() Desc: Called when the weapon is first loaded ---------------------------------------------------------*/ function SWEP:Initialize() if (SERVER) then self:SetWeaponHoldType("normal") end end /*--------------------------------------------------------- Name: SWEP:PrimaryAttack() Desc: +attack1 has been pressed ---------------------------------------------------------*/ function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + .4) if self.IsCracking then return end local trace = self.Owner:GetEyeTrace() local e = trace.Entity if IsValid(e) and trace.HitPos:Distance(self.Owner:GetShootPos()) <= 300 and (e:GetClass() == "sent_keypad") then self.IsCracking = true self.StartCrack = CurTime() self.EndCrack = CurTime() + self.KeyCrackTime if SERVER then self:SetWeaponHoldType("pistol") timer.Create("KeyCrackSounds", 1, self.KeyCrackTime, function(wep) wep:EmitSound("buttons/blip2.wav", 100, 100) end, self) end if CLIENT then self.Dots = self.Dots or "" timer.Create("KeyCrackDots", 0.5, 0, function(wep) if not wep:IsValid() then timer.Destroy("KeyCrackDots") return end local len = string.len(wep.Dots) local dots = {[0]=".", [1]="..", [2]="...", [3]=""} wep.Dots = dots[len] end, self) end end end function SWEP:Holster() self.IsCracking = false if SERVER then timer.Destroy("KeyCrackSounds") end if CLIENT then timer.Destroy("KeyCrackDots") end return true end function SWEP:Succeed() self.IsCracking = false local trace = self.Owner:GetEyeTrace() if IsValid(trace.Entity) and trace.Entity:GetClass() == "sent_keypad" then local owner = trace.Entity:GetNWEntity("keypad_owner") trace.Entity:SetNWBool("keypad_access", true) trace.Entity:SetNWBool("keypad_showaccess", true) if (SERVER) then trace.Entity:EmitSound("buttons/button11.wav") owner:SendLua("LocalPlayer():ConCommand(\"+gm_special "..trace.Entity:GetNWInt("keypad_keygroup1").."\")") timer.Simple(trace.Entity:GetNWInt("keypad_length1"), function() owner:SendLua("LocalPlayer():ConCommand(\"-gm_special "..trace.Entity:GetNWInt("keypad_keygroup1").."\")") end) end timer.Simple(2, function() trace.Entity:SetNWBool("keypad_showaccess", false) end) end if SERVER then timer.Destroy("KeyCrackSounds") end if CLIENT then timer.Destroy("KeyCrackDots") end end function SWEP:Fail() self.IsCracking = false if SERVER then self:SetWeaponHoldType("normal") timer.Destroy("KeyCrackSounds") end if CLIENT then timer.Destroy("KeyCrackDots") end end function SWEP:Think() if self.IsCracking then local trace = self.Owner:GetEyeTrace() if not IsValid(trace.Entity) then self:Fail() end if trace.HitPos:Distance(self.Owner:GetShootPos()) > 300 or (trace.Entity:GetClass() != "sent_keypad") then self:Fail() end if self.EndCrack <= CurTime() then self:Succeed() end end end function SWEP:DrawHUD() if self.IsCracking then self.Dots = self.Dots or "" local w = ScrW() local h = ScrH() local x,y,width,height = w/2-w/10, h/3, w/5, h/15 draw.RoundedBox(8, x, y, width, height, Color(10,10,10,120)) local time = self.EndCrack - self.StartCrack local curtime = CurTime() - self.StartCrack local status = curtime/time local BarWidth = status * (width - 16) + 8 draw.RoundedBox(8, x+8, y+8, BarWidth, height - 16, Color(255-(status*255), 0+(status*255), 0, 255)) draw.SimpleText("Cracking"..self.Dots, "Trebuchet24", w/2, h/2 + height/2, Color(255,255,255,255), 1, 1) end end function SWEP:SecondaryAttack() self:PrimaryAttack() end [/lua]
So I've tried several things, but everytime I try to color my printer differently it just turns to the default Purple. [lua]function ENT:Initialize() self:SetModel("models/props_c17/consolebox01a.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:SetColor( (125,80,30,255) ) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end self.sparking = false self.damage = 100 self.IsMoneyPrinter = true timer.Simple(180, PrintMore) self:SetNWInt("PrintA",0) end[/lua]
Try Color(125,80,30,255) instead of just (125,80,30,255)
[QUOTE=h3inrich;38204837]Garrysmod error when you try crack a keypad, any help would be greatly appreciated [lua] [ERROR] lua/includes/modules/timer.lua:62: timer.Create - called wrong! 1. error - [C]:-1 2. Create - lua/includes/modules/timer.lua:62 3. unknown - gamemodes/darkrp/entities/weapons/keypad_cracker/shared.lua:74 [lua]-fuck ton of code noone wants to read-[/lua][/QUOTE] what must be going through your head in order to think "ye..people want to read through 150+ lines of code to find an error" if you have a look at the code for the timer module it will error if the name is not a string, reps or delay are not numbers, the callback is not a function or you have more than 4 args. change: [lua] timer.Create("KeyCrackDots", 0.5, 0, function(wep) if not wep:IsValid() then timer.Destroy("KeyCrackDots") return end local len = string.len(wep.Dots) local dots = {[0]=".", [1]="..", [2]="...", [3]=""} wep.Dots = dots[len] end, self) [/lua] to: [lua] timer.Create("KeyCrackDots", 0.5, 0, function(wep) if not wep:IsValid() then timer.Destroy("KeyCrackDots") return end local len = string.len(wep.Dots) local dots = {[0]=".", [1]="..", [2]="...", [3]=""} wep.Dots = dots[len] end) [/lua]
[QUOTE=G4MB!T;38205308]what must be going through your head in order to think "ye..people want to read through 150+ lines of code to find an error" if you have a look at the code for the timer module it will error if the name is not a string, reps or delay are not numbers, the callback is not a function or you have more than 4 args. change: [lua] timer.Create("KeyCrackDots", 0.5, 0, function(wep) if not wep:IsValid() then timer.Destroy("KeyCrackDots") return end local len = string.len(wep.Dots) local dots = {[0]=".", [1]="..", [2]="...", [3]=""} wep.Dots = dots[len] end, self) [/lua] to: [lua] timer.Create("KeyCrackDots", 0.5, 0, function(wep) if not wep:IsValid() then timer.Destroy("KeyCrackDots") return end local len = string.len(wep.Dots) local dots = {[0]=".", [1]="..", [2]="...", [3]=""} wep.Dots = dots[len] end) [/lua][/QUOTE] I tried that too, now when i try cracking i get this error instead.. Hmm. [lua] ERROR: Hook 'CheckTimers' Failed: gamemodes/darkrp/entities/weapons/keypad_cracker/shared.lua:75: attempt to index local 'wep' (a nil value) Removing Hook 'CheckTimers' [/lua]
thats because wep doesnt exist. change it to self
[QUOTE=G4MB!T;38205472]thats because wep doesnt exist. change it to self[/QUOTE] This is what i renamed, and now it's complaining about "self". Excuse my lack of knowledge with programming. [lua] timer.Create("KeyCrackDots", 0.5, 0, function(self) if not self:IsValid() then timer.Destroy("KeyCrackDots") return end local len = string.len(self.Dots) local dots = {[0]=".", [1]="..", [2]="...", [3]=""} self.Dots = dots[len] end) [/lua] [lua] ERROR: Hook 'CheckTimers' Failed: gamemodes/darkrp/entities/weapons/keypad_cracker/shared.lua:75: attempt to index local 'self' (a nil value) Removing Hook 'CheckTimers' [/lua]
Remove the self in "function(self)"
Change function(self) to just function() [editline]27th October 2012[/editline] ninjahawke
[lua] G_CHARSELECTVGUI.ListHolder = vgui.Create("DPanelList", G_CHARSELECTVGUI) G_CHARSELECTVGUI.ListHolder:SetPos( 5, 5 ) G_CHARSELECTVGUI.ListHolder:SetSize(290, ScrH() - 210) G_CHARSELECTVGUI.ListHolder:EnableVerticalScrollbar(true) G_CHARSELECTVGUI.ListHolder:SetVisible(false) timer.Simple(0.01 * 200, function() G_CHARSELECTVGUI.ListHolder:SetVisible(true) end) [/lua] Its not appearing, at all.
[QUOTE=Blackfire76;38205739][lua] G_CHARSELECTVGUI.ListHolder = vgui.Create("DPanelList", G_CHARSELECTVGUI) G_CHARSELECTVGUI.ListHolder:SetPos( 5, 5 ) G_CHARSELECTVGUI.ListHolder:SetSize(290, ScrH() - 210) G_CHARSELECTVGUI.ListHolder:EnableVerticalScrollbar(true) G_CHARSELECTVGUI.ListHolder:SetVisible(false) timer.Simple(0.01 * 200, function() G_CHARSELECTVGUI.ListHolder:SetVisible(true) end) [/lua] Its not appearing, at all.[/QUOTE] G_CHARSELECTVGUI.ListHolder:SetVisible(false) remove that line to change it to false
Is there anyway to block people spawning/duplicating things from the creation tab? Not so great when people spawn health and armor packs on a RP server. Thanks.
Found a solution for broken SNPC's. Turns out that [B]ai.GetTaskID[/B] function is bugged out and always returns nil. If anyone has broken SNPCs, I've made a [url=http://pastebin.com/h2P9yTxX]temporary fix[/url] until Garry gets around to this.
[QUOTE=twoski;38201785]is there a hook that controls what decals/effects are used when you shoot a player? I searched the base gamemode files and i didn't see anything, maybe there's some other file i missed?[/QUOTE] On the client, there's SWEP:DoImpactEffect.
Is there a way to stop a player moving his view when rightclicking, inside a weapon?
How can I get a tool to use the new keyboard input instead of the old keypad input?
[lua] local FacText = vgui.Create("DLabel", FT) FacText:SetFont("Intro_MainText") FacText:SetColor(Color(220,200,100,200)) FacText:SetText(v.name) FacText:SizeToContents() FacText:SetPos((290 / 2) - (FacText:GetWide() / 2), (80 / 2) - (FacText:GetTall() / 2)) [/lua] It works, perfectly, but console spams errors all over the joint. This, repeatedly: [code] [ERROR] lua/vgui/dlabel.lua:68: attempt to index local 'col' (a number value) 1. ApplySchemeSettings - lua/vgui/dlabel.lua:68 2. unknown - lua/vgui/dlabel.lua:74 [/code]
Are you sure it's that line? Comment out FacText:SetColor(Color(220,200,100,200))***
[QUOTE=garry;38212570]Are you sure it's that line? Comment out FacText:SetColor(Color(220,200,100,200))***[/QUOTE] That worked, errors have stopped. Another thing, the errors from the SetColor seem to be random. Sometimes they are there, sometimes they aren't.
It really shouldn't have fixed anything
I have a simple command that worked in the beta but not the final [code]] ess_stack 1 0 0 20 [ERROR] lua/ess.lua:60: bad argument #2 to '__add' (Angle expected, got userdata) 1. __add - [C]:-1 2. unknown - lua/ess.lua:60 3. unknown - lua/includes/modules/concommand.lua:69[/code] Line 60 is the SetAngles one (27 below): [lua]function ESS_Stack(ply, cmd, args) --args: num (def 1), dx (inches), dy, dz (def 6), dpitch (degrees), dyaw, droll, freeze (def 1) local trace = util.GetPlayerTrace(ply) local traceRes = util.TraceLine( trace ) if traceRes.HitNonWorld then local target = traceRes.Entity if target:IsPlayer() then return 1; else ess_targetmdl = target:GetModel() ess_targetpos = target:GetPos() ess_targetang = target:GetAngles() ess_targetfrz = target:GetPhysicsObject():IsMoveable() args[1] = args[1] or 1 -- stack 1 object if not specified undo.Create("ess_stack") for i = 1, args[1] do local ess_ent=ents.Create(target:GetClass()) ess_ent:SetModel(ess_targetmdl) args[2] = args[2] or 0 args[3] = args[3] or 0 args[4] = args[4] or 6 -- move 6 inches up if no translation specified ess_ent:SetPos(ess_targetpos + Vector(i*args[2], i*args[3], i*args[4])) args[5] = args[5] or 0 args[6] = args[6] or 0 args[7] = args[7] or 0 -- don't rotate if not specified args[8] = args[8] or 1 ess_ent:SetAngles(ess_targetang + Vector(i*args[5], i*args[6], i*args[7])) ess_ent:Spawn() if args[8] then if !ess_targetfrz then ess_ent:GetPhysicsObject():EnableMotion(false) end end undo.AddEntity(ess_ent) end undo.Finish() end end end concommand.Add("ess_stack", ESS_Stack) [/lua] [editline]27th October 2012[/editline] Figured it out, turned the args into an angle instead of a vector [editline]27th October 2012[/editline] although my undo doesn't work [editline]27th October 2012[/editline] had to set the undo player :downs: i'll just leave now
[QUOTE=garry;38212916]It really shouldn't have fixed anything[/QUOTE] :pwn: What's wrong then.
I'm having a real hard time working with fonts, I understand the new system easy enough how ever.. When I get in-game, either the font I'm using works but soon-after fucks up and changes to some ugly ass bold font. Or when I use the context menu it'll change, or when I shift-tab into steam it'll change. I can't get MY specific font to stick. I'm not sure if this is a GM13 bug, but it sure is annoying.
How do you create a ragdoll clientside?
Sorry, you need to Log In to post a reply to this thread.