I'm looking for a stamina system, if someone can make or post one i would be rather grateful
i realised i wasnt very clear - by stamina system, i mean that you can sprint for only a short period, say 30 seconds than find yourself unable to sprint until it is recharged.
[QUOTE=archie-88;19021731]i realised i wasnt very clear - by stamina system, i mean that you can sprint for only a short period, say 30 seconds than find yourself unable to sprint until it is recharged.[/QUOTE]
Isn't that already included with Garry's Mod?
No, it's explicitly disabled.
Hrm, would there be a way to enable it, ill actually go look at some of the lua functions, probably wont find much >.<
Nope, it's disabled in a not-so-convenient fashion within the SDK. You'd have to recreate it entirely in Lua.
I have the code for this. I'll upload it when I get off my mac. lol
[QUOTE=PC Camp;19032111]I have the code for this. I'll upload it when I get off my mac. lol[/QUOTE]
Holy crap, Thankyou :D, if you made it, its got to be good. (not being a suckup but you're great with lua, used to play on BB when you were a dev.)
Kogitsune made one a while ago but then it disappeared.
...and then he made it again!
[url=http://www.garrysmod.org/downloads/?a=view&id=85659][img]http://www.garrysmod.org/img/?t=dll&id=85659[/img][/url]
Here's my version,
[lua]
local LastThink = 0
function StartingStamina( ply )
ply.Energy = 30
ply.Flash = 60
end
hook.Add("PlayerSpawn","StartingStamina",StartingStamina)
function AddPlyEnergy( ply, num )
if !ply:Alive() then return end
ply.Energy = math.Clamp( ply.Energy + num, 0, 30 )
end
-- I know we can just do -num, but this is easier for me
function TakePlyEnergy( ply, num )
if !ply:Alive() then return end
ply.Energy = math.Clamp( ply.Energy - num, 0, 30 )
end
function FlashlightOnOrOff(ply, status)
if status then
return ply.Flash > 15
end
end
hook.Add("PlayerSwitchFlashlight","FlashlightOnOrOff?",FlashlightOnOrOff)
function Stankeypress( ply, key )
if key == IN_SPEED and ply.Energy < 5 then
ply:ConCommand( "-speed" )
end
if key == IN_JUMP and ply.Energy >= 5 then
TakePlyEnergy( ply, 5 )
end
end
hook.Add("KeyPress","staminakeypress",Stankeypress)
function ThinkOfDisShiz()
local now = CurTime()
local delta = now - LastThink
for k, ply in pairs( player.GetAll() ) do
if ply:Alive() and ply:FlashlightIsOn() and !ply:GetNWBool("sleep") then
ply.Flash = math.Clamp( ply.Flash - (delta / 2), 0, 60 )
else
ply.Flash = math.Clamp( ply.Flash + delta, 0, 60 )
end
if ply:KeyDown( IN_SPEED ) and ply:Alive() and ply:GetVelocity():Length() > 10 and !ply:Crouching() then
TakePlyEnergy( ply, (delta / 2) )
else
AddPlyEnergy( ply, delta )
end
if ply.Flash <= 0 then
ply:Flashlight( false )
end
if ply.Energy <= 1 then
ply:ConCommand( "-speed" )
end
if ply.Energy >= 5 then
ply:SetJumpPower( 175 )
else
ply:SetJumpPower( 0 )
end
if ply.Energy != 30 then
umsg.Start("GetStamina", ply)
umsg.Float( ply.Energy )
umsg.End()
end
if ply.Flash != 60 then
umsg.Start("GetFlash", ply)
umsg.Float( ply.Flash )
umsg.End()
end
end
LastThink = now
end
hook.Add("Think","ThinkOfDisShiz",ThinkOfDisShiz)
[/lua]
It does stamina for running and jumping and has batteries for the flashlight.
Personally, I'd much rather prefer the HEV battery/sprint/oxygen system to look pixel perfect like HL2's, but hey, just an opinion. Nice work PC Camp, and kudos to Kogitsune as well. :smile:
Thanks to all, i'll have a muck around with both of them
Sorry, you need to Log In to post a reply to this thread.