mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
15
gamemodes/darkrp/plugins/customitems/cl_hooks.lua
Normal file
15
gamemodes/darkrp/plugins/customitems/cl_hooks.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/
|
||||
--]]
|
||||
|
||||
|
||||
function PLUGIN:InitPostEntity()
|
||||
net.Start("ixRequestCustomItems")
|
||||
net.SendToServer()
|
||||
end
|
||||
73
gamemodes/darkrp/plugins/customitems/cl_plugin.lua
Normal file
73
gamemodes/darkrp/plugins/customitems/cl_plugin.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
net.Receive("ixCreateCustomItem", function()
|
||||
vgui.Create("ixCustomItemCreator")
|
||||
end)
|
||||
|
||||
net.Receive("ixNetworkCustomItemCreation", function()
|
||||
local data = {
|
||||
base = net.ReadString(),
|
||||
uniqueID = net.ReadString(),
|
||||
name = net.ReadString(),
|
||||
description = net.ReadString(),
|
||||
model = net.ReadString(),
|
||||
skin = net.ReadUInt(5),
|
||||
category = net.ReadString(),
|
||||
iconCam = net.ReadString(),
|
||||
material = net.ReadString(),
|
||||
width = net.ReadUInt(5),
|
||||
height = net.ReadUInt(5),
|
||||
color = net.ReadColor(),
|
||||
rotate = net.ReadBool(),
|
||||
maxStackSize = net.ReadUInt(8),
|
||||
hunger = net.ReadUInt(8),
|
||||
thirst = net.ReadUInt(8),
|
||||
spoilTime = net.ReadUInt(6),
|
||||
damage = net.ReadUInt(8),
|
||||
health = net.ReadUInt(8),
|
||||
amount = net.ReadUInt(7)
|
||||
}
|
||||
|
||||
local base = data.base
|
||||
local iconCam = data.iconCam
|
||||
|
||||
if (data.base == "No Base") then
|
||||
base = nil
|
||||
end
|
||||
|
||||
if (data.iconCam == "") then
|
||||
iconCam = nil
|
||||
else
|
||||
iconCam = util.JSONToTable(iconCam)
|
||||
end
|
||||
|
||||
local ITEM = ix.item.Register(data.uniqueID, base, false, nil, true)
|
||||
ITEM.name = data.name
|
||||
ITEM.description = data.description
|
||||
ITEM.model = data.model
|
||||
ITEM.skin = data.skin
|
||||
ITEM.category = data.category
|
||||
ITEM.iconCam = iconCam
|
||||
ITEM.material = data.material
|
||||
ITEM.width = data.width
|
||||
ITEM.height = data.height
|
||||
ITEM.color = data.color
|
||||
ITEM.rotate = data.rotate
|
||||
ITEM.maxStackSize = data.maxStackSize
|
||||
ITEM.hunger = data.hunger
|
||||
ITEM.thirst = data.thirst
|
||||
ITEM.spoilTime = data.spoilTime
|
||||
ITEM.damage = data.damage
|
||||
ITEM.health = data.health
|
||||
ITEM.amount = data.amount -- Credits. lol
|
||||
ITEM.customItem = true
|
||||
end)
|
||||
278
gamemodes/darkrp/plugins/customitems/derma/cl_itemcreator.lua
Normal file
278
gamemodes/darkrp/plugins/customitems/derma/cl_itemcreator.lua
Normal file
@@ -0,0 +1,278 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
function PANEL:Init()
|
||||
self:SetSize(ScrW(), ScrH())
|
||||
self:SetAlpha(0)
|
||||
self:AlphaTo(255, 0.5, 0)
|
||||
|
||||
self.rows = {}
|
||||
|
||||
self.innerContent = self:Add("EditablePanel")
|
||||
self.innerContent:SetSize(SScaleMin(700 / 3), SScaleMin(600 / 2.5))
|
||||
self.innerContent:Center()
|
||||
self.innerContent:MakePopup()
|
||||
self.innerContent.Paint = function(self, w, h)
|
||||
surface.SetDrawColor(0, 0, 0, 130)
|
||||
surface.DrawRect(0, 0, w, h)
|
||||
end
|
||||
|
||||
local topbar = self.innerContent:Add("Panel")
|
||||
topbar:SetHeight(SScaleMin(50 / 3))
|
||||
topbar:Dock(TOP)
|
||||
topbar.Paint = function(self, width, height)
|
||||
surface.SetDrawColor(0, 0, 0, 130)
|
||||
surface.DrawRect(0, 0, width, height)
|
||||
end
|
||||
|
||||
local titleText = topbar:Add("DLabel")
|
||||
titleText:SetFont("CharCreationBoldTitleNoClamp")
|
||||
titleText:Dock(LEFT)
|
||||
titleText:SetText("Custom Item Creator")
|
||||
titleText:DockMargin(SScaleMin(10 / 3), 0, 0, 0)
|
||||
titleText:SetContentAlignment(4)
|
||||
titleText:SizeToContents()
|
||||
|
||||
local exit = topbar:Add("DImageButton")
|
||||
exit:SetImage("willardnetworks/tabmenu/navicons/exit.png")
|
||||
exit:SetSize(SScaleMin(20 / 3), SScaleMin(20 / 3))
|
||||
exit:DockMargin(0, SScaleMin(15 / 3), SScaleMin(10 / 3), SScaleMin(15 / 3))
|
||||
exit:Dock(RIGHT)
|
||||
exit.DoClick = function()
|
||||
if (self.ExitCallback) then
|
||||
self.ExitCallback()
|
||||
end
|
||||
|
||||
self:Remove()
|
||||
surface.PlaySound("helix/ui/press.wav")
|
||||
end
|
||||
|
||||
local divider = topbar:Add("Panel")
|
||||
divider:SetSize(1, topbar:GetTall())
|
||||
divider:Dock(RIGHT)
|
||||
divider:DockMargin(0, SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3))
|
||||
divider.Paint = function(self, w, h)
|
||||
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
|
||||
surface.DrawLine(0, 0, 0, h)
|
||||
end
|
||||
|
||||
local itemBases = {"No Base"}
|
||||
|
||||
for base, _ in pairs(ix.item.base) do
|
||||
itemBases[#itemBases + 1] = base
|
||||
end
|
||||
|
||||
-- VGUI Class | VGUI Identifier | Name | Description | Default | Additional Data
|
||||
self:AddRow("ixSettingsRowArray", "rowBase", "Base", "The base item that this item should be based off of.", 1, {populate = function() return itemBases end})
|
||||
self:AddRow("ixSettingsRowString", "rowID", "Unique ID", "The unique identifier of the item. Should be unique and not contain spaces.", "custom_item")
|
||||
self:AddRow("ixSettingsRowString", "rowName", "Name", "The name of the item.", "An Item")
|
||||
self:AddRow("ixSettingsRowString", "rowDesc", "Description", "The description of the item.", "A custom item.")
|
||||
self:AddRow("ixSettingsRowString", "rowModel", "Model", "The model of the item.", "models/props_junk/PopCan01a.mdl")
|
||||
self:AddRow("ixSettingsRowNumber", "rowSkin", "Skin", "The skin of the item.", 0, {min = 0, max = 10})
|
||||
self:AddRow("ixSettingsRowString", "rowCategory", "Category", "The category this item falls under.", "Custom Items")
|
||||
|
||||
-- Doing this one manually because it's a little more complicated.
|
||||
self.rowCam = self.innerContent:Add("ixSettingsRowString")
|
||||
self.rowCam:Dock(TOP)
|
||||
self.rowCam:DockMargin(0, 0, 6, 0)
|
||||
self.rowCam:SetText("Icon Position")
|
||||
|
||||
self.rowCam.OnResetClicked = function()
|
||||
self.rowCam:SetShowReset(false)
|
||||
self.rowCam:SetValue("", true)
|
||||
end
|
||||
self.rowCam.OnValueChanged = function()
|
||||
local newValue = self.rowCam:GetValue()
|
||||
|
||||
self.rowCam:SetShowReset(newValue != "", "Icon Position", "")
|
||||
end
|
||||
self.rowCam:GetLabel():SetHelixTooltip(function(tooltip)
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText("Icon Position")
|
||||
title:SizeToContents()
|
||||
title:SetMaxWidth(math.max(title:GetMaxWidth(), ScrW() * 0.5))
|
||||
|
||||
local desc = tooltip:AddRow("description")
|
||||
desc:SetText("The position, angles, and FOV of this item's inventory icon. Leave blank for default settings.")
|
||||
desc:SizeToContents()
|
||||
end)
|
||||
|
||||
self.rowCam.rowCamButton = self.rowCam:Add("DButton")
|
||||
self.rowCam.rowCamButton:Dock(RIGHT)
|
||||
self.rowCam.rowCamButton:SetFont("ixGenericFont")
|
||||
self.rowCam.rowCamButton:SetColor(ix.config.Get("color", Color(255, 255, 255)))
|
||||
self.rowCam.rowCamButton:SetText("CHANGE")
|
||||
self.rowCam.rowCamButton.DoClick = function()
|
||||
local iconEditor = vgui.Create("ix_icon_editor")
|
||||
|
||||
iconEditor.modelPath:SetValue(self["rowModel"]:GetValue())
|
||||
iconEditor.model:SetModel(self["rowModel"]:GetValue())
|
||||
iconEditor.width:SetValue(self["rowWidth"]:GetValue())
|
||||
iconEditor.height:SetValue(self["rowHeight"]:GetValue())
|
||||
|
||||
iconEditor.best:DoClick()
|
||||
|
||||
iconEditor.copy:SetText("F")
|
||||
iconEditor.copy:SetTooltip("Confirm")
|
||||
iconEditor.copy.DoClick = function()
|
||||
local camPos = iconEditor.model:GetCamPos()
|
||||
local camAng = iconEditor.model:GetLookAng()
|
||||
local iconCam = {
|
||||
pos = Vector(math.Round(camPos.x, 2), math.Round(camPos.y, 2), math.Round(camPos.z, 2)),
|
||||
ang = Angle(math.Round(camAng.p, 2), math.Round(camAng.y, 2), math.Round(camAng.r, 2)),
|
||||
fov = math.Round(iconEditor.model:GetFOV(), 2)
|
||||
}
|
||||
|
||||
self.rowCam:SetValue(util.TableToJSON(iconCam))
|
||||
iconEditor:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
self.rowCam.setting:Remove()
|
||||
|
||||
self.rowCam.setting = self.rowCam:Add("ixTextEntry")
|
||||
self.rowCam.setting:Dock(RIGHT)
|
||||
self.rowCam.setting:DockMargin(0, 0, 8, 0)
|
||||
self.rowCam.setting:SetFont("TitlesFontNoBoldNoClamp")
|
||||
self.rowCam.setting:SetBackgroundColor(derma.GetColor("DarkerBackground", self.rowCam))
|
||||
self.rowCam.setting.OnEnter = function()
|
||||
self.rowCam:OnValueChanged(self.rowCam:GetValue())
|
||||
end
|
||||
self.rowCam:SetValue("")
|
||||
|
||||
self.rowCam.PerformLayout = function(this, width, height)
|
||||
this.setting:SetWide(width * 0.34)
|
||||
this.rowCamButton:SetWide(width * 0.15)
|
||||
end
|
||||
|
||||
self.rows[#self.rows + 1] = self.rowCam
|
||||
|
||||
self:AddRow("ixSettingsRowString", "rowMaterial", "Material", "The material of the item.", "")
|
||||
self:AddRow("ixSettingsRowNumber", "rowWidth", "Width", "The physical width of the item.", 1, {min = 1, max = 10})
|
||||
self:AddRow("ixSettingsRowNumber", "rowHeight", "Height", "The physical height of the item.", 1, {min = 1, max = 10})
|
||||
self:AddRow("ixSettingsRowColor", "rowColor", "Color", "The color of the item.", Color(255, 255, 255))
|
||||
self:AddRow("ixSettingsRowBool", "rowRotating", "Rotating", "Whether the item's icon should rotate in the inventory.", false)
|
||||
self:AddRow("ixSettingsRowNumber", "rowStack", "Max Stack", "The maximum stack of this item, if supported by the item base.", 1, {min = 1, max = 100})
|
||||
self:AddRow("ixSettingsRowNumber", "rowHunger", "Hunger Restoration", "The amount of hunger to restore once this item is used, if supported by the item base.", 0, {min = 0, max = 100})
|
||||
self:AddRow("ixSettingsRowNumber", "rowThirst", "Thirst Restoration", "The amount of thirst to restore once this item is used, if supported by the item base.", 0, {min = 0, max = 100})
|
||||
self:AddRow("ixSettingsRowNumber", "rowSpoil", "Spoil Time", "The time, in days, until the item spoils, if supported by the item base.", 14, {min = 1, max = 30})
|
||||
self:AddRow("ixSettingsRowNumber", "rowDamage", "Damage", "The amount of damage to deal once this item is used, if supported by the item base.", 0, {min = 0, max = 100})
|
||||
self:AddRow("ixSettingsRowNumber", "rowHealth", "Health", "The amount of health to restore once this item is used, if supported by the item base.", 0, {min = 0, max = 100})
|
||||
self:AddRow("ixSettingsRowNumber", "rowCredits", "Credits", "The amount of Credits to award once this item is used, if supported by the item base.", 0, {min = 0, max = 50})
|
||||
|
||||
self.createItem = self.innerContent:Add("DButton")
|
||||
self.createItem:Dock(BOTTOM)
|
||||
self.createItem:DockMargin(10, 10, 10, 10)
|
||||
self.createItem:SetTall(SScaleMin(60 / 4))
|
||||
self.createItem:SetFont("ixMediumFont")
|
||||
self.createItem:SetColor(ix.config.Get("color", Color(255, 255, 255)))
|
||||
self.createItem:SetText("CREATE ITEM")
|
||||
self.createItem.DoClick = function()
|
||||
surface.PlaySound("helix/ui/press.wav")
|
||||
|
||||
local uniqueID = string.Trim(self["rowID"]:GetValue())
|
||||
|
||||
if (uniqueID == "") then
|
||||
LocalPlayer():Notify("Bu geçerli bir Benzersiz Kimlik değil!")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if (ix.item.list[uniqueID]) then
|
||||
LocalPlayer():Notify("Bu öğe zaten var!")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
net.Start("ixCreateCustomItem")
|
||||
net.WriteString(select(1, self["rowBase"].setting:GetSelected()))
|
||||
net.WriteString(self["rowID"]:GetValue())
|
||||
net.WriteString(self["rowName"]:GetValue())
|
||||
net.WriteString(self["rowDesc"]:GetValue())
|
||||
net.WriteString(self["rowModel"]:GetValue())
|
||||
net.WriteUInt(self["rowSkin"]:GetValue(), 5)
|
||||
net.WriteString(self["rowCategory"]:GetValue())
|
||||
net.WriteString(self.rowCam:GetValue())
|
||||
net.WriteString(self["rowMaterial"]:GetValue())
|
||||
net.WriteUInt(self["rowWidth"]:GetValue(), 5)
|
||||
net.WriteUInt(self["rowHeight"]:GetValue(), 5)
|
||||
net.WriteColor(Color(self["rowColor"]:GetValue().r, self["rowColor"]:GetValue().g, self["rowColor"]:GetValue().b))
|
||||
net.WriteBool(self["rowRotating"]:GetValue())
|
||||
net.WriteUInt(self["rowStack"]:GetValue(), 8)
|
||||
net.WriteUInt(self["rowHunger"]:GetValue(), 8)
|
||||
net.WriteUInt(self["rowThirst"]:GetValue(), 8)
|
||||
net.WriteUInt(self["rowSpoil"]:GetValue(), 6)
|
||||
net.WriteUInt(self["rowDamage"]:GetValue(), 8)
|
||||
net.WriteUInt(self["rowHealth"]:GetValue(), 8)
|
||||
net.WriteUInt(self["rowCredits"]:GetValue(), 7)
|
||||
net.SendToServer()
|
||||
|
||||
self:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function PANEL:AddRow(class, uniqueID, name, description, default, data)
|
||||
data = data or {}
|
||||
|
||||
self[uniqueID] = self.innerContent:Add(class)
|
||||
self[uniqueID]:Dock(TOP)
|
||||
self[uniqueID]:DockMargin(0, 0, 6, 0)
|
||||
self[uniqueID]:SetText(name)
|
||||
|
||||
if (data.min) then
|
||||
self[uniqueID]:SetMin(data.min)
|
||||
end
|
||||
|
||||
if (data.max) then
|
||||
self[uniqueID]:SetMax(data.max)
|
||||
end
|
||||
|
||||
if (data.populate) then
|
||||
self[uniqueID]:Populate(nil, data)
|
||||
end
|
||||
|
||||
self[uniqueID]:SetValue(default)
|
||||
|
||||
self[uniqueID].OnResetClicked = function()
|
||||
self[uniqueID]:SetShowReset(false)
|
||||
self[uniqueID]:SetValue(default, true)
|
||||
end
|
||||
self[uniqueID].OnValueChanged = function()
|
||||
local newValue = self[uniqueID]:GetValue()
|
||||
|
||||
self[uniqueID]:SetShowReset(newValue != default, name, default)
|
||||
end
|
||||
self[uniqueID]:GetLabel():SetHelixTooltip(function(tooltip)
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText(name)
|
||||
title:SizeToContents()
|
||||
title:SetMaxWidth(math.max(title:GetMaxWidth(), ScrW() * 0.5))
|
||||
|
||||
local desc = tooltip:AddRow("description")
|
||||
desc:SetText(description)
|
||||
desc:SizeToContents()
|
||||
end)
|
||||
|
||||
self.rows[#self.rows + 1] = self[uniqueID]
|
||||
end
|
||||
|
||||
function PANEL:Paint(width, height)
|
||||
surface.SetDrawColor(Color(63, 58, 115, 220))
|
||||
surface.DrawRect(0, 0, width, height)
|
||||
|
||||
Derma_DrawBackgroundBlur(self, 1)
|
||||
end
|
||||
|
||||
vgui.Register("ixCustomItemCreator", PANEL, "EditablePanel")
|
||||
35
gamemodes/darkrp/plugins/customitems/sh_plugin.lua
Normal file
35
gamemodes/darkrp/plugins/customitems/sh_plugin.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
PLUGIN.name = "Advanced Custom Item Creation"
|
||||
PLUGIN.author = "Aspect™"
|
||||
PLUGIN.description = "Adds the ability to create custom items on the fly with advanced customization options."
|
||||
|
||||
ix.util.Include("cl_hooks.lua")
|
||||
ix.util.Include("cl_plugin.lua")
|
||||
ix.util.Include("sv_hooks.lua")
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
|
||||
CAMI.RegisterPrivilege({
|
||||
Name = "Helix - Create Custom Script",
|
||||
MinAccess = "admin"
|
||||
})
|
||||
|
||||
ix.command.Add("CreateCustomItem", {
|
||||
description = "Opens the Custom Item Creator menu.",
|
||||
OnRun = function(self, client)
|
||||
net.Start("ixCreateCustomItem")
|
||||
net.Send(client)
|
||||
end,
|
||||
OnCheckAccess = function(self, client)
|
||||
return CAMI.PlayerHasAccess(client, "Helix - Create Custom Script")
|
||||
end
|
||||
})
|
||||
54
gamemodes/darkrp/plugins/customitems/sv_hooks.lua
Normal file
54
gamemodes/darkrp/plugins/customitems/sv_hooks.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
function PLUGIN:InitializedPlugins()
|
||||
local files, _ = file.Find("customitems/*", "DATA")
|
||||
|
||||
for _, item in ipairs(files) do
|
||||
item = util.JSONToTable(file.Read("customitems/" .. item, "DATA"))
|
||||
|
||||
local base = item.base
|
||||
local iconCam = item.iconCam
|
||||
|
||||
if (item.base == "No Base") then
|
||||
base = nil
|
||||
end
|
||||
|
||||
if (item.iconCam == "") then
|
||||
iconCam = nil
|
||||
else
|
||||
iconCam = util.JSONToTable(iconCam)
|
||||
end
|
||||
|
||||
item.uniqueID = string.Replace(item.uniqueID, " ", "_")
|
||||
|
||||
local ITEM = ix.item.Register(item.uniqueID, base, false, nil, true)
|
||||
ITEM.name = item.name
|
||||
ITEM.description = item.description
|
||||
ITEM.model = item.model
|
||||
ITEM.skin = item.skin
|
||||
ITEM.category = item.category
|
||||
ITEM.iconCam = iconCam
|
||||
ITEM.material = item.material
|
||||
ITEM.width = item.width
|
||||
ITEM.height = item.height
|
||||
ITEM.color = item.color
|
||||
ITEM.rotate = item.rotate
|
||||
ITEM.maxStackSize = item.maxStackSize
|
||||
ITEM.hunger = item.hunger
|
||||
ITEM.thirst = item.thirst
|
||||
ITEM.spoilTime = item.spoilTime
|
||||
ITEM.damage = item.damage
|
||||
ITEM.health = item.health
|
||||
ITEM.amount = item.amount -- Credits. lol
|
||||
ITEM.customItem = true
|
||||
end
|
||||
end
|
||||
197
gamemodes/darkrp/plugins/customitems/sv_plugin.lua
Normal file
197
gamemodes/darkrp/plugins/customitems/sv_plugin.lua
Normal file
@@ -0,0 +1,197 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
util.AddNetworkString("ixCreateCustomItem")
|
||||
util.AddNetworkString("ixNetworkCustomItemCreation")
|
||||
util.AddNetworkString("ixRequestCustomItems")
|
||||
util.AddNetworkString("ixDeleteCustomItem")
|
||||
|
||||
function PLUGIN:DeleteItemFromDatabase(itemID)
|
||||
local query = mysql:Delete("ix_items")
|
||||
query:Where("unique_id", itemID)
|
||||
query:Execute()
|
||||
end
|
||||
|
||||
net.Receive("ixCreateCustomItem", function(_, client)
|
||||
if (!CAMI.PlayerHasAccess(client, "Helix - Create Custom Script")) then return end
|
||||
|
||||
local data = {
|
||||
base = net.ReadString(),
|
||||
uniqueID = net.ReadString(),
|
||||
name = net.ReadString(),
|
||||
description = net.ReadString(),
|
||||
model = net.ReadString(),
|
||||
skin = net.ReadUInt(5),
|
||||
category = net.ReadString(),
|
||||
iconCam = net.ReadString(),
|
||||
material = net.ReadString(),
|
||||
width = net.ReadUInt(5),
|
||||
height = net.ReadUInt(5),
|
||||
color = net.ReadColor(),
|
||||
rotate = net.ReadBool(),
|
||||
maxStackSize = net.ReadUInt(8),
|
||||
hunger = net.ReadUInt(8),
|
||||
thirst = net.ReadUInt(8),
|
||||
spoilTime = net.ReadUInt(6),
|
||||
damage = net.ReadUInt(8),
|
||||
health = net.ReadUInt(8),
|
||||
amount = net.ReadUInt(7)
|
||||
}
|
||||
|
||||
for key, value in pairs(data) do
|
||||
if (!isstring(value)) then continue end
|
||||
|
||||
data[key] = string.Trim(value)
|
||||
end
|
||||
|
||||
if (data.uniqueID == "") then return end
|
||||
if (ix.item.list[data.uniqueID]) then return end
|
||||
|
||||
local base = data.base
|
||||
local iconCam = data.iconCam
|
||||
|
||||
if (data.base == "No Base") then
|
||||
base = nil
|
||||
end
|
||||
|
||||
if (data.iconCam == "") then
|
||||
iconCam = nil
|
||||
else
|
||||
iconCam = util.JSONToTable(iconCam)
|
||||
end
|
||||
|
||||
data.uniqueID = string.Replace(data.uniqueID, " ", "_")
|
||||
|
||||
local ITEM = ix.item.Register(data.uniqueID, base, false, nil, true)
|
||||
ITEM.name = data.name
|
||||
ITEM.description = data.description
|
||||
ITEM.model = data.model
|
||||
ITEM.skin = data.skin
|
||||
ITEM.category = data.category
|
||||
ITEM.iconCam = iconCam
|
||||
ITEM.material = data.material
|
||||
ITEM.width = data.width
|
||||
ITEM.height = data.height
|
||||
ITEM.color = data.color
|
||||
ITEM.rotate = data.rotate
|
||||
ITEM.maxStackSize = data.maxStackSize
|
||||
ITEM.hunger = data.hunger
|
||||
ITEM.thirst = data.thirst
|
||||
ITEM.spoilTime = data.spoilTime
|
||||
ITEM.damage = data.damage
|
||||
ITEM.health = data.health
|
||||
ITEM.amount = data.amount -- Credits. lol
|
||||
ITEM.customItem = true
|
||||
|
||||
net.Start("ixNetworkCustomItemCreation")
|
||||
net.WriteString(data.base)
|
||||
net.WriteString(data.uniqueID)
|
||||
net.WriteString(data.name)
|
||||
net.WriteString(data.description)
|
||||
net.WriteString(data.model)
|
||||
net.WriteUInt(data.skin, 5)
|
||||
net.WriteString(data.category)
|
||||
net.WriteString(data.iconCam)
|
||||
net.WriteString(data.material)
|
||||
net.WriteUInt(data.width, 5)
|
||||
net.WriteUInt(data.height, 5)
|
||||
net.WriteColor(data.color)
|
||||
net.WriteBool(data.rotate)
|
||||
net.WriteUInt(data.maxStackSize, 8)
|
||||
net.WriteUInt(data.hunger, 8)
|
||||
net.WriteUInt(data.thirst, 8)
|
||||
net.WriteUInt(data.spoilTime, 6)
|
||||
net.WriteUInt(data.damage, 8)
|
||||
net.WriteUInt(data.health, 8)
|
||||
net.WriteUInt(data.amount, 7)
|
||||
net.Broadcast()
|
||||
|
||||
file.CreateDir("customitems")
|
||||
file.Write("customitems/" .. data.uniqueID .. ".json", util.TableToJSON(data))
|
||||
|
||||
-- Timer probably isn't needed, but I like to give it some space just in case.
|
||||
timer.Simple(1, function()
|
||||
if (!client:GetCharacter():GetInventory():Add(data.uniqueID)) then
|
||||
ix.item.Spawn(data.uniqueID, client)
|
||||
end
|
||||
end)
|
||||
|
||||
client:Notify("\"" .. data.name .. "\" başarılı bir şekilde yaratıldı. Bulmak için Item Spawner'ı yenileyin.")
|
||||
end)
|
||||
|
||||
net.Receive("ixRequestCustomItems", function(_, client)
|
||||
if (client.receivedItems) then return end -- Avoid spam
|
||||
|
||||
local files, _ = file.Find("customitems/*", "DATA")
|
||||
local itemList = {}
|
||||
|
||||
for _, itemFile in ipairs(files) do
|
||||
local item = util.JSONToTable(file.Read("customitems/" .. itemFile, "DATA") or "")
|
||||
if (!item) then continue end
|
||||
|
||||
itemList[#itemList + 1] = item
|
||||
end
|
||||
|
||||
for k, data in ipairs(itemList) do
|
||||
timer.Simple(1 * k, function()
|
||||
net.Start("ixNetworkCustomItemCreation")
|
||||
net.WriteString(data.base)
|
||||
net.WriteString(data.uniqueID)
|
||||
net.WriteString(data.name)
|
||||
net.WriteString(data.description)
|
||||
net.WriteString(data.model)
|
||||
net.WriteUInt(data.skin, 5)
|
||||
net.WriteString(data.category)
|
||||
net.WriteString(data.iconCam)
|
||||
net.WriteString(data.material)
|
||||
net.WriteUInt(data.width, 5)
|
||||
net.WriteUInt(data.height, 5)
|
||||
net.WriteColor(IsColor(data.color) and data.color or istable(data.color) and Color(data.color.r, data.color.g, data.color.b) or Color(255, 255, 255))
|
||||
net.WriteBool(data.rotate)
|
||||
net.WriteUInt(data.maxStackSize, 8)
|
||||
net.WriteUInt(data.hunger, 8)
|
||||
net.WriteUInt(data.thirst, 8)
|
||||
net.WriteUInt(data.spoilTime, 6)
|
||||
net.WriteUInt(data.damage, 8)
|
||||
net.WriteUInt(data.health, 8)
|
||||
net.WriteUInt(data.amount, 7)
|
||||
net.Send(client)
|
||||
end)
|
||||
end
|
||||
|
||||
client.receivedItems = true
|
||||
end)
|
||||
|
||||
net.Receive("ixDeleteCustomItem", function(_, client)
|
||||
if (!CAMI.PlayerHasAccess(client, "Helix - Create Custom Script")) then return end
|
||||
|
||||
local itemID = net.ReadString()
|
||||
local item = ix.item.list[itemID]
|
||||
|
||||
if (!item) then return end
|
||||
if (!item.customItem) then
|
||||
client:Notify("Bu custom item değildir - silinemez!")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if (!file.Exists("customitems/" .. itemID .. ".json", "DATA")) then
|
||||
client:Notify("Bu öğe yok. Zaten silinmek üzere işaretlenmiş olabilir!")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
file.Delete("customitems/" .. itemID .. ".json", "DATA")
|
||||
PLUGIN:DeleteItemFromDatabase(itemID) -- We remove the item from the database, so the inventory doesn't break due to null items.
|
||||
client:Notify("\"" .. item.name .. "\" silinmek üzere işaretlendi. Sunucu yeniden başlatıldığında kaldırılacak.")
|
||||
end)
|
||||
Reference in New Issue
Block a user