• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[t]http://images.akamai.steamusercontent.com/ugc/93851906627098777/83E723D04370D0B1D3C2565BB92D144D5B3C898A/[/t] How can I make the NPC hold the weapon just like how it is in the Frame?
[QUOTE=dannyf127;51880071][t]http://images.akamai.steamusercontent.com/ugc/93851906627098777/83E723D04370D0B1D3C2565BB92D144D5B3C898A/[/t] How can I make the NPC hold the weapon just like how it is in the Frame?[/QUOTE] Set their hold type to passive.
I'm trying to draw a beam along with a sprite to emulate the slam laser thingy. However for some reason even though the trace hits, the sprite gets kinda bugged out after some distance and I have no idea if it's the matter of code or material values. Images will show it better: This is how everything should be, the SLAM on the right shows its max trace length, the one on the left impacts the bathtub correctly. [THUMB]http://i.imgur.com/OAV25C9.jpg[/THUMB] This is bugged out - even though the trace on the left hits the bathtub it seems to draw the bathtub on top of the trace even though this has been produced simply by moving the tub' from the first pic a little bit higher. [THUMB]http://i.imgur.com/OjJr3jl.jpg[/THUMB] [code] local laserLine = Material("effects/laser1") local splodemat = Material("effects/redflare") splodemat:SetInt("$spriterendermode", 9) splodemat:SetInt("$ignorez", 0) laserLine:SetInt("$spriterendermode", 9) laserLine:SetInt("$ignorez", 0) if (CLIENT) then function ENT:Draw() self:DrawModel() local tracedata = {} tracedata.start = self:GetPos() + self.LaserOffset tracedata.endpos = self:GetPos() + self.LaserOffset + self:GetUp() * self.LaserLength tracedata.filter = self self.LaserTrace = util.TraceLine(tracedata) self:SetRenderBoundsWS(self.LaserTrace.StartPos, self.LaserTrace.HitPos ) local glowStartSize = math.random(5,12) local glowEndSize = math.random(5,12) local lineWidth = math.random(1,5) cam.Start3D() render.SetMaterial(splodemat) render.DrawSprite(self.LaserTrace.StartPos, glowStartSize, glowStartSize, Color(255, 255, 255, 255)) render.DrawSprite(self.LaserTrace.HitPos, glowEndSize, glowEndSize, Color(255, 255, 255, 255)) render.SetMaterial(laserLine) render.DrawBeam(self.LaserTrace.StartPos, self.LaserTrace.HitPos, lineWidth, 1, 1, Color( 255, 25, 25, 255 ) ) cam.End3D() end end [/code] Excuse any code heresy, I'm pretty much green in terms of drawing and stuff in glua.
-snip-
[QUOTE=Failure;51881338]I'm trying to draw a beam along with a sprite to emulate the slam laser thingy. However for some reason even though the trace hits, the sprite gets kinda bugged out after some distance and I have no idea if it's the matter of code or material values. Images will show it better: This is how everything should be, the SLAM on the right shows its max trace length, the one on the left impacts the bathtub correctly. [THUMB]http://i.imgur.com/OAV25C9.jpg[/THUMB] This is bugged out - even though the trace on the left hits the bathtub it seems to draw the bathtub on top of the trace even though this has been produced simply by moving the tub' from the first pic a little bit higher. [THUMB]http://i.imgur.com/OjJr3jl.jpg[/THUMB] -snip- Excuse any code heresy, I'm pretty much green in terms of drawing and stuff in glua.[/QUOTE] Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/DrawTranslucent]ENT:DrawTranslucent[/url]
[QUOTE=YourStalker;51881327]Set their hold type to passive.[/QUOTE] Ahhh, I was doing that with CW weapons and was getting errors, tried it with an ar2 and it worked. Thanks.
How do I set multiple game flags to a PhysObj ? I'm trying to make saw blades thrown stick to walls and chop zombies. Apparently it requires both FVPHYSICS_DMG_SLICE (1) and FVPHYSICS_WAS_THROWN (256) to be set, but I can't figure out how to set both of them at the same time.
[QUOTE=Kenny032;51883245]How do I set multiple game flags to a PhysObj ? I'm trying to make saw blades thrown stick to walls and chop zombies. Apparently it requires both FVPHYSICS_DMG_SLICE (1) and FVPHYSICS_WAS_THROWN (256) to be set, but I can't figure out how to set both of them at the same time.[/QUOTE] The way it works is using a thing called bitflags. (Google them, they are actually really cool when you know how to use them, learn what the AND and OR bitwise operations do for starters) But what you can do in Lua to get what you're looking for is to give [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/PhysObj/AddGameFlag]PhysObj:AddGameFlag[/url] the product of the bitwise AND operation of FVPHYSICS_DMG_SLICE and FVPHYSICS_WAS_THROWN. Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/bit/bor]bit.bor[/url]. [lua]physObj:AddGameFlag(bit.bor(FVPHYSICS_DMG_SLICE, FVPHYSICS_WAS_THROWN))[/lua] The function would probably be better off called "SetGameFlags", but here in GMod, we don't name things logically...
[QUOTE=Kenny032;51883245]How do I set multiple game flags to a PhysObj ? I'm trying to make saw blades thrown stick to walls and chop zombies. Apparently it requires both FVPHYSICS_DMG_SLICE (1) and FVPHYSICS_WAS_THROWN (256) to be set, but I can't figure out how to set both of them at the same time.[/QUOTE] The flags are bit fields, so use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/bit/bor]bit.bor[/url] E.g. [code] bit.bor(FVPHYSICS_DMG_SLICE, FVPHYSICS_WAS_THROWN) [/code] Edit; ninja'd
Am I going crazy or do you guys mean bit.bor
definitely bor, both of those posts would be setting the flags to 0 :v: [editline]27th February 2017[/editline] how they work: [code] 0010 & 0001 | 0010 | 0001 | 0 & 0 = 0 | 0 | 0 = 0 0 & 0 = 0 | 0 | 0 = 0 1 & 0 = 0 | 1 | 0 = 1 0 & 1 = 0 | 0 | 1 = 1 | result: 0000 | result: 0011 [/code] [editline]27th February 2017[/editline] alternatively, because all the flags are just powers of 2, adding them will have the same effect of bitwise or'ing them in this case
[QUOTE=Willox;51883387]Am I going crazy or do you guys mean bit.bor[/QUOTE] Yep... I'm at work and running in full-retard mode. Corrected, thanks.
Thank you all for your answers! I did manage to set two flags to a PhysObj (FVPHYSICS_NO_IMPACT_DMG and FVPHYSICS_NO_PLAYER_PICKUP, and the thrown saw blades didn't hurt NPCs and I couldn't pick them up with the Gravity Gun.) However, I still can't get the saw blades to act like I want them to. Even when setting FVPHYSICS_DMG_SLICE and FVPHYSICS_WAS_THROWN, the saw blades don't cut zombies in half and don't stick to walls. Here is the code executed when using primary fire. I'm a beginner, so I'm sorry if there's any big mistakes. [CODE]function SWEP:ThrowSaw( model_file ) self:EmitSound( ShootSound ) if ( CLIENT ) then return end local ent = ents.Create( "prop_physics" ) if ( !IsValid( ent ) ) then return end ent:SetModel( model_file ) ent:SetPos( self.Owner:EyePos() + ( self.Owner:GetAimVector() * 50 ) ) ent:SetAngles( self.Owner:EyeAngles() ) ent:Spawn() local phys = ent:GetPhysicsObject() if ( IsValid( phys ) ) then phys:AddGameFlag(bit.bor(FVPHYSICS_DMG_SLICE, FVPHYSICS_WAS_THROWN)) else ent:Remove() end local velocity = self.Owner:GetAimVector() velocity = velocity * 100000 velocity = velocity + Vector(0, 0, 0) phys:ApplyForceCenter( velocity ) end[/CODE] Am I doing anything wrong here? Or is it just that the requirements for what I want are different than what I read.
How do I use rcon inside an entity? What I am basically trying to do is, an entity that runs a console command but not from the player but through rcon. I want some script to give XP whenever you press on it, the console command for that is rp_givexp "player" "amount" but only admins can execute that command in console
I want to create a bunch of artillery shells in the sky and have them spawn at random positions. What's the best way to do this while making sure they're in the world and not in the skybox. Thanks!
[QUOTE=MGFear;51889049]How do I use rcon inside an entity? What I am basically trying to do is, an entity that runs a console command but not from the player but through rcon. I want some script to give XP whenever you press on it, the console command for that is rp_givexp "player" "amount" but only admins can execute that command in console[/QUOTE] Doesn't DarkRP already have a chat commands system?
[QUOTE=NeatNit;51891574]Doesn't DarkRP already have a chat commands system?[/QUOTE] I am trying to make an entity that rewards the player with experience, the console command for doing so would be rp_givexp but this can only be done by an admin+. My question is, how can I make this entity give XP basically, to any user not just admins.
The entity would have to give players XP, refer to the XP mod you're using the see what the Lua function for that is.
Serverside how can I read a clientside convar with the FCVAR_USERINFO flag.
[QUOTE=YourStalker;51897982]Serverside how can I read a clientside convar with the FCVAR_USERINFO flag.[/QUOTE] [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stool.lua#L80[/url] [url]http://wiki.garrysmod.com/page/Player/GetInfo[/url] If only you'd bother to try to search.
[QUOTE=YourStalker;51897982]Serverside how can I read a clientside convar with the FCVAR_USERINFO flag.[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetInfo]Player:GetInfo[/url] [editline]a[/editline] oh shit how long ago did i open this tab
Looking at making this pointshop player model 'player rotatable': [url]http://pointshop.burt0n.net/images/ps.jpg[/url] I want the player to be able to hold the left mouse button down and rotate model left and right Any ideas? :) EDIT: How would I go about turn the background blur down?
[QUOTE=Robotboy655;51898009][URL]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stool.lua#L80[/URL] [URL]http://wiki.garrysmod.com/page/Player/GetInfo[/URL] If only you'd bother to try to search.[/QUOTE] Shit, if the developers named the function something less broad than "GetInfo" maybe I'd know it had anything to do with fucking ConVars.
-snip-
1st Question: Is there any difference between the Entity:SetNetworkedVarProxy() function defined in [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/extensions/entity.lua#L485-L493"]Lua[/URL] and the one defined in the engine? 2nd Question: I've made [URL="https://github.com/willox/archive/tree/master/gmsv_refresh-master"]this[/URL] module compatible with Linux. But there is one thing that is strange for me: When I run for example refresh("includes/extensions/entity.lua"), the message "Unhandled Lua Refresh: [NAME:includes/extensions/entity.lua] [TYPE:!UNKNOWN]" comes, but the script is still not executed. If I am not wrong, then it should be because the autorefresh system only supports gamemode files, weapons, etc., right? That would mean that the manual use of this system doesn't update the files. If so, what should I do to make other files working too?
-snip was looking at the wrong function-
[QUOTE=code_gs;51899401]1. The one defined in the engine is for NW2Vars, the one in Lua is for NetworkVars, which is really just an abstraction for DTVars. Yes, the names are very similar and poorly thought out.[/QUOTE] The one defined in Lua is for NW2Vars. And the names are identical. The Lua function just overrides the engine function for some reason.
Could be leftovers from when Garry was moving stuff from C to Lua? [url]https://garry.tv/2012/10/30/optimising-gmod/[/url] [sp]I spent way too long looking for that link[/sp]
How can I make the entity stay at the same position regardless of where the view point is, because when I spawn the swep from thirdperson the ent moes to the right, but if I spawn it in first person it spawns on the left side of the screen (where it should be) [code]function SWEP:Deploy() if SERVER then if IsValid(self.ent) then return end self:SetNoDraw(false) self.ent = ents.Create("prop_physics") self.ent:SetModel("models/morrowind/daedric/shield/m_daedrictower.mdl") self.ent:SetModelScale(self.ent:GetModelScale() * 1.25, 1) self.ent:SetPos(self.Owner:GetPos() + Vector(10,-10,45) + (self.Owner:GetForward()*25)) self.ent:SetAngles(Angle(0,self.Owner:EyeAngles().y,self.Owner:EyeAngles().r)) self.ent:SetParent(self.Owner) self.ent:Fire("SetParentAttachmentMaintainOffset", "eyes", 0.01) self.ent:SetCollisionGroup( COLLISION_GROUP_WORLD ) self.ent:Spawn() self.ent:Activate() end return true end[/code] this only happens whenever I spawn it in thirdperson, if I have it spawned on first person but go to thirdperson everything is fine
I'm having a problem with my Lightsaber SWeps. If someone is autojumping and crouching at the same time and then releases their crouch button the same time that they hit the floor they go flying into the air. Can someone please try to find why this is happening? [CODE] if ( SERVER ) then AddCSLuaFile( "shared.lua" ) end if ( CLIENT ) then SWEP.PrintName = "Jedi Knight LightSaber" SWEP.Author = "XcoliahX" SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.IconLetter = "f" SWEP.DrawCrosshair = false killicon.AddFont( "weapon_knife", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end -----------------------Main functions---------------------------- -- function SWEP:Reload() --To do when reloading -- end function SWEP:Think() if self.Owner:KeyDown(IN_JUMP) then if self.Owner:IsOnGround() then self.Owner:SetVelocity(Vector(0,0,500)) end end end function SWEP:Initialize() util.PrecacheSound("physics/flesh/flesh_impact_bullet" .. math.random( 3, 5 ) .. ".wav") util.PrecacheSound("weapons/iceaxe/iceaxe_swing1.wav") self:SetWeaponHoldType("melee") end function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + .50) local trace = self.Owner:GetEyeTrace() if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER) bullet = {} bullet.Num = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector(0, 0, 0) bullet.Tracer = 0 bullet.Force = 20 bullet.Damage = 25 self.Owner:FireBullets(bullet) self.Owner:SetAnimation( PLAYER_ATTACK1 ); self.Weapon:EmitSound("ls/lightsaber_swing" .. math.random( 3, 5 ) .. ".wav") else self.Weapon:EmitSound("ls/ls_throw") self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER) self.Owner:SetAnimation( PLAYER_ATTACK1 ) end end /*--------------------------------------------------------- SecondaryAttack ---------------------------------------------------------*/ function SWEP:SecondaryAttack() end ------------------------------------------------------------------- ------------General Swep Info--------------- SWEP.Author = "XcoliahX" SWEP.Contact = "" SWEP.Purpose = "" SWEP.Instructions = "" SWEP.Spawnable = false SWEP.AdminSpawnable = true ----------------------------------------------- ------------Models--------------------------- SWEP.ViewModel = "models/weapons/v_breebar.mdl" SWEP.WorldModel = "models/weapons/v_breebar.mdl" ----------------------------------------------- -------------Primary Fire Attributes---------------------------------------- SWEP.Primary.Delay = 0.5 --In seconds SWEP.Primary.Recoil = 0 --Gun Kick SWEP.Primary.Damage = 25 --Damage per Bullet SWEP.Primary.NumShots = 1 --Number of shots per one fire SWEP.Primary.Cone = 0 --Bullet Spread SWEP.Primary.ClipSize = -1 --Use "-1 if there are no clips" SWEP.Primary.DefaultClip = -1 --Number of shots in next clip SWEP.Primary.Automatic = true --Pistol fire (false) or SMG fire (true) SWEP.Primary.Ammo = "none" --Ammo Type SWEP.Primary.Sound = Sound("ls/lightsaber_swing") --Sound when attacking -------------End Primary Fire Attributes------------------------------------ -------------Secondary Fire Attributes------------------------------------- -------------End Secondary Fire Attributes-------------------------------- function SWEP:Deploy() self.Weapon:EmitSound( "weapons/knife/knife_deploy1.wav" ) --Plays a nifty sound when you pull it out. end [/CODE]
Sorry, you need to Log In to post a reply to this thread.