diff options
Diffstat (limited to 'gamemode/shared/player_human.lua')
| -rw-r--r-- | gamemode/shared/player_human.lua | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/gamemode/shared/player_human.lua b/gamemode/shared/player_human.lua new file mode 100644 index 0000000..8fa6997 --- /dev/null +++ b/gamemode/shared/player_human.lua @@ -0,0 +1,66 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("SetHuman")
+
+ function meta:SetHuman(bool)
+ self.IsHuman = bool
+ self.Inventory = {}
+ self.Weapons = {}
+
+ net.Start("SetHuman")
+ net.WriteEntity(self)
+ net.WriteBit(self.IsHuman)
+ net.Broadcast()
+ end
+
+ function meta:UpdateHumans()
+ for k,v in pairs(player.GetAll()) do
+ if (v.IsHuman) then
+ timer.Simple(math.Rand(0.1,0.2),function()
+ net.Start("SetHuman")
+ net.WriteEntity(v)
+ net.WriteBit(true)
+ net.Send(self)
+ end)
+ end
+ end
+ end
+else
+ net.Receive("SetHuman",function()
+ local pl = net.ReadEntity()
+
+ pl.IsHuman = util.tobool(net.ReadBit())
+ pl.Inventory = {}
+ pl.Weapons = {}
+ end)
+end
+
+function meta:IsPigeon()
+ return !util.tobool(self.IsHuman)
+end
+
+function player.GetAllHumans()
+ local dat = {}
+
+ for k,v in pairs(player.GetAll()) do
+ if (!v:IsPigeon()) then
+ table.insert(dat,v)
+ end
+ end
+
+ return dat
+end
+
+function player.GetAllHumansAlive()
+ local dat = {}
+
+ for k,v in pairs(player.GetAll()) do
+ if (!v:IsPigeon() and v:Alive()) then
+ table.insert(dat,v)
+ end
+ end
+
+ return dat
+end
|
