From 658ed9b2121bec111de750a979798cf6cc88c92f Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 7 May 2016 04:18:55 -0400 Subject: Gravestone fixed --- entities/entities/gms_gravestone.lua | 3 +- gamemode/cl_deathmenu.lua | 79 ++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 44 deletions(-) diff --git a/entities/entities/gms_gravestone.lua b/entities/entities/gms_gravestone.lua index c1fff07..76f46f0 100644 --- a/entities/entities/gms_gravestone.lua +++ b/entities/entities/gms_gravestone.lua @@ -71,12 +71,13 @@ if ( CLIENT ) then end - function ENT:Use( ply ) table.sort(self.deathWeapons) table.sort(self.deathResources) ply:CancelProcess() ply:DeathMenu(self.deathResources, self.deathWeapons) + + end if ( SERVER ) then diff --git a/gamemode/cl_deathmenu.lua b/gamemode/cl_deathmenu.lua index 6b023eb..b228ee8 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,9 +171,7 @@ 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() @@ -178,10 +183,9 @@ function PANEL:Init() 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) + if (getResName(v) == getResName(o)) then + print(getResName(v).." : "..getResName(o)) + giveRes(getResName(o), 1, i) table.remove(res,i) end end @@ -191,12 +195,9 @@ function PANEL:Init() 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 + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), 1, i) + res[i] = getResName(o) .. " x" .. amount v = res[i] end end @@ -213,10 +214,8 @@ function PANEL:Init() 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) + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), 5, i) table.remove(res, i) end end @@ -230,10 +229,8 @@ function PANEL:Init() 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) + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), num2, i) table.remove(res,i) end end @@ -244,11 +241,9 @@ function PANEL:Init() 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 + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), 5, i) + res[i] = getResName(o) .. " x" .. amount v = res[i] end end @@ -264,10 +259,8 @@ function PANEL:Init() 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) + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), 10, i) table.remove(res, i) end end @@ -280,10 +273,8 @@ function PANEL:Init() 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) + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), num2, i) table.remove(res,i) end end @@ -296,11 +287,9 @@ function PANEL:Init() 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 + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), 10, i) + res[i] = getResName(o) .. " x" .. amount v = res[i] end end @@ -312,10 +301,8 @@ function PANEL:Init() 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) + if (getResName(v) == getResName(o)) then + giveRes(getResName(o), amount, i) amount = 0 table.remove(res,i) end @@ -345,6 +332,12 @@ function PANEL:Init() end +function getResName(str) + spl = string.Split(str, " ") + table.remove(spl) + return string.Implode(" ", spl) +end + function PANEL:Close() active = 0 self:Remove() -- cgit v1.2.3-70-g09d2