summaryrefslogtreecommitdiff
path: root/gamemode
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-07 15:31:37 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-07 15:31:37 -0400
commitc491feabe53d517fd47f2ed2dad82125a9a7da57 (patch)
tree609c4540f12a5a6c9aa9fdacc757ae296e158504 /gamemode
parentd3612d8431de4eaa813d6571c368a0ce0679662c (diff)
parent17d19d5c8e8d849b9d7c7ffb2aa8f52a26e2d605 (diff)
downloadgmstranded-c491feabe53d517fd47f2ed2dad82125a9a7da57.tar.gz
gmstranded-c491feabe53d517fd47f2ed2dad82125a9a7da57.tar.bz2
gmstranded-c491feabe53d517fd47f2ed2dad82125a9a7da57.zip
Merge branch 'master' of ssh://cogarr.net:43/home/git/gmstranded
Diffstat (limited to 'gamemode')
-rw-r--r--gamemode/cl_deathmenu.lua219
1 files changed, 67 insertions, 152 deletions
diff --git a/gamemode/cl_deathmenu.lua b/gamemode/cl_deathmenu.lua
index 6b023eb..0a3474b 100644
--- a/gamemode/cl_deathmenu.lua
+++ b/gamemode/cl_deathmenu.lua
@@ -46,6 +46,13 @@ local function receive_message(len)
res = net.ReadTable()
wep = net.ReadTable()
+for k,v in pairs(wep) do
+ print("death weapon: "..k.." : "..v)
+ end
+ for k,v in pairs(res) do
+ print("death resource: "..k.." : "..v)
+ end
+
if (active == 0) then dmFrame = vgui.Create("dmFrame") active = 1 end
end
@@ -164,165 +171,18 @@ function PANEL:Init()
local tbl1 = string.Split(res[k], " ")
local tbl2 = string.Split(tbl1[#tbl1], "x")
- local ntbl = tbl1
- table.remove(ntbl)
- rName = string.Implode(" ", ntbl)
+
local amount = tbl2[2]
resPNL.DoClick = function()
local mb = DermaMenu()
+ addMenuButton(mb, resPNL, "Take x1", amount, 1, v)
+ addMenuButton(mb, resPNL, "Take x5", amount, 5, v)
+ addMenuButton(mb, resPNL, "Take x10", amount, 10, v)
+ addMenuButton(mb, resPNL, "Take All", amount, amount, v)
- mb:AddOption("Take x1", function()
-
- if (amount - 1 <= 0) then
- amount = 0
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, 1, i)
- table.remove(res,i)
- end
- end
- resPNL:Remove()
- else
- amount = amount - 1
-
-
- for i,o in pairs(res) do
-
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, 1, i)
- res[i] = rName .. " x" .. amount
- v = res[i]
- end
- end
-
- end
-
- end)
- mb:AddOption("Take x5", function()
-
- if (amount - 5 <= 0) then
-
- if (amount - 5 == 0) then
- amount = 0
-
-
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, 5, i)
- table.remove(res, i)
- end
- end
- resPNL:Remove()
- else
-
- num1 = amount - 5
- num2 = 5 + num1
- amount = 0
-
-
-
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, num2, i)
- table.remove(res,i)
- end
- end
- resPNL:Remove()
- end
- else
- amount = amount - 5
-
-
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, 5, i)
- res[i] = rName .. " x" .. amount
- v = res[i]
- end
- end
-
- end
- end)
- mb:AddOption("Take x10", function()
-
- if (amount - 10 <= 0) then
-
- if (amount - 10 == 0) then
- amount = 0
-
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, 10, i)
- table.remove(res, i)
- end
- end
- resPNL:Remove()
- else
-
- num1 = amount - 10
- num2 = 10 + num1
- amount = 0
-
-
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, num2, i)
- table.remove(res,i)
- end
- end
-
- resPNL:Remove()
-
- end
- else
- amount = amount - 10
-
-
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, 10, i)
- res[i] = rName .. " x" .. amount
- v = res[i]
- end
- end
-
- end
-
- end)
- mb:AddOption("Take All", function()
-
-
- for i,o in pairs(res) do
- spl1 = string.Split(v, " ")
- spl2 = string.Split(o, " ")
- if (spl1[#spl1] == spl2[#spl2]) then
- giveRes(rName, amount, i)
- amount = 0
- table.remove(res,i)
- end
- end
-
- resPNL:Remove()
- end)
mb:Open()
end
@@ -345,6 +205,61 @@ function PANEL:Init()
end
+function getResName(str)
+ spl = string.Split(str, " ")
+ table.remove(spl)
+ return string.Implode(" ", spl)
+end
+
+function addMenuButton(mb, resPNL, name, amount, remove, v)
+ mb:AddOption(name, function()
+
+ if (amount - remove <= 0) then
+
+ if (amount - remove == 0) then
+ amount = 0
+ for i,o in pairs(res) do
+ if (getResName(v) == getResName(o)) then
+ giveRes(getResName(o), remove, i)
+ table.remove(res, i)
+ end
+ end
+ resPNL:Remove()
+ else
+
+ num1 = amount - remove
+ num2 = remove + num1
+ amount = 0
+
+
+ for i,o in pairs(res) do
+ if (getResName(v) == getResName(o)) then
+ giveRes(getResName(o), num2, i)
+ table.remove(res,i)
+ end
+ end
+
+ resPNL:Remove()
+ end
+
+ else
+
+ amount = amount - remove
+
+
+ for i,o in pairs(res) do
+ if (getResName(v) == getResName(o)) then
+ giveRes(getResName(o), remove, i)
+ res[i] = getResName(o) .. " x" .. amount
+ v = res[i]
+ end
+ end
+
+ end
+
+ end)
+end
+
function PANEL:Close()
active = 0
self:Remove()