mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
57
gamemodes/darkrp/schema/items/base/sh_armor_clothes.lua
Normal file
57
gamemodes/darkrp/schema/items/base/sh_armor_clothes.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.base = "base_outfit"
|
||||
ITEM.name = "Armored Clothes"
|
||||
ITEM.description = "A suitcase full of clothes."
|
||||
ITEM.model = Model("models/props_c17/suitcase_passenger_physics.mdl")
|
||||
ITEM.category = "Armored Clothing"
|
||||
ITEM.width = 2
|
||||
ITEM.height = 2
|
||||
ITEM.maxArmor = 0
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
local panel = tooltip:AddRowAfter("name", "armor")
|
||||
panel:SetBackgroundColor(derma.GetColor("Warning", tooltip))
|
||||
panel:SetText("Armor: " .. (self:GetData("equip") and LocalPlayer():Armor() or self:GetData("armor", self.maxArmor)))
|
||||
panel:SizeToContents()
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnEquipped()
|
||||
self.player:SetArmor(self:GetData("armor", self.maxArmor))
|
||||
end
|
||||
|
||||
function ITEM:OnUnequipped()
|
||||
self:SetData("armor", math.Clamp(self.player:Armor(), 0, self.maxArmor))
|
||||
self.player:SetArmor(0)
|
||||
end
|
||||
|
||||
function ITEM:Repair(amount)
|
||||
self:SetData("armor", math.Clamp(self:GetData("armor") + amount, 0, self.maxArmor))
|
||||
end
|
||||
|
||||
function ITEM:OnLoadout()
|
||||
if (self:GetData("equip")) then
|
||||
self.player:SetArmor(self:GetData("armor", self.maxArmor))
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnSave()
|
||||
if (self:GetData("equip")) then
|
||||
local armor = math.Clamp(self.player:Armor(), 0, self.maxArmor)
|
||||
self:SetData("armor", armor)
|
||||
if (armor != self.player:Armor()) then
|
||||
self.player:SetArmor(armor)
|
||||
end
|
||||
end
|
||||
end
|
||||
128
gamemodes/darkrp/schema/items/base/sh_genericequipable.lua
Normal file
128
gamemodes/darkrp/schema/items/base/sh_genericequipable.lua
Normal file
@@ -0,0 +1,128 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Generic Equipable Item"
|
||||
ITEM.description = "An item that can be equipped."
|
||||
ITEM.category = "Equipable"
|
||||
ITEM.model = "models/props_lab/box01a.mdl"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
|
||||
-- Inventory drawing
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("equip")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
if (self:GetData("equip")) then
|
||||
local name = tooltip:GetRow("name")
|
||||
name:SetBackgroundColor(derma.GetColor("Success", tooltip))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:Equip(client)
|
||||
self:SetData("equip", true)
|
||||
self:OnEquipped(client)
|
||||
end
|
||||
|
||||
function ITEM:Unequip(client)
|
||||
self:SetData("equip", false)
|
||||
self:OnUnequipped(client)
|
||||
end
|
||||
|
||||
|
||||
ITEM:Hook("drop", function(item)
|
||||
if (item:GetData("equip")) then
|
||||
local character = ix.char.loaded[item.owner]
|
||||
local client = character and character:GetPlayer() or item:GetOwner()
|
||||
|
||||
item.player = client
|
||||
item:Unequip(item:GetOwner())
|
||||
end
|
||||
end)
|
||||
|
||||
ITEM.functions.EquipUn = { -- sorry, for name order.
|
||||
name = "Unequip",
|
||||
icon = "icon16/cross.png",
|
||||
OnRun = function(item)
|
||||
item:Unequip(item.player)
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") == true and hook.Run("CanPlayerUnequipItem", client, item) != false
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.Equip = {
|
||||
name = "Equip",
|
||||
icon = "icon16/tick.png",
|
||||
OnRun = function(item)
|
||||
local client = item.player
|
||||
local char = client:GetCharacter()
|
||||
local items = char:GetInventory():GetItems()
|
||||
|
||||
if (item.equipableCategory) then
|
||||
for _, v in pairs(items) do
|
||||
if (v.id != item.id) then
|
||||
local itemTable = ix.item.instances[v.id]
|
||||
|
||||
if (v.equipableCategory == item.equipableCategory and itemTable:GetData("equip")) then
|
||||
client:NotifyLocalized(item.equippedNotify or "itemAlreadyEquipped")
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
item:Equip(item.player)
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") != true and item:CanEquip(client) and hook.Run("CanPlayerEquipItem", client, item) != false
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:CanTransfer(oldInventory, newInventory)
|
||||
if (newInventory and self:GetData("equip")) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ITEM:OnRemoved()
|
||||
if (self.invID != 0 and self:GetData("equip")) then
|
||||
self.player = self:GetOwner()
|
||||
self:Unequip(self.player)
|
||||
|
||||
self.player = nil
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnEquipped(client) end
|
||||
|
||||
function ITEM:OnUnequipped(client) end
|
||||
|
||||
function ITEM:CanEquip(client)
|
||||
return client:GetCharacter():GetInventory():GetID() == self.invID
|
||||
end
|
||||
15
gamemodes/darkrp/schema/items/base/sh_permits.lua
Normal file
15
gamemodes/darkrp/schema/items/base/sh_permits.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
ITEM.name = "Permit Base"
|
||||
ITEM.model = "models/props_lab/clipboard.mdl"
|
||||
ITEM.description = "A permit for purchasing goods."
|
||||
ITEM.category = "Permits"
|
||||
ITEM.permit = "none"
|
||||
142
gamemodes/darkrp/schema/items/base/sh_tools.lua
Normal file
142
gamemodes/darkrp/schema/items/base/sh_tools.lua
Normal file
@@ -0,0 +1,142 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
ITEM.name = "Tools Base"
|
||||
ITEM.description = "Breakable tools for crafting purposes"
|
||||
ITEM.category = "Tools"
|
||||
ITEM.maxDurability = 8
|
||||
ITEM.isTool = true
|
||||
|
||||
local color_green = Color(100, 255, 100)
|
||||
local color_red = Color(200, 25, 25)
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
local maxDurability = item:GetMaxDurability()
|
||||
local durability = item:GetDurability()
|
||||
local width = w - 8
|
||||
local cellWidth = math.Round(width / maxDurability)
|
||||
local color = ix.util.ColorLerp(1 - durability / maxDurability, color_green, color_red)
|
||||
surface.SetDrawColor(color)
|
||||
|
||||
for i = 0, durability - 1 do
|
||||
surface.DrawRect(5 + i * cellWidth, h - 8, cellWidth - 1, 4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.SetMaxDurability = {
|
||||
name = "Set Max Durability",
|
||||
icon = "icon16/wrench.png",
|
||||
OnClick = function(itemTable)
|
||||
local client = itemTable.player
|
||||
Derma_StringRequest("Set Durability", "Enter new maximum durability value", itemTable:GetMaxDurability(), function(text)
|
||||
local amount = tonumber(text)
|
||||
|
||||
if (amount and amount > 0) then
|
||||
netstream.Start("ixSetToolMaxDurability", itemTable:GetID(), math.floor(amount))
|
||||
else
|
||||
client:Notify("Geçersiz sayı")
|
||||
end
|
||||
end)
|
||||
end,
|
||||
OnRun = function(itemTable)
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(itemTable)
|
||||
if (IsValid(itemTable.entity)) then
|
||||
return false
|
||||
end
|
||||
|
||||
if (!CAMI.PlayerHasAccess(itemTable.player, "Helix - Basic Admin Commands")) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.SetDurability = {
|
||||
name = "Set Durability",
|
||||
icon = "icon16/wrench.png",
|
||||
OnClick = function(itemTable)
|
||||
local client = itemTable.player
|
||||
Derma_StringRequest("Set Durability", "Enter new durability value", itemTable:GetDurability(), function(text)
|
||||
local amount = tonumber(text)
|
||||
|
||||
if (amount and amount > 0 and amount <= itemTable:GetMaxDurability()) then
|
||||
netstream.Start("ixSetToolDurability", itemTable:GetID(), math.floor(amount))
|
||||
else
|
||||
client:Notify("Geçersiz sayı")
|
||||
end
|
||||
end)
|
||||
end,
|
||||
OnRun = function(itemTable)
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(itemTable)
|
||||
if (IsValid(itemTable.entity)) then
|
||||
return false
|
||||
end
|
||||
|
||||
if (!CAMI.PlayerHasAccess(itemTable.player, "Helix - Basic Admin Commands")) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:GetDescription()
|
||||
local maxDurability = self:GetMaxDurability()
|
||||
local durability = self:GetDurability()
|
||||
return self.description .. "\n\nDayanıklılık: " .. durability .. "/" .. maxDurability
|
||||
end
|
||||
|
||||
function ITEM:OnInstanced(index, x, y, item)
|
||||
self:SetData("durability", self:GetMaxDurability())
|
||||
end
|
||||
|
||||
function ITEM:DamageDurability(amount)
|
||||
self:SetData("durability", math.max(0, self:GetDurability() - 1))
|
||||
|
||||
if (self:GetDurability() == 0) then
|
||||
local name = self.name
|
||||
if IsValid(self:GetOwner()) then
|
||||
ix.log.Add(self, "itemBreakageDurability", name, self:GetOwner())
|
||||
end
|
||||
|
||||
self:OnBreak()
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:GetBreakSound()
|
||||
return "weapons/crowbar/crowbar_impact"..math.random(1, 2)..".wav"
|
||||
end
|
||||
|
||||
function ITEM:OnBreak()
|
||||
local breakSound = self:GetBreakSound()
|
||||
|
||||
if (IsValid(self.player)) then
|
||||
self.player:EmitSound(breakSound, 65)
|
||||
elseif (IsValid(self.entity)) then
|
||||
self.entity:EmitSound(breakSound, 65)
|
||||
end
|
||||
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
function ITEM:GetDurability()
|
||||
return self:GetData("durability", self:GetMaxDurability())
|
||||
end
|
||||
|
||||
function ITEM:GetMaxDurability()
|
||||
return self:GetData("maxDurability", self.maxDurability)
|
||||
end
|
||||
Reference in New Issue
Block a user