• Print

Author Topic: Lua Take a look at this...  (Read 4192 times)

0 Members and 1 Guest are viewing this topic.

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Lua Take a look at this...
« on: August 21, 2014, 03:57:44 am »
OK the jump edit.ply lua script goes something like this if you want to create an item/entity that alters it, I call it anti-gravity.

Code: Lua
  1. function ITEM:Think(ply, modifications)
  2.         if ply:KeyDown(IN_JUMP) then
  3.                 ply:SetVelocity(ply:GetUp() * 6)
  4.         end
  5. end

but what is the lua code when calling the physics for accelerate run/strafe forward?

I know the code I just don't know the lua for "hey I want this item to make the player with this item run really fast."

Thanks in advance,
ChaosWolf
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Take a look at this...
« Reply #1 on: August 22, 2014, 01:58:27 pm »
NEVERMIND ive figured it out, I had the wrong keydown function, I kept putting if ply.KeyDown(IN_STRAFE) -- being wasd movement
but it was actually ply.KeyDown(IN_FORWARD) -- which strangely enough also means left right and back.

here's the code I used.

Code: Lua
  1. function ITEM:Think(ply, modifications)
  2.         if ply:KeyDown(IN_FORWARD) then
  3.                 ply:SetRunSpeed(250) -- default/normal run speed set 500 for double speed or 300 for sprint.
  4.         end
  5. end

SO IF ANYONE WANTS TO ADD SPEED FREAK TO THEIR POINTSHOP HERE IS THE SCRIPT MY FIRST PROJECT I WROTE MYSELF. WOOT WOOT!!!

Code: Lua
  1. ITEM.Name = 'Speed Freak'
  2. ITEM.Price = 20000
  3. ITEM.Model = 'models/props_junk/garbage_glassbottle003a.mdl'
  4. ITEM.Bone = 'ValveBiped.Bip01_Spine2'
  5. ITEM.NoPreview = true
  6.  
  7. function ITEM:OnEquip(ply, modifications)
  8.         ply:PS_AddClientsideModel(self.ID)
  9. end
  10.  
  11. function ITEM:OnHolster(ply)
  12.         ply:PS_RemoveClientsideModel(self.ID)
  13. end
  14.  
  15. function ITEM:Think(ply, modifications)
  16.         if ply:KeyDown(IN_FORWARD) then
  17.                 ply:SetRunSpeed(400)   
  18.         end
  19. end
  20.  
« Last Edit: August 24, 2014, 03:41:47 pm by ChaosWolf »
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

  • Print