blob: 9f5a413004518f01c3a949f641df9bdac26dbdb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
local meta = FindMetaTable("Player")
if (SERVER) then
util.AddNetworkString("SetFatigue")
local Tick = CurTime()
function meta:SetFatigue(s)
if (s > 100) then self:TakeDamage(s-100) s = 100 end
s = math.Clamp(s,0,100)
self.Fatigue = s
net.Start("SetFatigue")
net.WriteUInt(s,8)
net.Send(self)
end
function meta:AddFatigue(s)
self:SetFatigue(self:GetFatigue()+s)
end
hook.Add("Tick","Fatigue",function()
if (Tick < CurTime()) then
for k,v in pairs(player.GetAllHumans()) do
local Fat = v.Fatigue or 0
if (Fat > 0) then Fat = Fat-2 end
Fat = Fat+math.ceil(v:GetVelocity():Length()/100)
v:SetFatigue(Fat)
end
Tick = CurTime()+0.5
end
end)
else
net.Receive("SetFatigue",function()
LocalPlayer().Fatigue = net.ReadUInt(8)
end)
end
function meta:GetFatigue()
return self.Fatigue or 0
end
|