• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=Z0mb1n3;48796752]Oh, ok. I'll try that. Thank you yet again for your help. EDIT: What if the goal number is something other than 1? 200, perhaps[/QUOTE] As Portal said it returns a decimal of the time in seconds that it took the render the last frame. Do you need need to ask what some low number divided by 200 is?
[QUOTE=>>oubliette<<;48796905]As Portal said it returns a decimal of the time in seconds that it took the render the last frame. Do you need need to ask what some low number divided by 200 is?[/QUOTE] Please try to understand that I am attempting to learn, and that while it may be a simple concept to you, it is not for me. I know how to divide, but I don't know which operations to use to achieve a certain effect. I am currently using this in a HUDPaint hook to have a decreasing progress bar [code] local Progress local Duration = 10 Progress = ((Progress or 1) - ((Duration * FrameTime()))*200) surface.SetDrawColor(color_black) surface.DrawRect(ScrW()/2 - 100, ScrH()/2 + 200, 200, 100) surface.SetDrawColor(color_red) surface.DrawRect(ScrW()/2 - 100, ScrH()/2 + 200, Progress, 100) [/code] and the progress bar is moving way too fast. Even if the * 200 is removed, the lower the number, the slower the progress is.
[QUOTE=Z0mb1n3;48797121]Please try to understand that I am attempting to learn, and that while it may be a simple concept to you, it is not for me. I know how to divide, but I don't know which operations to use to achieve a certain effect. I am currently using this in a HUDPaint hook to have a decreasing progress bar [code] local Progress local Duration = 10 Progress = ((Progress or 1) - ((Duration * FrameTime()))*200) surface.SetDrawColor(color_black) surface.DrawRect(ScrW()/2 - 100, ScrH()/2 + 200, 200, 100) surface.SetDrawColor(color_red) surface.DrawRect(ScrW()/2 - 100, ScrH()/2 + 200, Progress, 100) [/code] and the progress bar is moving way too fast. Even if the * 200 is removed, the lower the number, the slower the progress is.[/QUOTE] I understand that you're trying to learn but you asked him to repeat what he said but multiply his example by 200. I wouldn't use FrameTime for a progress bar. Use SysTime or something. [lua] -- Start is SysTime when the progress bar started progessing local duration = 10 local secondsElapsed = SysTime() - start; local widthInPixels = (secondsElapsed / duration) * 200; [/lua]
[QUOTE=>>oubliette<<;48797310]I understand that you're trying to learn but you asked him to repeat what he said but multiply his example by 200. I wouldn't use FrameTime for a progress bar. Use SysTime or something. [lua] -- Start is SysTime when the progress bar started progessing local duration = 10 local secondsElapsed = SysTime() - start; local widthInPixels = (secondsElapsed / duration) * 200; [/lua][/QUOTE] Thank you very much, that was very helpful.
[QUOTE=Z0mb1n3;48797121]Please try to understand that I am attempting to learn, and that while it may be a simple concept to you, it is not for me. I know how to divide, but I don't know which operations to use to achieve a certain effect. I am currently using this in a HUDPaint hook to have a decreasing progress bar [code] local Progress local Duration = 10 Progress = ((Progress or 1) - ((Duration * FrameTime()))*200) surface.SetDrawColor(color_black) surface.DrawRect(ScrW()/2 - 100, ScrH()/2 + 200, 200, 100) surface.SetDrawColor(color_red) surface.DrawRect(ScrW()/2 - 100, ScrH()/2 + 200, Progress, 100) [/code] and the progress bar is moving way too fast. Even if the * 200 is removed, the lower the number, the slower the progress is.[/QUOTE] woops, I messed up my post, it should have been FrameTime() / duration, not duration * FrameTime()!
for my swep, how would I set it to change the viewmodel for the just the holder and not everyone im using [code] LocalPlayer():GetViewModel():SetMaterial("phoenix_storms/dome.vtf") --works [/code] right now and it sets it for everyone and self:Owner doesn't work
Anyone know why render.DrawLine draws properly (as in behind objects) but most other render shapes don't? [IMG]https://www.dropbox.com/s/39du6zmd3p86f47/legit.gif?raw=1[/IMG] The GIF above has a render.DrawLine going behind the object (and actually getting hidden), but the render.DrawBox doesn't get hidden at all!
tiny gif is tiny. are you sure you're not just seeing the line get hidden behind the box? [editline]30th September 2015[/editline] [QUOTE=343N;48800532]for my swep, how would I set it to change the viewmodel for the just the holder and not everyone im using [code] LocalPlayer():GetViewModel():SetMaterial("phoenix_storms/dome.vtf") --works [/code] right now and it sets it for everyone and self:Owner doesn't work[/QUOTE] inside your swep you're using self.Owner?
Can someone help me find the addon that tells you info about your server? It was posted here a while ago and I don't know the name of it. I've searched the releases about 10 pages in and didn't find it. I remember reading something about the addon being a paid addon until the release of it on FP. The guy also made it apparent that it is very resource heavy. Those are the only real details I remember, if anyone can help me out that'd be awesome. EDIT: Sorry, I just assumed the post was about anything and not code specific things. If I could delete this I would.
How would I get the highest Z coordinate of a map? I could do a trace from Vector(0,0,0) but that might run into things.
[QUOTE=Z0mb1n3;48800592]tiny gif is tiny. are you sure you're not just seeing the line get hidden behind the box? [editline]30th September 2015[/editline] inside your swep you're using self.Owner?[/QUOTE] yeah, because that gets the holder of the swep doesn't it
[QUOTE=343N;48800922]yeah, because that gets the holder of the swep doesn't it[/QUOTE] Yeah, I just wanted to make sure you were actually using it in a SWEP. Do you have more code than just that one line? Like, where in your SWEP code are you trying this?
[QUOTE=Z0mb1n3;48800940]Yeah, I just wanted to make sure you were actually using it in a SWEP. Do you have more code than just that one line? Like, where in your SWEP code are you trying this?[/QUOTE] probably horrendously coded, but [code]]if SERVER then AddCSLuaFile() AddCSLuaFile("weapon_propcannon.lua") resource.AddFile("materials/vgui/ttt/icon_boxlauncher.png") end if CLIENT then SWEP.PrintName = "Box Cannon" SWEP.Slot = 6 -- add 1 to get the slot number key SWEP.ViewModelFOV = 54 SWEP.ViewModelFlip = false end -- Always derive from weapon_tttbase. --- Standard GMod values SWEP.Base = "weapon_tttbase" SWEP.Primary.Automatic = false SWEP.Primary.Damage = 0 SWEP.Primary.Ammo = "HelicopterGun" SWEP.Kind = WEAPON_EQUIP1 SWEP.Primary.NumShots = 1 SWEP.Primary.Delay = 1 SWEP.Primary.ClipSize = 2 SWEP.Primary.ClipMax = 2 SWEP.Primary.DefaultClip = 2 SWEP.ViewModel = "models/weapons/c_rpg.mdl" SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl" function SWEP:Holster() LocalPlayer():GetViewModel():SetMaterial("") self:EmitSound(Sound("buttons/combine_button2.wav"), 50, 80, 0.8, CHAN_AUTO) end function SWEP:PostDrawViewModel() LocalPlayer():GetViewModel():SetMaterial("effects/prisonmap_disp") if (self:Clip1() <= 0) then self:SetMaterial("effects/combinedisplay002b") LocalPlayer():GetViewModel():SetMaterial("effects/combinedisplay002b") end if (self:Clip1() = 0) self:EmitSound(Sound("items/battery_pickup.wav"), 50, 90, 0.8, CHAN_AUTO) end end function SWEP:OnRemove() LocalPlayer():GetViewModel():SetMaterial("") end function SWEP:OnDrop() LocalPlayer():GetViewModel():SetMaterial("") end function SWEP:OwnerChanged() LocalPlayer():GetViewModel():SetMaterial("") end function SWEP:Initialize() self:SetHoldType("rpg") self:SetMaterial("effects/prisonmap_disp") self:SetDeploySpeed(1) end function SWEP:Deploy() LocalPlayer():GetViewModel():SetMaterial("effects/prisonmap_disp") if (self:Clip1() <= 0) then LocalPlayer():GetViewModel():SetMaterial("effects/combinedisplay002b") self:SetMaterial("effects/combinedisplay002b") self:EmitSound(Sound("common/warning.wav"), 50, 80, 0.8, CHAN_AUTO) end end SWEP.Kind = WEAPON_EQUIP1 SWEP.AutoSpawnable = false SWEP.CanBuy = { ROLE_TRAITOR } SWEP.InLoadoutFor = nil SWEP.LimitedStock = true SWEP.NoSights = true if CLIENT then SWEP.Icon = "materials/vgui/ttt/icon_boxlauncher.png" SWEP.EquipMenuData = { type = "Box Cannon", desc = "Fires deadly wooden boxes that shatter anything\nit touches, as well as itself!" }; end function SWEP:shootEnt() local tr = self.Owner:GetEyeTrace() self:EmitSound(Sound("weapons/grenade_launcher1.wav"), 50, 150, 0.8, CHAN_AUTO) if (!SERVER) then return end prop = ents.Create("prop_physics") prop:SetModel(("models/props_junk/wood_crate001a.mdl")) prop:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector()* 64)) prop:SetAngles(self.Owner:EyeAngles()) prop:Spawn() prop:SetMaterial("effects/prisonmap_disp") prop:SetHealth(100) local phys = prop:GetPhysicsObject() if !(phys && IsValid(phys)) then prop:Remove() return end phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()* math.pow(tr.HitPos:Length(),5)) prop:AddCallback("PhysicsCollide", function(self, data) local ent = data.HitEntity if IsValid(ent) then -- check for whatever you want here, really prop:TakeDamage(100, ent, ent) ent:TakeDamage(100, phys, phys) end timer.Simple(3, function() self:SetRenderFX(kRenderFxStrobeFaster) end) timer.Simple(5, function() self:TakeDamage(100, self, self) end) if (not self:CanPrimaryAttack()) then LocalPlayer():GetViewModel():SetMaterial("effects/combinedisplay002b") self:SetMaterial("effects/combinedisplay002b") self:EmitSound(Sound("common/warning.wav"), 50, 100, 0.8, CHAN_AUTO) end end) end function SWEP:PrimaryAttack() if (not self:CanPrimaryAttack()) then LocalPlayer():GetViewModel():SetMaterial("effects/combinedisplay002b") self:SetMaterial("effects/combinedisplay002b") self:EmitSound(Sound("common/warning.wav"), 50, 100, 0.8, CHAN_AUTO) end if (self:CanPrimaryAttack()) then self:TakePrimaryAmmo(1) self:shootEnt() self:SetNextPrimaryFire(CurTime() + 1) self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) end end function SWEP:Think() end function SWEP:Reload() end[/code]
PostDrawViewModel has arguments. First one is the viewmodel entity itself. Use that.
I'm having 2 problems if anyone is willing to help. First I have created a SENT for my gamemode to act as an NPC (i.e. Car dealer) which has a hl2 citizen model. The Type is "anim" and the base is "base_anim" and by default it spawns in the T pose but I managed to fix this by setting its sequence. The problem is the eyes. All of these SENT instances are looking to the corner of their head and they dont look around. The idle animation works perfectly and they move around a little. SetEyeTarget and SetEyeAngles do absolutely nothing to remedy this. The second problem I am having is a desync in NWvars for doors. The server says they are owned by the client says they arent. I tried to use networkvars instead which requires a SetupDataTables function on each door but by the time the server created my override function it was too late to be called. I'd prefer not to network it all manually but if thats possible. A third issue which is basically just an extension of the second, is how would I go about overriding SetupDataTables on an entity (SENT) that I am creating, in time for it to be called and create my networkvars? Any and all help is appreciated.
Well now that I've got the loop working and created the entities, I've ran into two problems. Falco pointed me to the spawn function in Darkrp.createEntity, and said it has to return an entity. I can't really find any examples of this anywhere though. What I'm trying is this, which doesn't seem to work. Am I meant to use a hook for this or something? [code]spawn = function(ply, tr, tblEnt) local foodEnt = ents.Create("zelpa_basefood") foodEnt:SetPos( ply:GetEyeTrace().HitPos ) foodEnt:SetFoodType( soda ) return foodEnt end, [/code] The second problem probably has an obvious answer, but the entities aren't being added to the f4 menu. I can use the commands to spawn them fine, but they don't appear in any of the tabs.
[QUOTE=Z0mb1n3;48801028]PostDrawViewModel has arguments. First one is the viewmodel entity itself. Use that.[/QUOTE] im a bit confused by this but a bigger newly discovered issue is the material isn't set for everyone when it runs out of ammo [code]self:SetMaterial("effects/combinedisplay002b")[/code] how can i make it so the worldmodel changes for everyone not just clientside for the person who is holding it
i don't wanna keep asking questions and bog up the thread. if someone could add me on steam or something that'd be great, cause im getting a bunch of errors i don't understand and the code still seems to work regardless of the errors? i'm really confused [editline]1st October 2015[/editline] errors like [code][ERROR] lua/weapons/weapon_propcannon.lua:131: attempt to call method 'CanPrimaryAttack' (a nil value) 1. unknown - lua/weapons/weapon_propcannon.lua:131 [/code] even though functions absolutely fine same with [code][ERROR] lua/weapons/weapon_propcannon.lua:73: attempt to call global 'LocalPlayer' (a nil value) 1. unknown - lua/weapons/weapon_propcannon.lua:73 [/code] like holy shit this boggles my mind
[QUOTE=343N;48801671]i don't wanna keep asking questions and bog up the thread. if someone could add me on steam or something that'd be great, cause im getting a bunch of errors i don't understand and the code still seems to work regardless of the errors? i'm really confused [editline]1st October 2015[/editline] errors like [code][ERROR] lua/weapons/weapon_propcannon.lua:131: attempt to call method 'CanPrimaryAttack' (a nil value) 1. unknown - lua/weapons/weapon_propcannon.lua:131 [/code] even though functions absolutely fine same with [code][ERROR] lua/weapons/weapon_propcannon.lua:73: attempt to call global 'LocalPlayer' (a nil value) 1. unknown - lua/weapons/weapon_propcannon.lua:73 [/code] like holy shit this boggles my mind[/QUOTE] You are running clientside code on the server. LocalPlayer() only exists on the client realm.
I'm completely fresh to glua. How does 'k,v in pairs' actually work? I see it a lot in ESP's.
[QUOTE=ilmon3y;48806584]I'm completely fresh to glua. How does 'k,v in pairs' actually work? I see it a lot in ESP's.[/QUOTE] It loops through a table where k is the key and v is the value.
I dont know where to begin with the one [CODE] Find a entity in a sphere Check if Entity is on fire remove fire [/CODE] probably going to look through ulx and see how they unignite something
[QUOTE=DiscoKnight;48807699]I dont know where to begin with the one [CODE] Find a entity in a sphere Check if Entity is on fire remove fire [/CODE][/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Global/pairs"]Global.pairs[/URL] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/IsOnFire"]Entity:IsOnFire[/URL] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/Extinguish"]Entity:Extinguish[/URL]
[QUOTE=Zelpa;48801137]Well now that I've got the loop working and created the entities, I've ran into two problems. Falco pointed me to the spawn function in Darkrp.createEntity, and said it has to return an entity. I can't really find any examples of this anywhere though. What I'm trying is this, which doesn't seem to work. Am I meant to use a hook for this or something? [code]spawn = function(ply, tr, tblEnt) local foodEnt = ents.Create("zelpa_basefood") foodEnt:SetPos( ply:GetEyeTrace().HitPos ) foodEnt:SetFoodType( soda ) return foodEnt end, [/code] [/QUOTE] You have to call foodEnt:Spawn() before returning.
[QUOTE=Z0mb1n3;48807707][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Global/pairs"]Global.pairs[/URL] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/IsOnFire"]Entity:IsOnFire[/URL] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/Extinguish"]Entity:Extinguish[/URL][/QUOTE] Trying that now :) -EDIT- WORKED :D
[QUOTE=Z0mb1n3;48800592]tiny gif is tiny. are you sure you're not just seeing the line get hidden behind the box?[/QUOTE] Yeah, sorry about the gif-it's not just getting hidden by the box, there's a frame of the .gif where the box is CLEARLY behind the object and the line isn't, but it's understandable if you couldn't see it. This is on a DModelPanel by the way, and I'm drawing the line (and the cube) both in the Panel:DrawModel function (under self.Entity:DrawModel()). I'll provide some example code later if you want to test out something (or maybe there will be a really obvious mistake in it).
[QUOTE=Bo98;48807725]You have to call foodEnt:Spawn() before returning.[/QUOTE] Gives me this error now. [code]on line 196. The best help I can give you is this: bad argument #3 to 'SetFunc' (string expected, got nil)[/code] Which is absurd because my init.lua is only 90 lines long.
[code]function SWEP:shootEnt() local tr = self.Owner:GetEyeTrace() self:EmitSound(Sound("weapons/grenade_launcher1.wav"), 400, 90, 0.7, CHAN_AUTO) if (!SERVER) then return end prop = ents.Create("prop_physics") prop:SetModel(("models/props_junk/wood_crate001a.mdl")) prop:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector()* 32)) prop:SetAngles(self.Owner:EyeAngles()) prop:Spawn() prop:SetMaterial("effects/prisonmap_disp") --line 144 --prop:SetMaterial("models/gman/gman_facehirez.vtf") prop:SetHealth(1000) local phys = prop:GetPhysicsObject() if !(phys && IsValid(phys)) then prop:Remove() return end phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()* math.pow(tr.HitPos:Length(),5)) phys:SetMaterial("ice") --phys:SetMaterial("gmod_bouncy") prop:AddCallback("PhysicsCollide", function(self, data) local ent = data.HitEntity if IsValid(ent) then -- check for whatever you want here, really self:EmitSound(Sound("npc/vort/foot_hit.wav"), 420, 100, 1, CHAN_AUTO) prop:TakeDamage(1000, ent, ent) ent:TakeDamage(1000, phys, phys) end timer.Simple(3, function() if IsValid(self) then self:SetMaterial("effects/combinedisplay002b") end end) --line 143 timer.Simple(5, function() if IsValid(self) then self:TakeDamage(1000, self, self) end end) if (not self:CanPrimaryAttack()) then LocalPlayer():GetViewModel():SetMaterial("effects/combinedisplay002b") self:SetMaterial("effects/combinedisplay002b") end end) end [/code] produces [code] [ERROR] lua/weapons/weapon_propcannon.lua:143: '=' expected near '<eof>' 1. unknown - lua/weapons/weapon_propcannon.lua:0 [/code] [editline]2nd October 2015[/editline] now it's gone from that to [code] [ERROR] lua/weapons/weapon_propcannon.lua:144: function arguments expected near '<eof>' 1. unknown - lua/weapons/weapon_propcannon.lua:0 [/code]
[QUOTE=Zelpa;48808075]Gives me this error now. [code]on line 196. The best help I can give you is this: bad argument #3 to 'SetFunc' (string expected, got nil)[/code] Which is absurd because my init.lua is only 90 lines long.[/QUOTE] I have no idea what that's referring to since you didn't give the whole error (including stack trace).
[QUOTE=Bo98;48808717]I have no idea what that's referring to since you didn't give the whole error (including stack trace).[/QUOTE] Yep, that was stupid of me. Here's the entire error. [code][ERROR] A runtime error has occurred in "addons/darkrpmodification/lua/entities/zelpa_basefood/init.lua" on line 196. The best help I can give you is this: bad argument #3 to 'SetFunc' (string expected, got nil) Hints: - No hints, sorry. The responsibility for this error lies with (the authors of) one (or more) of these files: 1. addons/darkrpmodification/lua/entities/zelpa_basefood/init.lua on line 196 2. gamemodes/darkrp/gamemode/libraries/fn.lua on line 80 3. gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua on line 606 4. gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua on line 17 5. gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua on line 75 6. gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua on line 139 ------- End of Simplerr error ------- [/code]
Sorry, you need to Log In to post a reply to this thread.