• Ghook broken please help
    24 replies, posted
Hello, so i recently downloaded the grappling hook from the workshop and when i go on my server to use it i cant go anyware.. The grappling hook like takes me 2 feet in the air but barely and i cant go on top of buildings or anything. Does it have to do with the gravity? I play on another server that uses it and its totally fine. I fly everywhere. Thanks and please help.
Post a link to the addon.
[url]http://steamcommunity.com/sharedfiles/filedetails/?id=138374257&searchtext=grappling+hook[/url] here
Read the description: [code]It has a cvar (grapple_distance)that defines its maximum range. The default range is -1 (unlimited). It will not latch onto anything that is out of range. This makes it useful in applications such as stranded, spacebuild, or roleplay. [/code]
Yes but the other rp server i play on has it and it works fine. Is their a way i can change the cvar and would that help?
[QUOTE=zman9300;45909926]Yes but the other rp server i play on has it and it works fine. Is their a way i can change the cvar and would that help?[/QUOTE] That's what a cvar is. A variable you can change.
Ok so wat would i change it to?
Change it via the server console.
Wat do you mean by that?
[QUOTE=zman9300;45910171]Wat do you mean by that?[/QUOTE] Are you using a dedicated server, or a listen server?
Im using a host. Nfo servers
So use their server console tool.
But wat do i do with it.
Change the cvar (grapple_distance).
ok so type in console cvar(grapple_distance) 3 or something like that? sorry im not smart at all with this stuff
grapple_distance distance
ok thanks does it matter wat the distance is. Also i would do this in the console of the actual server correct or in the file?
Server console. The description says make it -1 to allow infinite range.
when i type grapple_distance -1 it says invalid command
Can you post the code of the grapple hook in [code] tags?
wat do u mean code tags. and yes. Also wat code just the shared.lua [editline]6th September 2014[/editline] This is the shared.lua [CODE]SWEP.Author = "Hxrmn, HOLOGRAPHICpizza" SWEP.Contact = "mcraft@peak15.org" SWEP.Purpose = "A Grappling Hook" SWEP.Instructions = "Left click to fire" SWEP.Spawnable = true SWEP.AdminSpawnable = false SWEP.PrintName = "Grappling Hook" SWEP.Slot = 3 SWEP.SlotPos = 0 SWEP.DrawAmmo = false SWEP.DrawCrosshair = true SWEP.ViewModel = "models/weapons/c_crossbow.mdl" SWEP.WorldModel = "models/weapons/w_crossbow.mdl" local sndPowerUp = Sound("weapons/crossbow/hit1.wav") local sndPowerDown = Sound("weapons/crossbow/fire1.wav") local sndTooFar = Sound("weapons/pistol/pistol_empty.wav") function SWEP:Initialize() nextshottime = CurTime() self:SetWeaponHoldType( "smg" ) self.zoomed = false end function SWEP:Think() if (!self.Owner || self.Owner == NULL) then return end if ( self.Owner:KeyPressed( IN_ATTACK ) ) then self:StartAttack() elseif ( self.Owner:KeyDown( IN_ATTACK ) && inRange ) then self:UpdateAttack() elseif ( self.Owner:KeyReleased( IN_ATTACK ) && inRange ) then self:EndAttack( true ) end --Changed from KeyDown to prevent random stuck-in-zoom bug. if ( self.Owner:KeyPressed( IN_ATTACK2 ) ) then self:Attack2() end end function SWEP:DoTrace( endpos ) local trace = {} trace.start = self.Owner:GetShootPos() trace.endpos = trace.start + (self.Owner:GetAimVector() * 14096) --14096 is length modifier. if(endpos) then trace.endpos = (endpos - self.Tr.HitNormal * 7) end trace.filter = { self.Owner, self.Weapon } self.Tr = nil self.Tr = util.TraceLine( trace ) end function SWEP:StartAttack() -- Get begining and end poins of trace. local gunPos = self.Owner:GetShootPos() -- Start of distance trace. local disTrace = self.Owner:GetEyeTrace() -- Store all results of a trace in disTrace. local hitPos = disTrace.HitPos -- Stores Hit Position of disTrace. -- Calculate Distance -- Thanks to rgovostes for this code. local x = (gunPos.x - hitPos.x)^2; local y = (gunPos.y - hitPos.y)^2; local z = (gunPos.z - hitPos.z)^2; local distance = math.sqrt(x + y + z); -- Only latches if distance is less than distance CVAR, or CVAR negative local distanceCvar = GetConVarNumber("grapple_distance") inRange = false if distanceCvar < 0 or distance <= distanceCvar then inRange = true end if inRange then if (SERVER) then if (!self.Beam) then -- If the beam does not exist, draw the beam. -- grapple_beam self.Beam = ents.Create( "trace1" ) self.Beam:SetPos( self.Owner:GetShootPos() ) self.Beam:Spawn() end self.Beam:SetParent( self.Owner ) self.Beam:SetOwner( self.Owner ) end self:DoTrace() self.speed = 10000 -- Rope latch speed. Was 3000. self.startTime = CurTime() self.endTime = CurTime() + self.speed self.dt = -1 if (SERVER && self.Beam) then self.Beam:GetTable():SetEndPos( self.Tr.HitPos ) end self:UpdateAttack() self.Weapon:EmitSound( sndPowerDown ) else -- Play a sound self.Weapon:EmitSound( sndTooFar ) end end function SWEP:UpdateAttack() self.Owner:LagCompensation( true ) if (!endpos) then endpos = self.Tr.HitPos end if (SERVER && self.Beam) then self.Beam:GetTable():SetEndPos( endpos ) end lastpos = endpos if ( self.Tr.Entity:IsValid() ) then endpos = self.Tr.Entity:GetPos() if ( SERVER ) then self.Beam:GetTable():SetEndPos( endpos ) end end local vVel = (endpos - self.Owner:GetPos()) local Distance = endpos:Distance(self.Owner:GetPos()) local et = (self.startTime + (Distance/self.speed)) if(self.dt != 0) then self.dt = (et - CurTime()) / (et - self.startTime) end if(self.dt < 0) then self.Weapon:EmitSound( sndPowerUp ) self.dt = 0 end if(self.dt == 0) then zVel = self.Owner:GetVelocity().z vVel = vVel:GetNormalized()*(math.Clamp(Distance,0,7)) if( SERVER ) then local gravity = GetConVarNumber("sv_Gravity") vVel:Add(Vector(0,0,(gravity/100)*1.5)) -- Player speed. DO NOT MESS WITH THIS VALUE! if(zVel < 0) then vVel:Sub(Vector(0,0,zVel/100)) end self.Owner:SetVelocity(vVel) end end endpos = nil self.Owner:LagCompensation( false ) end function SWEP:EndAttack( shutdownsound ) if ( shutdownsound ) then self.Weapon:EmitSound( sndPowerDown ) end if ( CLIENT ) then return end if ( !self.Beam ) then return end self.Beam:Remove() self.Beam = nil end function SWEP:Attack2() -- Zoom. if self.zoomed then self.zoomed = false if SERVER then self.Owner:SetFOV(0, 0.1) end else self.zoomed = true if SERVER then self.Owner:SetFOV(30, 0.1) end end end function SWEP:Holster() self:EndAttack( false ) return true end function SWEP:OnRemove() self:EndAttack( false ) return true end function SWEP:PrimaryAttack() end function SWEP:SecondaryAttack() end[/CODE]
[code]local distanceCvar = GetConVarNumber("grapple_distance")[/code] Seems like the cvar is initialized in another file. Alternatively, you can just do [code]local distanceCvar = -1[/code]
So i set it to -1 and now it doesnt even do anything. [editline]6th September 2014[/editline] I did -1 and it still wont do anything.
Have you tried restarting your server? The code looks fine; should work if you changed GetConVarNumber("grapple_distance") to -1.
i will restart
Sorry, you need to Log In to post a reply to this thread.