SWEP Question

Hey guys, currently im working on a SWEP, Its called “Running Shoes” its a active SWEP for TTT but the only thing whats missing is a function what triggers Shift to sprint.

Eg. You hold shift, then the player runspeed goes faster (sprint) for 5 secs, then you have to wait 7 secs before you can sprint again.

Any idea how I have to start this function?

Thanks :smiley:

Help? I might found a way how to do it eg.

[lua]
function Sprintspeed(ply)
for k, v in pairs(player.GetAll()) do
if v:IsPlayer and v:IsAlive and v:HasEquipmentItem (EQUIP_RUNNINGSHOES) then
v:SetRunSpeed(400)
end
end
[/lua]
Something like that but im not sure about the line

[lua]v:HasEquipmentItem (EQUIP_RUNNINGSHOES)[/lua]

Any advices?

Edit: Discovered that the v:SetRunSpeed is already triggered when the player press shift? Not sure tho.

[lua]

function DoSprintShoes(ply,key)
if (key == “SPEED”) && (ply:HasEquipmentItem(EQUIP_RUNNINGSHOES)) then
– do stuff
end
end
hook.Add(“KeyPress”,“CheckSprintShoes”,DoSprintShoes)
[/lua]

You could do something like that…

Hmm yeah but then I still have a little problem with the time, like you can sprint only for 5 secs long then after those 5 secs you have to wait 7 secs before u can sprint again. So it would be like (I think)

[lua]
function DoSprintShoes(ply,key)
if (key == “SPEED”) && (ply:HasEquipmentItem(EQUIP_RUNNINGSHOES)) then
ply:SetRunSpeed(400) else
ply:SetRunSpeed(150)
end
end
end
hook.Add(“KeyPress”,“CheckSprintShoes”,DoSprintShoes)
[/lua]
But like i said before then there is still a little problem with the timer :l
Couldnt find stuff on the Wiki too, and its the first time i make something “Time based”

[lua]
function DoSprintShoes(ply,key)
local bool = false
if (key == “SPEED”) && (ply:HasEquipmentItem(EQUIP_RUNNINGSHOES)) && bool == false then
local bool = true
ply:SetRunSpeed(400)
timer.Simple(5,function()
ply:SetRunSpeed(150)
timer.Simple(7,function() local bool = false end)
end)
end
end
hook.Add(“KeyPress”,“CheckSprintShoes”,DoSprintShoes)
[/lua]
No idea if it’ll work; did it in a rush, but something along those lines.

Tried this, dont work I think i need to make this a Sent or Ent, something like that because it still draws a view and world model while its not there, in TTT we have weapons, passive and active items, the body armor and Radar are that types too, they dont pop up into your weapons cycle etc. but cant find the orig lua files from those.

This is the code at the moment:

[lua]
if SERVER then
AddCSLuaFile( “shared.lua” )
end

SWEP.HoldType = “ar2”

if CLIENT then

SWEP.PrintName = “Sneakers”
SWEP.Slot = 6
SWEP.Icon = “VGUI/ttt/icon_rg_sneakers”
end

SWEP.Base = “weapon_tttbase”
SWEP.Kind = WEAPON_EQUIP1

SWEP.CanBuy = { ROLE_TRAITOR }
SWEP.LimitedStock = true

SWEP.EquipMenuData = {
type = “item_passive”,
desc = “Sprint for 5 seconds with Shift!
Wait then 7 Seconds before you can sprint again!”
};

function DoSprintShoes(ply,key)
local bool = false
if (key == “IN_SPEED”) && (ply:HasEquipmentItem(EQUIP_SNEAKERS)) && bool == false then
local bool = true
ply:SetRunSpeed(400)
timer.Simple(5,function()
ply:SetRunSpeed(150)
timer.Simple(7,function() local bool = false end)
end)
end
end
hook.Add(“KeyPress”,“CheckSprintShoes”,DoSprintShoes)
[/lua]

Well never mind, I think ill let this one pass, Thanks anyways