From 5c4ebc932d8c02522802c842d43d863d89aca162 Mon Sep 17 00:00:00 2001 From: Apickx Date: Mon, 28 Dec 2015 19:10:44 -0500 Subject: Initial commit --- gamemode/shared/player_human.lua | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 gamemode/shared/player_human.lua (limited to 'gamemode/shared/player_human.lua') 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 -- cgit v1.2.3-70-g09d2