Author Topic: auto jumping?  (Read 1855 times)

0 Members and 1 Guest are viewing this topic.

Offline VIRDADOR

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
auto jumping?
« on: December 16, 2014, 08:06:13 AM »
Hello,
I recently created a GMOD server and I want to know if it's possible to activate auto jumping (by holding space).
is there a command for it ? if not how can i do it?

thanks in advance>> :)

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: auto jumping?
« Reply #1 on: December 16, 2014, 11:43:53 AM »
Hello,
taken straight from Mr. Gash's DR, put inside your shared.lua:

Code: [Select]
-- Credit: AzuiSleet
-- maybe.
-- It's old, I don't remember who made it. 90% sure it was AzuiSleet.
function GM:Move(pl, movedata)
if pl:IsOnGround() or !pl:Alive() or pl:WaterLevel() > 0 then return end

local aim = movedata:GetMoveAngles()
local forward, right = aim:Forward(), aim:Right()
local fmove = movedata:GetForwardSpeed()
local smove = movedata:GetSideSpeed()

forward.z, right.z = 0,0
forward:Normalize()
right:Normalize()

local wishvel = forward * fmove + right * smove
wishvel.z = 0

local wishspeed = wishvel:Length()

if(wishspeed > movedata:GetMaxSpeed()) then
wishvel = wishvel * (movedata:GetMaxSpeed()/wishspeed)
wishspeed = movedata:GetMaxSpeed()
end

local wishspd = wishspeed
wishspd = math.Clamp(wishspd, 0, 30)

local wishdir = wishvel:GetNormal()
local current = movedata:GetVelocity():Dot(wishdir)

local addspeed = wishspd - current

if(addspeed <= 0) then return end

local accelspeed = (120) * wishspeed * FrameTime()

if(accelspeed > addspeed) then
accelspeed = addspeed
end

local vel = movedata:GetVelocity()
vel = vel + (wishdir * accelspeed)
movedata:SetVelocity(vel)

return false
end

Offline VIRDADOR

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: auto jumping?
« Reply #2 on: December 16, 2014, 12:41:26 PM »
Hello,
taken straight from Mr. Gash's DR, put inside your shared.lua:

Code: [Select]
-- Credit: AzuiSleet
-- maybe.
-- It's old, I don't remember who made it. 90% sure it was AzuiSleet.
function GM:Move(pl, movedata)
if pl:IsOnGround() or !pl:Alive() or pl:WaterLevel() > 0 then return end

local aim = movedata:GetMoveAngles()
local forward, right = aim:Forward(), aim:Right()
local fmove = movedata:GetForwardSpeed()
local smove = movedata:GetSideSpeed()

forward.z, right.z = 0,0
forward:Normalize()
right:Normalize()

local wishvel = forward * fmove + right * smove
wishvel.z = 0

local wishspeed = wishvel:Length()

if(wishspeed > movedata:GetMaxSpeed()) then
wishvel = wishvel * (movedata:GetMaxSpeed()/wishspeed)
wishspeed = movedata:GetMaxSpeed()
end

local wishspd = wishspeed
wishspd = math.Clamp(wishspd, 0, 30)

local wishdir = wishvel:GetNormal()
local current = movedata:GetVelocity():Dot(wishdir)

local addspeed = wishspd - current

if(addspeed <= 0) then return end

local accelspeed = (120) * wishspeed * FrameTime()

if(accelspeed > addspeed) then
accelspeed = addspeed
end

local vel = movedata:GetVelocity()
vel = vel + (wishdir * accelspeed)
movedata:SetVelocity(vel)

return false
end


Thank you for your reply
I found several shared.lua and i do not know which one to modify. could you please tell me which one i should modify?