summaryrefslogtreecommitdiff
path: root/gamemode/sh_various
diff options
context:
space:
mode:
authorApickx <Apickx@cogarr.org>2015-12-28 19:18:30 -0500
committerApickx <Apickx@cogarr.org>2015-12-28 19:18:30 -0500
commit868e729d68b5913716bfe5ddb512f4099851e9a2 (patch)
tree6441108754145dfd68a6e23bea382b5cb1ab63d5 /gamemode/sh_various
downloadgearfox-master.tar.gz
gearfox-master.tar.bz2
gearfox-master.zip
Initial commitHEADmaster
Diffstat (limited to 'gamemode/sh_various')
-rw-r--r--gamemode/sh_various/hooks.lua14
-rw-r--r--gamemode/sh_various/math_ext.lua57
-rw-r--r--gamemode/sh_various/note.lua62
-rw-r--r--gamemode/sh_various/perlins_noise.lua2
4 files changed, 135 insertions, 0 deletions
diff --git a/gamemode/sh_various/hooks.lua b/gamemode/sh_various/hooks.lua
new file mode 100644
index 0000000..8983152
--- /dev/null
+++ b/gamemode/sh_various/hooks.lua
@@ -0,0 +1,14 @@
+
+// :O
+
+
+hook.Add( "PhysgunPickup", "CanPickupPlayer_MB", function(ply,ent)
+ GM = GM or GAMEMODE
+
+ if (ent:IsPlayer() and GM:GetGlobalSHVar("PlayerPickup",false)) then
+ if (GM:GetGlobalSHVar("PlayerPickupAdmin",false)) then return (ply:IsAdmin()) end
+ return true
+ end
+end)
+
+hook.Remove( "PostDrawEffects", "RenderHalos" )
diff --git a/gamemode/sh_various/math_ext.lua b/gamemode/sh_various/math_ext.lua
new file mode 100644
index 0000000..f789306
--- /dev/null
+++ b/gamemode/sh_various/math_ext.lua
@@ -0,0 +1,57 @@
+local Ints = {1000, 900, 500, 400, 100,90, 50, 40, 10, 9, 5, 4, 1}
+local Nums = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}
+
+function math.IntToRoman(int)
+ if (int == 0) then return "N" end
+
+ local Txt = ""
+
+ if (int < 0) then Txt = "-" int = math.abs(int) end
+
+ for i = 1, 13 do
+ while (int >= Ints[i]) do
+ int = int-Ints[i]
+ Txt = Txt..Nums[i]
+ end
+ end
+
+ return Txt
+end
+
+function math.IsFloat(num)
+ return (math.floor(num) != math.ceil(num))
+end
+
+function math.AngleNormalize(ang)
+ return Angle(math.NormalizeAngle(ang.p),math.NormalizeAngle(ang.y),math.NormalizeAngle(ang.r))
+end
+
+function math.Distance2Points(x1,y1,x2,y2)
+ return math.sqrt((x2-x1)^2+(y2-y1)^2)
+end
+
+function math.Increment2Points(x1,y1,x2,y2)
+ return (y2-y1)/(x2-x1)
+end
+
+function math.LinearAngle(x1,y1,x2,y2)
+ return math.atan2(y2-y1,x2-x1) * 180 / math.pi
+end
+
+function math.SecondsToTime(secs)
+ secs = math.floor(secs)
+
+ local Txt = ""
+
+ for i = 0,2 do
+ local It = 60^(2-i)
+ local T = math.floor(secs/It)
+
+ if (T<10) then Txt = Txt..":0"..T
+ else Txt = Txt..":"..T end
+
+ secs = secs - T*It
+ end
+
+ return Txt:sub(2)
+end \ No newline at end of file
diff --git a/gamemode/sh_various/note.lua b/gamemode/sh_various/note.lua
new file mode 100644
index 0000000..d2597c7
--- /dev/null
+++ b/gamemode/sh_various/note.lua
@@ -0,0 +1,62 @@
+
+local meta = FindMetaTable("Player")
+local Dat = {}
+
+function meta:AddNote(Msg)
+ if (CLIENT) then
+ local DAT = {}
+ DAT.Time = CurTime()
+ DAT.Msg = Msg
+ table.insert(Dat,DAT)
+ else
+ net.Start("_GFGetMessage")
+ net.WriteString(Msg)
+ net.Send(self)
+ end
+end
+
+if (CLIENT) then
+ net.Receive("_GFGetMessage",function(size)
+ local DAT = {}
+ DAT.Time = CurTime()
+ DAT.Msg = net.ReadString()
+ table.insert(Dat,DAT)
+ end)
+
+ hook.Add("HUDPaint","GearFoxDrawNotes",function()
+ local N = CurTime()-5
+ local C = 0
+ local x = ScrW()
+ local y = ScrH()/2
+
+ surface.SetFont("Trebuchet18") --This is for the GetTextSize function. To get the correct size of a text.
+
+ for k,v in pairs( Dat ) do
+ if (v.Time < N) then
+ table.remove(Dat,k)
+ else
+ local T = math.Clamp(v.Time-N,0,1)
+ local T2 = math.Clamp(N+5-v.Time,0,1)
+ C = C+1
+
+ local W,H = surface.GetTextSize(v.Msg)
+ local D = y+21*C
+ local X = x-(W+10)*T2
+ local B = MAIN_COLOR.a*1
+ local K = MAIN_TEXTCOLOR.a*1
+
+ MAIN_COLOR.a = B*T
+ MAIN_TEXTCOLOR.a = K*T
+
+ DrawRect(X,D,W+8,20,MAIN_COLOR)
+ DrawText(v.Msg,"Trebuchet18",X+2,D+1,MAIN_TEXTCOLOR)
+
+ MAIN_COLOR.a = B
+ MAIN_TEXTCOLOR.a = K
+ end
+ end
+ end)
+else util.AddNetworkString( "_GFGetMessage" )
+end
+
+
diff --git a/gamemode/sh_various/perlins_noise.lua b/gamemode/sh_various/perlins_noise.lua
new file mode 100644
index 0000000..d23ef18
--- /dev/null
+++ b/gamemode/sh_various/perlins_noise.lua
@@ -0,0 +1,2 @@
+--Not entirely my own code...
+