Files
wnsrc/gamemodes/darkrp/plugins/willardskills/items/base/sh_assembly.lua
lifestorm df294d03aa Upload
2024-08-04 23:54:45 +03:00

83 lines
2.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--[[
| 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.uniqueID = "base_assembly"
ITEM.name = "Taban Montaj Kiti"
ITEM.description = "Bu ahşap paket, bir dizi talimatın yanı sıra, Crafting aparatı için çok sayıda farklı bileşen parçası içerir."
ITEM.category = "Tools"
ITEM.width = 3
ITEM.height = 3
ITEM.model = "models/props_junk/wood_crate001a.mdl"
ITEM.useSound = "physics/metal/metal_box_break1.wav"
ITEM.openedItem = "tool_craftingbench"
ITEM.openRequirement = "tool_toolkit"
ITEM.functions.Assemble = {
icon = "icon16/wrench.png",
OnCanRun = function(item)
return !IsValid(item.entity)
end,
OnRun = function(item)
local client = item.player
if (client.CantPlace) then
client:NotifyLocalized("assembleCant")
return false
end
client.CantPlace = true
timer.Simple(3, function()
if (client) then
client.CantPlace = false
end
end)
local character = client:GetCharacter()
local inventory = character:GetInventory()
local requirementTable = ix.item.list[item.openRequirement]
local requirementName = requirementTable.name or item.openRequirement
local openerItem = inventory:HasItem(item.openRequirement)
if (!openerItem) then
client:NotifyLocalized("assembleMissingRequirement", requirementName)
return false
else
if (item.openedItem) then
local openedItemName = ix.item.list[item.openedItem].name or item.openedItem
local openedItemWidth, openedItemHeight = ix.item.list[item.openedItem].width, ix.item.list[item.openedItem].height
timer.Simple(0.25, function()
if (inventory:FindEmptySlot(openedItemWidth, openedItemHeight)) then
inventory:Add(item.openedItem)
if (openerItem.isTool) then
openerItem:DamageDurability(1)
end
client:EmitSound(item.useSound)
client:NotifyLocalized("assembleSuccess", openedItemName)
else
client:NotifyLocalized("assembleNoSpace", openedItemWidth, openedItemHeight)
inventory:Add(item.uniqueID)
end
end)
else
return false
end
end
end
}