From 2eeb33ef8fe6b040e17d4a54354e56920dd4798d Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:42:05 +0000 Subject: [PATCH 01/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/357.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/pointshop/items/weapons/357.lua b/lua/pointshop/items/weapons/357.lua index c0cca25..8f20d10 100644 --- a/lua/pointshop/items/weapons/357.lua +++ b/lua/pointshop/items/weapons/357.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_357' ITEM.SingleUse = true function ITEM:OnBuy(ply) + if (!ply:HasWeapon(self.WeaponClass)) then ply:Give(self.WeaponClass) + else + ply:GiveAmmo(6, "357", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From 53b61207b820a9f279c82a3f506ffdf35dd4ba14 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:43:14 +0000 Subject: [PATCH 02/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/ar2.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/pointshop/items/weapons/ar2.lua b/lua/pointshop/items/weapons/ar2.lua index b0f122e..22e9e80 100644 --- a/lua/pointshop/items/weapons/ar2.lua +++ b/lua/pointshop/items/weapons/ar2.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_ar2' ITEM.SingleUse = true function ITEM:OnBuy(ply) - ply:Give(self.WeaponClass) + if (!ply:HasWeapon(self.WeaponClass)) then + ply:Give(self.WeaponClass) + else + ply:GiveAmmo(60, "AR2", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From ae618d61437c5a80968fd1a5e9ca6c4ada9c94b8 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:44:00 +0000 Subject: [PATCH 03/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/crossbow.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/pointshop/items/weapons/crossbow.lua b/lua/pointshop/items/weapons/crossbow.lua index 3ba120e..87e1f50 100644 --- a/lua/pointshop/items/weapons/crossbow.lua +++ b/lua/pointshop/items/weapons/crossbow.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_crossbow' ITEM.SingleUse = true function ITEM:OnBuy(ply) - ply:Give(self.WeaponClass) + if (!ply:HasWeapon(self.WeaponClass)) then + ply:Give(self.WeaponClass) + else + ply:GiveAmmo(5, "XBowBolt", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From 1069820f410df007b799ee268c260c11aef38e48 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:44:48 +0000 Subject: [PATCH 04/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/grenade.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/pointshop/items/weapons/grenade.lua b/lua/pointshop/items/weapons/grenade.lua index a31267c..a0d3b65 100644 --- a/lua/pointshop/items/weapons/grenade.lua +++ b/lua/pointshop/items/weapons/grenade.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_frag' ITEM.SingleUse = true function ITEM:OnBuy(ply) - ply:Give(self.WeaponClass) + if (!ply:HasWeapon(self.WeaponClass)) then + ply:Give(self.WeaponClass) + else + ply:GiveAmmo(1, "Grenade", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From df6abce950044972df5a428e56c1de69e72d4020 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:46:37 +0000 Subject: [PATCH 05/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/pistol.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/pointshop/items/weapons/pistol.lua b/lua/pointshop/items/weapons/pistol.lua index fe919ed..2ef9c66 100644 --- a/lua/pointshop/items/weapons/pistol.lua +++ b/lua/pointshop/items/weapons/pistol.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_pistol' ITEM.SingleUse = true function ITEM:OnBuy(ply) - ply:Give(self.WeaponClass) + if (!ply:HasWeapon(self.WeaponClass)) then + ply:Give(self.WeaponClass) + else + ply:GiveAmmo(18, "Pistol", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From db1f9eb28fa034bf2628d1613339628d3ed6321d Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:47:46 +0000 Subject: [PATCH 06/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/rpg.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/pointshop/items/weapons/rpg.lua b/lua/pointshop/items/weapons/rpg.lua index 358398d..e384f73 100644 --- a/lua/pointshop/items/weapons/rpg.lua +++ b/lua/pointshop/items/weapons/rpg.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_rpg' ITEM.SingleUse = true function ITEM:OnBuy(ply) - ply:Give(self.WeaponClass) + if (!ply:HasWeapon(self.WeaponClass)) then + ply:Give(self.WeaponClass) + else + ply:GiveAmmo(3, "RPG_Round", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From 972e4ff3f5d4af8b82cebe375e5fa512126825e3 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:48:20 +0000 Subject: [PATCH 07/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/shotgun.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/pointshop/items/weapons/shotgun.lua b/lua/pointshop/items/weapons/shotgun.lua index f021c31..7887ba5 100644 --- a/lua/pointshop/items/weapons/shotgun.lua +++ b/lua/pointshop/items/weapons/shotgun.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_shotgun' ITEM.SingleUse = true function ITEM:OnBuy(ply) + if (!ply:HasWeapon(self.WeaponClass)) then ply:Give(self.WeaponClass) + else + ply:GiveAmmo(70, "Buckshot", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From 7ec5ffaaa4a72c3233219a23983a136283d2df74 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 19:48:57 +0000 Subject: [PATCH 08/11] Added option to buy ammo if you own the gun --- lua/pointshop/items/weapons/smg.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/pointshop/items/weapons/smg.lua b/lua/pointshop/items/weapons/smg.lua index fc79d77..5457204 100644 --- a/lua/pointshop/items/weapons/smg.lua +++ b/lua/pointshop/items/weapons/smg.lua @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_smg1' ITEM.SingleUse = true function ITEM:OnBuy(ply) + if (!ply:HasWeapon(self.WeaponClass)) then ply:Give(self.WeaponClass) + else + ply:GiveAmmo(180, "SMG1", false) + end ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) -end \ No newline at end of file +end From 2537d5159cf0de5269d1754c25e0fc5b0fc60f50 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 20:08:10 +0000 Subject: [PATCH 09/11] Adds function BodyGroup and some icons --- lua/pointshop/vgui/DPointShopItem.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lua/pointshop/vgui/DPointShopItem.lua b/lua/pointshop/vgui/DPointShopItem.lua index d636d36..7f7e748 100644 --- a/lua/pointshop/vgui/DPointShopItem.lua +++ b/lua/pointshop/vgui/DPointShopItem.lua @@ -3,6 +3,8 @@ local PANEL = {} local adminicon = Material("icon16/shield.png") local equippedicon = Material("icon16/eye.png") local groupicon = Material("icon16/group.png") +local modifyicon = Material("icon16/color_wheel.png") +local bodygroupicon = Material("icon16/cog.png") local canbuycolor = Color(0, 100, 0, 125) local cantbuycolor = Color(100, 0, 0, 125) @@ -58,6 +60,14 @@ function PANEL:DoClick() PS.Items[self.Data.ID]:Modify(LocalPlayer().PS_Items[self.Data.ID].Modifiers) end) end + + if LocalPlayer():PS_HasItemEquipped(self.Data.ID) and self.Data.BodyGroup then + menu:AddSpacer() + + menu:AddOption('Body Groups...', function() + PS.Items[self.Data.ID]:BodyGroup(LocalPlayer().PS_Items[self.Data.ID].Modifiers) + end) + end end menu:Open() @@ -155,6 +165,18 @@ function PANEL:PaintOver() surface.SetDrawColor(Color(255, 255, 255, 255)) surface.DrawTexturedRect(5, self:GetTall() - self.InfoHeight - 5 - 16, 16, 16) end + + if self.Data.Modify then + surface.SetMaterial(modifyicon) + surface.SetDrawColor(Color(255, 255, 255, 255)) + surface.DrawTexturedRect(5, 5, 16, 16) + end + + if self.Data.BodyGroup then + surface.SetMaterial(bodygroupicon) + surface.SetDrawColor(Color(255, 255, 255, 255)) + surface.DrawTexturedRect(5, 26, 16, 16) + end local points = PS.Config.CalculateBuyPrice(LocalPlayer(), self.Data) From 195b2a4971ca5ce425292b688eb8d90d616b4113 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 20:11:52 +0000 Subject: [PATCH 10/11] Adds BodyGroups and Skin settings to the preview --- lua/pointshop/vgui/DPointShopPreview.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lua/pointshop/vgui/DPointShopPreview.lua b/lua/pointshop/vgui/DPointShopPreview.lua index 2c7c661..3ad4153 100644 --- a/lua/pointshop/vgui/DPointShopPreview.lua +++ b/lua/pointshop/vgui/DPointShopPreview.lua @@ -2,7 +2,7 @@ local PANEL = {} function PANEL:Init() self:SetModel(LocalPlayer():GetModel()) - + local PrevMins, PrevMaxs = self.Entity:GetRenderBounds() self:SetCamPos(PrevMins:Distance(PrevMaxs) * Vector(0.30, 0.30, 0.25) + Vector(0, 0, 15)) self:SetLookAt((PrevMaxs + PrevMins) / 2) @@ -14,8 +14,18 @@ function PANEL:Paint() local x, y = self:LocalToScreen( 0, 0 ) self:LayoutEntity( self.Entity ) - - local ang = self.aLookAngle + function self.Entity:GetPlayerColor() return LocalPlayer():GetPlayerColor() end + + self.Entity:SetSkin(LocalPlayer():GetSkin()) + for i = 0, 20 do + if LocalPlayer():GetBodygroup(i) ~= nil then + self.Entity:SetBodygroup(i, LocalPlayer():GetBodygroup(i)) + else + self.Entity:SetBodygroup(i, 0) + end + end + + local ang = self.aLookAngle if ( !ang ) then ang = (self.vLookatPos-self.vCamPos):Angle() end From 2721db2a220439e090b48099862360c03cb68e80 Mon Sep 17 00:00:00 2001 From: TheWhichDoctor Date: Wed, 30 Oct 2019 20:15:42 +0000 Subject: [PATCH 11/11] Added color chooser for playermodels Code was made ~2 years ago, needed this because for some reason the regular "modifications.color" wouldn't work. --- lua/pointshop/cl_init.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/pointshop/cl_init.lua b/lua/pointshop/cl_init.lua index ddbdd21..d4bba5f 100644 --- a/lua/pointshop/cl_init.lua +++ b/lua/pointshop/cl_init.lua @@ -65,6 +65,16 @@ function PS:ShowColorChooser(item, modifications) self:SendModifications(item.ID, modifications) end end +function PS:ShowPlyColorChooser(item, modifications) + -- TODO: Do this + local chooser = vgui.Create('DPointShopColorChooser') + chooser:SetColor(modifications.plycolor) + + chooser.OnChoose = function(color) + modifications.plycolor = color + self:SendModifications(item.ID, modifications) + end +end function PS:SendModifications(item_id, modifications) net.Start('PS_ModifyItem')