mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
131
gamemodes/helix/plugins/deathdrop/entities/entities/ix_drop.lua
Normal file
131
gamemodes/helix/plugins/deathdrop/entities/entities/ix_drop.lua
Normal file
@@ -0,0 +1,131 @@
|
||||
--[[
|
||||
| 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 DEFINE_BASECLASS = DEFINE_BASECLASS
|
||||
local IsValid = IsValid
|
||||
local hook = hook
|
||||
local CurTime = CurTime
|
||||
local net = net
|
||||
local Color = Color
|
||||
local surface = surface
|
||||
local ix = ix
|
||||
|
||||
|
||||
DEFINE_BASECLASS("ix_container")
|
||||
|
||||
ENT.Type = "anim"
|
||||
ENT.PrintName = "Dropped Items"
|
||||
ENT.Category = "Helix"
|
||||
ENT.Spawnable = false
|
||||
|
||||
if (SERVER) then
|
||||
function ENT:Initialize()
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self.receivers = {}
|
||||
|
||||
self:SetDisplayName("Dropped Items")
|
||||
|
||||
local physObj = self:GetPhysicsObject()
|
||||
|
||||
if (IsValid(physObj)) then
|
||||
physObj:EnableMotion(true)
|
||||
physObj:Wake()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
local index = self:GetID()
|
||||
|
||||
if (!ix.shuttingDown and !self.ixIsSafe and ix.entityDataLoaded and index) then
|
||||
local inventory = index != 0 and ix.item.inventories[index]
|
||||
|
||||
if (inventory) then
|
||||
ix.item.inventories[index] = nil
|
||||
|
||||
local query = mysql:Delete("ix_items")
|
||||
query:Where("inventory_id", index)
|
||||
query:Execute()
|
||||
|
||||
query = mysql:Delete("ix_inventories")
|
||||
query:Where("inventory_id", index)
|
||||
query:Execute()
|
||||
end
|
||||
|
||||
hook.Run("DropRemoved", self, inventory)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Use(activator)
|
||||
local inventory = self:GetInventory()
|
||||
|
||||
if (inventory and (activator.ixNextOpen or 0) < CurTime()) then
|
||||
local character = activator:GetCharacter()
|
||||
|
||||
if (character) then
|
||||
if (self:GetLocked() and !self.Sessions[character:GetID()]) then
|
||||
self:EmitSound("doors/default_locked.wav")
|
||||
|
||||
if (!self.keypad) then
|
||||
net.Start("ixContainerPassword")
|
||||
net.WriteEntity(self)
|
||||
net.Send(activator)
|
||||
end
|
||||
else
|
||||
self:OpenInventory(activator)
|
||||
end
|
||||
end
|
||||
|
||||
activator.ixNextOpen = CurTime() + 1
|
||||
end
|
||||
end
|
||||
else
|
||||
ENT.PopulateEntityInfo = true
|
||||
|
||||
local COLOR_LOCKED = Color(200, 38, 19, 200)
|
||||
local COLOR_UNLOCKED = Color(135, 211, 124, 200)
|
||||
|
||||
function ENT:OnPopulateEntityInfo(tooltip)
|
||||
local bLocked = self:GetLocked()
|
||||
|
||||
surface.SetFont("ixIconsSmall")
|
||||
|
||||
local iconText = bLocked and "P" or "Q"
|
||||
local iconWidth, iconHeight = surface.GetTextSize(iconText)
|
||||
|
||||
-- minimal tooltips have centered text so we'll draw the icon above the name instead
|
||||
if (tooltip:IsMinimal()) then
|
||||
local icon = tooltip:AddRow("icon")
|
||||
icon:SetFont("ixIconsSmall")
|
||||
icon:SetTextColor(bLocked and COLOR_LOCKED or COLOR_UNLOCKED)
|
||||
icon:SetText(iconText)
|
||||
icon:SizeToContents()
|
||||
end
|
||||
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText(self:GetDisplayName())
|
||||
title:SetBackgroundColor(ix.config.Get("color"))
|
||||
title:SetTextInset(iconWidth + 8, 0)
|
||||
title:SizeToContents()
|
||||
|
||||
if (!tooltip:IsMinimal()) then
|
||||
title.Paint = function(panel, width, height)
|
||||
panel:PaintBackground(width, height)
|
||||
|
||||
surface.SetFont("ixIconsSmall")
|
||||
surface.SetTextColor(bLocked and COLOR_LOCKED or COLOR_UNLOCKED)
|
||||
surface.SetTextPos(4, height * 0.5 - iconHeight * 0.5)
|
||||
surface.DrawText(iconText)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
16
gamemodes/helix/plugins/deathdrop/languages/sh_english.lua
Normal file
16
gamemodes/helix/plugins/deathdrop/languages/sh_english.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
LANGUAGE = {
|
||||
plyNoRefunding = "This character does not have any lost items.",
|
||||
plyRefund = "Items were successfully refunded.",
|
||||
plyRefundTemp = "Items were successfully refunded. Excess ones were put in a container in front.",
|
||||
plyRefundLost = "%s items were irretrievably lost in the refund!"
|
||||
}
|
||||
16
gamemodes/helix/plugins/deathdrop/languages/sh_polish.lua
Normal file
16
gamemodes/helix/plugins/deathdrop/languages/sh_polish.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
LANGUAGE = {
|
||||
plyNoRefunding = "Ta postać nie ma żadnych utraconych przedmiotów.",
|
||||
plyRefund = "Przedmioty zostały pomyślnie zwrócone.",
|
||||
plyRefundTemp = "Przedmioty zostały pomyślnie zwrócone. Nadmiar został umieszczony w pojemniku z przodu",
|
||||
plyRefundLost = "%s przedmiotów zostało bezpowrotnie utracone podczas zwrotu!"
|
||||
}
|
||||
16
gamemodes/helix/plugins/deathdrop/languages/sh_spanish.lua
Normal file
16
gamemodes/helix/plugins/deathdrop/languages/sh_spanish.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
LANGUAGE = {
|
||||
plyNoRefunding = "Este personaje no tiene objetos perdidos.",
|
||||
plyRefundTemp = "Los objetos se devolvieron con éxito. Los objetos sobrantes se colocaron en un contenedor en frente.",
|
||||
plyRefund = "Los objetos han sido devueltos con éxito.",
|
||||
plyRefundLost = "%s objetos han sido irremediablemente perdidos en la devolución!"
|
||||
}
|
||||
230
gamemodes/helix/plugins/deathdrop/sh_plugin.lua
Normal file
230
gamemodes/helix/plugins/deathdrop/sh_plugin.lua
Normal file
@@ -0,0 +1,230 @@
|
||||
--[[
|
||||
| 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 ix = ix
|
||||
local table = table
|
||||
local pairs = pairs
|
||||
local ents = ents
|
||||
local IsValid = IsValid
|
||||
local Color = Color
|
||||
local math = math
|
||||
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
PLUGIN.name = "Drop Items on Death"
|
||||
PLUGIN.author = "AleXXX_007"
|
||||
PLUGIN.description = "After death, the character will drop they belongings."
|
||||
|
||||
ix.config.Add("dropItems", false, "Whether or not characters drop their items after death.", nil, {
|
||||
category = "Drop Items on Death"
|
||||
})
|
||||
|
||||
ix.config.Add("dropContainerModel", "models/props_c17/BriefCase001a.mdl", "A model path of a container with dropped items.", nil, {
|
||||
category = "Drop Items on Death"
|
||||
})
|
||||
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
|
||||
if (ix.allowedHoldableClasses) then
|
||||
ix.allowedHoldableClasses["ix_drop"] = true
|
||||
end
|
||||
|
||||
ix.char.RegisterVar("refundItems", {
|
||||
field = "refundItems",
|
||||
default = {},
|
||||
bNoNetworking = true,
|
||||
bNoDisplay = true
|
||||
})
|
||||
|
||||
ix.lang.AddTable("english", {
|
||||
deathDropRemoved = "Usunięto łącznie %d death dropów."
|
||||
})
|
||||
|
||||
ix.lang.AddTable("spanish", {
|
||||
deathDropRemoved = "Borrados un total de %d death drops."
|
||||
})
|
||||
|
||||
ix.lang.AddTable("polish", {
|
||||
deathDropRemoved = "Usunięto łącznie %d death dropów."
|
||||
})
|
||||
|
||||
ix.command.Add("RemoveDeathDrops", {
|
||||
description = "Removes all death drops on the map or in the given radius.",
|
||||
adminOnly = true,
|
||||
arguments = {
|
||||
ix.type.number
|
||||
},
|
||||
OnRun = function(self, client, radius)
|
||||
radius = radius and radius * radius or math.huge
|
||||
local pos = client:GetPos()
|
||||
|
||||
local count = 0
|
||||
for k, v in pairs(ents.GetAll()) do
|
||||
if (!IsValid(v)) then continue end
|
||||
|
||||
if (v:GetClass() != "ix_drop") then continue end
|
||||
if (v:GetPos():DistToSqr(pos) > radius) then continue end
|
||||
|
||||
v:Remove()
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
return "@deathDropRemoved", count
|
||||
end
|
||||
})
|
||||
|
||||
if (CLIENT) then
|
||||
function PLUGIN:PostDrawTranslucentRenderables(bDrawingDepth, bDrawingSkybox)
|
||||
local command = string.utf8lower(ix.chat.currentCommand)
|
||||
if (command == "removedeathdrops") then
|
||||
local range = tonumber(ix.chat.currentArguments[1])
|
||||
if (range) then
|
||||
render.SetColorMaterial()
|
||||
render.DrawSphere(LocalPlayer():GetPos(), 0 - range, 50, 50, Color(255,150,0,100))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ix.command.Add("RefundKill", {
|
||||
description = "Returns all items player lost after they last death.",
|
||||
adminOnly = true,
|
||||
arguments = {
|
||||
ix.type.player
|
||||
},
|
||||
OnRun = function(self, client, target)
|
||||
local inventory = target:GetCharacter():GetInventory()
|
||||
local itemIds = target:GetCharacter():GetRefundItems()
|
||||
|
||||
if (!itemIds) then
|
||||
client:NotifyLocalized("plyNoRefunding")
|
||||
end
|
||||
local leftItems = table.Copy(itemIds)
|
||||
local lost = 0
|
||||
local temp = false
|
||||
|
||||
for _, v in pairs(itemIds) do
|
||||
local itemTable = ix.item.instances[v]
|
||||
if (!itemTable) then
|
||||
lost = lost + 1
|
||||
continue
|
||||
end
|
||||
|
||||
local curInv = ix.item.inventories[self.invID or 0]
|
||||
if (!curInv) then
|
||||
ErrorNoHalt("[DEATHDROP] Failed to transfer item "..itemTable.uniqueID.." (#"..v.."), no curInv!")
|
||||
continue
|
||||
end
|
||||
|
||||
local w, h = itemTable.width, itemTable.height
|
||||
if (inventory:FindEmptySlot(w, h)) then
|
||||
PLUGIN:TransferItem(target, itemTable, curInv, inventory)
|
||||
table.RemoveByValue(leftItems, v)
|
||||
else
|
||||
temp = true
|
||||
|
||||
local container = ents.Create("ix_drop")
|
||||
container:SetPos(target:GetPos() + target:GetAngles():Forward() * 5)
|
||||
container:SetModel(ix.config.Get("dropContainerModel", "models/props_c17/BriefCase001a.mdl"))
|
||||
container:Spawn()
|
||||
|
||||
ix.inventory.New(0, "droppedItems", function(newInv)
|
||||
newInv.vars.isBag = false
|
||||
newInv.vars.isDrop = true
|
||||
|
||||
function newInv.OnAuthorizeTransfer(_, _, _, item)
|
||||
if (item.authorized) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if (!IsValid(container)) then
|
||||
return
|
||||
end
|
||||
|
||||
container:SetInventory(newInv)
|
||||
newInv.vars.entity = container
|
||||
|
||||
for _, v1 in pairs(leftItems) do
|
||||
local item = ix.item.instances[v1]
|
||||
|
||||
if (!item) then continue end
|
||||
local owner = item:GetOwner()
|
||||
local curInv1 = IsValid(owner) and owner:GetCharacter():GetInventory() or false
|
||||
|
||||
PLUGIN:TransferItem(owner, item, curInv1, newInv)
|
||||
end
|
||||
|
||||
ix.saveEnts:SaveEntity(container)
|
||||
end)
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local notify = temp and "plyRefundTemp" or "plyRefund"
|
||||
client:NotifyLocalized(notify)
|
||||
|
||||
if (lost > 0) then
|
||||
client:NotifyLocalized("plyRefundLost", lost)
|
||||
end
|
||||
|
||||
if (client != target) then
|
||||
target:NotifyLocalized(notify)
|
||||
|
||||
if (lost > 0) then
|
||||
target:NotifyLocalized("plyRefundLost", lost)
|
||||
end
|
||||
end
|
||||
|
||||
target:GetCharacter():SetRefundItems(nil)
|
||||
end
|
||||
})
|
||||
|
||||
function PLUGIN:InitializedConfig()
|
||||
ix.inventory.Register("droppedItems", 9, 9)
|
||||
end
|
||||
|
||||
function PLUGIN:CanTransferItem(itemTable, curInv, inventory)
|
||||
if (!itemTable.authorized) then
|
||||
if (curInv:GetID() == 0) then return end
|
||||
|
||||
if (curInv.vars and curInv.vars.isDrop and inventory:GetID() == curInv:GetID()) then
|
||||
return false
|
||||
end
|
||||
|
||||
if (inventory.vars and inventory.vars.isDrop) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:OnItemTransferred(itemTable, curInv, inventory)
|
||||
if (curInv.vars and curInv.vars.isDrop and table.IsEmpty(curInv:GetItems())) then
|
||||
local container = curInv.vars.entity
|
||||
|
||||
if (IsValid(container)) then
|
||||
container:Remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (CLIENT) then
|
||||
local color = Color(255, 0, 128)
|
||||
function PLUGIN:InitializedPlugins()
|
||||
local function drawDropESP(client, entity, x, y, factor)
|
||||
ix.util.DrawText("Death Drop", x, y - math.max(10, 32 * factor), color,
|
||||
TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, math.max(255 * factor, 80))
|
||||
end
|
||||
|
||||
ix.observer:RegisterESPType("ix_drop", drawDropESP, "drop")
|
||||
end
|
||||
end
|
||||
220
gamemodes/helix/plugins/deathdrop/sv_plugin.lua
Normal file
220
gamemodes/helix/plugins/deathdrop/sv_plugin.lua
Normal file
@@ -0,0 +1,220 @@
|
||||
--[[
|
||||
| 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 ix = ix
|
||||
local IsValid = IsValid
|
||||
local pairs = pairs
|
||||
local isfunction = isfunction
|
||||
local table = table
|
||||
local ents = ents
|
||||
local hook = hook
|
||||
local ipairs = ipairs
|
||||
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
ix.log.AddType("droppedItems", function(client, text)
|
||||
return text
|
||||
end)
|
||||
|
||||
function PLUGIN:TransferItem(client, itemTable, curInv, inventory)
|
||||
itemTable.player = client
|
||||
if (itemTable:GetData("equip") == true and itemTable.functions.EquipUn) then
|
||||
itemTable.functions.EquipUn.OnRun(itemTable)
|
||||
end
|
||||
|
||||
if (itemTable.OnTransferred) then
|
||||
itemTable:OnTransferred(curInv, inventory)
|
||||
end
|
||||
|
||||
if (itemTable.OnDrop) then
|
||||
itemTable:OnDrop()
|
||||
end
|
||||
|
||||
local x, y = itemTable.gridX, itemTable.gridY
|
||||
local w, h = itemTable.width, itemTable.height
|
||||
|
||||
if (!x or !y or !inventory:CanItemFit(x, y, w, h)) then
|
||||
x, y = inventory:FindEmptySlot(w, h)
|
||||
end
|
||||
|
||||
itemTable.authorized = true
|
||||
itemTable:Transfer(inventory:GetID(), x, y)
|
||||
|
||||
local entity = itemTable:GetEntity()
|
||||
|
||||
if (IsValid(entity)) then
|
||||
itemTable:GetEntity():Remove()
|
||||
end
|
||||
|
||||
itemTable.player = nil
|
||||
itemTable.authorized = nil
|
||||
end
|
||||
|
||||
function PLUGIN:ShouldCharacterDropItems(client)
|
||||
if (!ix.config.Get("dropItems")) then
|
||||
return false
|
||||
end
|
||||
|
||||
local character = client:GetCharacter()
|
||||
|
||||
if (character) then
|
||||
local faction = character:GetFaction()
|
||||
|
||||
if (faction) then
|
||||
local factionTable = ix.faction.Get(faction)
|
||||
|
||||
if (factionTable.saveItemsAfterDeath) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerDeath(client, inflictor, attacker)
|
||||
if (hook.Run("ShouldCharacterDropItems", client) != false) then
|
||||
local clientInv = client:GetCharacter():GetInventory()
|
||||
local droppedItems = {}
|
||||
local items = {}
|
||||
|
||||
for _, v in pairs(clientInv:GetItems()) do
|
||||
if (v.isBag) then continue end
|
||||
|
||||
if (v.OnDeathDrop) then
|
||||
v:OnDeathDrop(client, items, droppedItems)
|
||||
elseif ((isfunction(v.KeepOnDeath) and v:KeepOnDeath(client) or v.KeepOnDeath) != true) then
|
||||
table.insert(items, v)
|
||||
table.insert(droppedItems, v:GetID())
|
||||
if (v.OnDoDeathDrop) then
|
||||
v:OnDoDeathDrop(client, items, droppedItems)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if (!table.IsEmpty(items)) then
|
||||
local container = ents.Create("ix_drop")
|
||||
container:SetPos(client:GetPos())
|
||||
container:SetModel(ix.config.Get("dropContainerModel", "models/props_c17/BriefCase001a.mdl"))
|
||||
container:Spawn()
|
||||
|
||||
hook.Run("PreDropCharacterInventory", client, items, container)
|
||||
|
||||
ix.inventory.New(0, "droppedItems", function(inventory)
|
||||
inventory.vars.isBag = false
|
||||
inventory.vars.isDrop = true
|
||||
|
||||
function inventory.OnAuthorizeTransfer(_, _, _, itemTable)
|
||||
if (itemTable.authorized) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if (IsValid(container)) then
|
||||
container:SetInventory(inventory)
|
||||
inventory.vars.entity = container
|
||||
|
||||
for _, v in pairs(items) do
|
||||
self:TransferItem(client, v, clientInv, inventory)
|
||||
end
|
||||
|
||||
ix.saveEnts:SaveEntity(container)
|
||||
hook.Run("PostDropCharacterInventory", client, items, container, inventory)
|
||||
else
|
||||
ix.item.inventories[inventory.id] = nil
|
||||
|
||||
local query = mysql:Delete("ix_items")
|
||||
query:Where("inventory_id", inventory.id)
|
||||
query:Execute()
|
||||
|
||||
query = mysql:Delete("ix_inventories")
|
||||
query:Where("inventory_id", inventory.id)
|
||||
query:Execute()
|
||||
end
|
||||
end)
|
||||
|
||||
client:GetCharacter():SetRefundItems(droppedItems)
|
||||
|
||||
local logString = client:Name().." has dropped:"
|
||||
for _, v in ipairs(items) do
|
||||
if (!v.maxStackSize or v.maxStackSize == 1) then
|
||||
logString = logString.." "..v:GetName().." (#"..v:GetID()..");"
|
||||
else
|
||||
logString = logString.." "..v:GetStackSize().."x "..v:GetName().." (#"..v:GetID()..");"
|
||||
end
|
||||
end
|
||||
ix.log.Add(client, "droppedItems", logString)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PostDropCharacterInventory(client, items, container, inventory)
|
||||
for k, v in pairs(inventory:GetItems()) do
|
||||
if (v.replaceOnDeath) then
|
||||
local newItem = v.replaceOnDeath
|
||||
v:Remove()
|
||||
|
||||
if (ix.item.list[v.replaceOnDeath]) then
|
||||
inventory:Add(newItem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:RegisterSaveEnts()
|
||||
ix.saveEnts:RegisterEntity("ix_drop", true, true, true, {
|
||||
OnSave = function(entity, data) --OnSave
|
||||
local inventory = entity:GetInventory()
|
||||
data.invID = inventory:GetID()
|
||||
data.model = entity:GetModel()
|
||||
data.name = entity.name
|
||||
data.password = entity.password
|
||||
data.money = entity:GetMoney()
|
||||
end,
|
||||
OnRestore = function(entity, data) --OnRestore
|
||||
entity:SetModel(data.model)
|
||||
entity:SetSolid(SOLID_VPHYSICS)
|
||||
entity:PhysicsInit(SOLID_VPHYSICS)
|
||||
|
||||
if (data.password) then
|
||||
entity.password = data.password
|
||||
entity:SetLocked(true)
|
||||
entity.Sessions = {}
|
||||
end
|
||||
|
||||
if (data.name) then
|
||||
entity.name = data.name
|
||||
entity:SetDisplayName(data.name)
|
||||
end
|
||||
|
||||
if (data.money) then
|
||||
entity:SetMoney(data.money)
|
||||
end
|
||||
|
||||
ix.inventory.Restore(data.invID, ix.config.Get("inventoryWidth"), ix.config.Get("inventoryHeight"), function(inventory)
|
||||
inventory.vars.isBag = false
|
||||
inventory.vars.isDrop = true
|
||||
|
||||
if (IsValid(entity)) then
|
||||
entity:SetInventory(inventory)
|
||||
inventory.vars.entity = entity
|
||||
end
|
||||
end)
|
||||
end,
|
||||
ShouldSave = function(entity) --ShouldSave
|
||||
return entity:GetInventory() and entity:GetInventory() != 0
|
||||
end,
|
||||
ShouldRestore = function(data) --ShouldRestore
|
||||
return data.invID >= 1
|
||||
end
|
||||
})
|
||||
end
|
||||
Reference in New Issue
Block a user