This commit is contained in:
lifestorm
2024-08-04 23:54:45 +03:00
parent 8064ba84d8
commit 6a58f406b1
7522 changed files with 4011896 additions and 15 deletions

View File

@@ -0,0 +1,146 @@
--[[
| 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 AddCSLuaFile = AddCSLuaFile
local include = include
AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent.
include('shared.lua')
function ENT:Initialize()
self:SetModel("models/willardnetworks/misc/prison_padlock001a.mdl")
self:SetSolid(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:PhysicsInit( SOLID_VPHYSICS )
self:DrawShadow(false)
local physics = self:GetPhysicsObject()
physics:EnableMotion(false)
physics:Sleep()
self:PrecacheGibs()
end
function ENT:Use(client)
local curTime = CurTime()
if (self.nextUse and self.nextUse > curTime) then return end
local door = self.door
if !IsValid(door) then return end
if !door.GetSaveTable then return end
if !door:GetSaveTable() then return end
self.nextUse = curTime + 1
if (door:GetSaveTable()["m_bLocked"]) then
if (door.Sessions and door.Sessions[client:SteamID()]) then
door:Fire("Unlock")
door.Sessions[client:SteamID()] = true
local doorPartner = door:GetDoorPartner()
if (IsValid(doorPartner)) then
doorPartner:Fire("Unlock")
doorPartner.Sessions = doorPartner.Sessions or {}
doorPartner.Sessions[client:SteamID()] = true
end
door:EmitSound("doors/latchunlocked1.wav")
return
end
net.Start("ixDoorPassword")
net.WriteEntity(self.door)
net.Send(client)
return
end
if !self.password then
client:Notify("Bu kilitte şifre yok, kilitlenmeyecek.")
return
end
door:Fire("Lock")
door:Fire("Close")
local doorPartner = door:GetDoorPartner()
if (IsValid(doorPartner)) then
doorPartner:Fire("Lock")
doorPartner:Fire("Close")
end
door:EmitSound("doors/latchlocked2.wav")
client:Notify("Kapıyı tekrar kilitledin.")
end
function ENT:OnTakeDamage( dmginfo )
local groupPlugin = ix.plugin.list["groupmanager"]
local groupStored = groupPlugin.stored
if groupStored[self:GetParent().group] then
local group = groupStored[self:GetParent().group]
if #group:GetOnlineMembers() <= 0 then
return false
end
end
-- If owner is offline don't apply the damage
if (self:GetNetVar("owner") and !IsValid(player.GetBySteamID(self:GetNetVar("owner")))) then
return false
end
local inflictor = dmginfo:GetInflictor()
-- Damage the player when hitting the metal lock with the bare hands
if (IsValid(inflictor) and inflictor:GetClass() == "ix_hands") then
dmginfo:GetAttacker():TakeDamage(dmginfo:GetDamage())
return false
end
-- Make sure we're not already applying damage a second time
-- This prevents infinite loops
if ( !self.m_bApplyingDamage ) then
self.m_bApplyingDamage = true
self:TakeDamageInfo( dmginfo )
if (self.LockHealth <= 0) then return end -- If the lock health is already zero or below it - do nothing - prevent errors
self.LockHealth = self.LockHealth - dmginfo:GetDamage() -- Reduce the amount of damage took from lock health
if (self.LockHealth <= 0) then -- If lock health variable is zero or below it
self:EmitSound("physics/metal/metal_box_break1.wav")
self:GibBreakClient(self:GetForward() * 200)
if self.door then self.door.locked = nil end
self:Remove()
end
self.m_bApplyingDamage = false
end
end
function ENT:SetParentUnlocked()
if (IsValid(self:GetParent()) and !self:GetParent():GetClass():find("door")) then
self:GetParent():SetLocked(false)
self:GetParent().password = nil
end
end
function ENT:OnRemove()
self:SetParentUnlocked()
end

View File

@@ -0,0 +1,23 @@
--[[
| 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/
--]]
ENT.Type = "anim"
ENT.PrintName = "Container Lock"
ENT.Category = "HL2 RP"
ENT.Spawnable = true
ENT.AdminOnly = true
ENT.PhysgunDisable = true
ENT.bNoPersist = true
ENT.LockHealth = 350
function ENT:SetupDataTables()
self:NetworkVar("String", 0, "Password")
end

View File

@@ -0,0 +1,19 @@
--[[
| 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 = "Kasa"
ITEM.uniqueID = "container_safe"
ITEM.model = "models/willardnetworks/safe.mdl"
ITEM.width = 2
ITEM.height = 2
ITEM.description = "Öğelerinizi tutmak için kırılmaz 4x4 büyüklüğünde bir kasa. Bu konteyneri ayarlamak için bir yöneticiyle iletişime geçin."
ITEM.category = "Storage"
ITEM.colorAppendix = {["red"] = "Bunu bir konteynere dönüştürmek için bir yöneticiyle iletişime geçin.", ["blue"] = "Oyuncu başına 2 küçük veya 1 orta kişisel konteyner sınırımız var.\nGruplar ayrıca 3 büyük konteyner alabilir."}

View File

@@ -0,0 +1,143 @@
--[[
| 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
ITEM.name = "Asma Kilit"
ITEM.uniqueID = "cont_lock_t1"
ITEM.model = "models/props_wasteland/prison_padlock001a.mdl"
ITEM.width = 1
ITEM.height = 1
ITEM.description = "Can set a password on a certain containers/doors when used."
ITEM.category = "Tools"
ITEM.colorAppendix = {["blue"] = "Bu kilit kapılarda da çalışır.", ["red"] = "Bu kilit, ancak sahibi çevrimiçi ise kırılabilir."}
local allowedModels = {
"models/props_junk/trashdumpster01a.mdl",
"models/props_wasteland/controlroom_filecabinet001a.mdl",
"models/props_lab/filecabinet02.mdl",
"models/props_wasteland/controlroom_filecabinet002a.mdl",
"models/props_wasteland/controlroom_storagecloset001a.mdl",
"models/props_wasteland/controlroom_storagecloset001b.mdl",
"models/props_c17/door01_left.mdl",
"models/props_c17/door01_addg.mdl",
"models/props_c17/door01_addf.mdl",
"models/props_c17/door03_left.mdl",
"models/props_c17/door_fence01.mdl"
}
ITEM.functions.Lock = {
sound = "physics/metal/metal_grate_impact_soft1.wav",
OnRun = function(itemTable)
local client = itemTable.player
local trace = client:GetEyeTraceNoCursor()
if (!IsValid(trace.Entity) or !IsValid(trace.Entity:GetPhysicsObject())) then
client:NotifyLocalized("Bu geçerli bir konteyner/kapı değil!")
return false
end
local traceClass = trace.Entity:GetClass()
if (traceClass != "ix_container" and traceClass != "ix_wncontainer" and !traceClass:find("door")) then
client:NotifyLocalized("Bu geçerli bir konteyner/kapı değil!")
return false
end
if (trace.Entity.GetLocked and trace.Entity:GetLocked()) or (trace.Entity.locked and IsValid(trace.Entity.locked)) then
client:NotifyLocalized("Bu konteyerde/kapıda zaten bir kilit var!")
return false
end
local model = string.utf8lower(trace.Entity:GetModel())
if (!table.HasValue(allowedModels, model)) then
client:NotifyLocalized("Bu geçerli bir model değil!")
return false
end
if (client.ixPlacingLock and client.ixPlacingLock > CurTime()) then
client:NotifyLocalized("Bunu yerleştirmeden önce beklemeniz gerekiyor!")
return false
end
if (traceClass == "ix_wncontainer") then
local entity = trace.Entity
if (entity:GetType() != entity.PUBLIC and entity:GetType() != entity.GROUP and
(entity:GetType() != entity.PRIVATE or entity.ownerCharID != client:GetCharacter():GetID())) then
client:NotifyLocalized("Bu konteynerin üzerine bir kilit yerleştiremezsiniz!")
return false
else
if (entity:GetType() == entity.PUBLIC) then
entity:ChangeType(entity.PRIVATE, client)
end
PLUGIN:SetContainerPassword(client, entity, true)
return
end
end
client.ixPlacingLock = CurTime() + 3
local position = Vector(0, 0, 0)
local angles = Angle(0, 0, 0)
local forward = trace.Entity:GetForward()
local up = trace.Entity:GetUp()
local right = trace.Entity:GetRight()
if model == "models/props_junk/trashdumpster01a.mdl" then
position = Vector(22, 22, 17)
angles = Angle(-15, 0, 0)
elseif model == "models/props_wasteland/controlroom_filecabinet001a.mdl" then
position = Vector(13, 13, 2)
elseif model == "models/props_lab/filecabinet02.mdl" then
position = Vector(17, 17, 2)
elseif model == "models/props_wasteland/controlroom_filecabinet002a.mdl" then
position = Vector(15, 15, 2)
elseif model == "models/props_wasteland/controlroom_storagecloset001a.mdl" then
position = Vector(16, 16, 2)
elseif model == "models/props_wasteland/controlroom_storagecloset001b.mdl" then
position = Vector(18, 18, 2)
end
local lockentity = ents.Create("ix_containerlock")
if !model:find("door") then
lockentity:SetPos(trace.Entity:GetPos() + (position * forward) + (Vector(0, 0, position.z) * up))
else
local doorX, doorY, doorZ
local doorForward
local doorUp
if model == "models/props_c17/door_fence01.mdl" then
doorX, doorY, doorZ = 47 * right, 0 * right, 0
doorUp = (Vector(0, 0, -12) * up)
doorForward = Vector(2 * forward, 0, 0)
end
if model == "models/props_c17/door01_left.mdl" or model == "models/props_c17/door01_addg.mdl"
or model == "models/props_c17/door01_addf.mdl" or model == "models/props_c17/door03_left.mdl" then
doorX, doorY, doorZ = -43 * right, 0 * right, -12 * right
doorUp = (Vector(0, 0, -7) * up)
doorForward = Vector(0 * forward, 0, 0)
end
lockentity:SetPos(trace.Entity:GetPos() + (Vector(doorX, doorY, doorZ)) + doorUp + doorForward)
end
lockentity:SetAngles(trace.Entity:GetAngles() + angles)
lockentity:SetParent(trace.Entity)
lockentity:SetNetVar("owner", client:SteamID())
lockentity:Spawn()
PLUGIN:SetContainerPassword(client, trace.Entity, true, lockentity:EntIndex())
end
}

View File

@@ -0,0 +1,277 @@
--[[
| 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 netstream = netstream
local Derma_StringRequest = Derma_StringRequest
local L = L
local properties = properties
local gamemode = gamemode
local net = net
local LocalPlayer = LocalPlayer
local IsValid = IsValid
local PLUGIN = PLUGIN
PLUGIN.name = "Container Locks"
PLUGIN.author = "Fruity"
PLUGIN.description = "Adds in a locking mechanism."
ix.container.Register("models/willardnetworks/safe.mdl", {
name = "Safe",
description = "An unbreakable safe to keep your items in.",
width = 4,
height = 4,
sizeClass = "safe"
})
ix.util.Include("sv_plugin.lua")
if (CLIENT) then
netstream.Hook("LockSetContainerPassword", function(entity, bShouldHaveLock, lockEntityID)
Derma_StringRequest(L("containerPasswordWrite"), "", "", function(text)
netstream.Start("LockSetContainerPassword", entity, text, lockEntityID)
end, function()
if bShouldHaveLock then
netstream.Start("LockOnCancel", entity)
end
end)
end)
end
properties.Add("container_changepassword", {
MenuLabel = "Change Password",
Order = 402,
MenuIcon = "icon16/lock_edit.png",
Filter = function(self, entity, client)
if (!gamemode.Call("CanProperty", client, "container_changepassword", entity)) then return false end
if (entity:GetClass() != "ix_container" and !entity:IsDoor()) then return false end
return true
end,
Action = function(self, entity)
if (entity.GetLocked and entity:GetLocked()) or (entity:IsDoor() and #entity:GetChildren() > 0) then
Derma_StringRequest("This container/door is already locked, write the password to change it", "", "", function(text)
if (entity.GetPassword and text == entity:GetPassword()) or (entity:IsDoor() and text == entity:GetChildren()[1]:GetPassword()) then
Derma_StringRequest("Enter the password you want it to change to", "", "", function(newPass)
self:MsgStart()
net.WriteEntity(entity)
net.WriteString(newPass)
self:MsgEnd()
end)
else
LocalPlayer():NotifyLocalized("Wrong password.")
end
end)
else
Derma_StringRequest("Enter new password", "", "", function(text)
self:MsgStart()
net.WriteEntity(entity)
net.WriteString(text)
self:MsgEnd()
end)
end
end,
Receive = function(self, length, client)
local entity = net.ReadEntity()
if (!IsValid(entity)) then return end
if (!self:Filter(entity, client)) then return end
local password = net.ReadString()
entity.Sessions = {}
if (password:utf8len() != 0) then
if entity.SetLocked then
entity:SetLocked(true)
entity:SetPassword(password)
entity.password = password
client:NotifyLocalized("containerPassword", password)
else
if entity.locked and IsValid(entity.locked) then
entity.locked.password = password
entity.locked:SetPassword(password)
client:Notify("Bu kapının şifresini şu şekilde değiştirdiniz: "..password)
ix.saveEnts:SaveEntity(entity)
else
client:Notify("Bu kapıda konteyner / kapı kilidi yok.")
end
end
else
if entity.SetLocked then
entity:SetLocked(false)
entity:SetPassword(nil)
entity.password = nil
client:NotifyLocalized("containerPasswordRemove")
else
if entity.locked and IsValid(entity.locked) then
entity.locked.password = nil
entity.locked:SetPassword(nil)
entity:Fire("Unlock")
end
end
end
if !entity.SetLocked then return end
local name = entity:GetDisplayName()
local inventory = entity:GetInventory()
local definition = ix.container.stored[entity:GetModel():lower()]
if (definition) then
entity:SetDisplayName(definition.name)
end
ix.log.Add(client, "containerPassword", name, inventory:GetID(), password:utf8len() != 0)
end
})
properties.Add("containerlock_checkowner", {
MenuLabel = "Check Owner",
Order = 399,
MenuIcon = "icon16/user.png",
Filter = function(self, entity, client)
if (entity:GetClass() != "ix_containerlock") then return false end
if (!gamemode.Call("CanProperty", client, "containerlock_checkowner", entity)) then return false end
return true
end,
Action = function(self, entity)
self:MsgStart()
net.WriteEntity(entity)
self:MsgEnd()
end,
Receive = function(self, length, client)
local entity = net.ReadEntity()
if (!IsValid(entity)) then return end
if (!self:Filter(entity, client)) then return end
local steamidNot64 = entity:GetNetVar("owner")
if !steamidNot64 then client:Notify("Sahip atanmadı.") return end
local ownerEnt = player.GetBySteamID(steamidNot64) or false
if (ownerEnt and IsValid(ownerEnt)) then
client:Notify("Kilit sahibi "..ownerEnt:SteamName().." ("..steamidNot64.."). Bu oyuncu çevrimiçi!")
else
client:Notify("Kilit sahibinin SteamID'si: "..steamidNot64.." - Bu oyuncu çevrimdışı!")
PLUGIN:PrintDateSinceOnline(client, steamidNot64)
end
end
})
properties.Add("containerlock_setowner", {
MenuLabel = "Set Owner",
Order = 400,
MenuIcon = "icon16/lock_edit.png",
Filter = function(self, entity, client)
if (entity:GetClass() != "ix_containerlock") then return false end
if (!gamemode.Call("CanProperty", client, "containerlock_setowner", entity)) then return false end
return true
end,
Action = function(self, entity)
Derma_StringRequest("Set lock owner", "Enter new owner's SteamID", entity:GetNetVar("owner"), function(text)
self:MsgStart()
net.WriteEntity(entity)
net.WriteString(text)
self:MsgEnd()
end)
end,
Receive = function(self, length, client)
local entity = net.ReadEntity()
if (!IsValid(entity)) then return end
if (!self:Filter(entity, client)) then return end
local ownerSteamID = net.ReadString()
if (ownerSteamID:len() != 0) then
entity:SetNetVar("owner", ownerSteamID)
client:Notify("Kilit sahibi başarıyla değiştirildi")
else
entity:SetNetVar("owner")
client:Notify("Kilit sahibi başarıyla kaldırıldı")
end
local inventory = entity:GetParent():GetInventory()
ix.log.Add(client, "containerlockSetOwner", inventory:GetID(), ownerSteamID)
end
})
properties.Add("door_lockunlock", {
MenuLabel = "Lock/Unlock Door",
Order = 402,
MenuIcon = "icon16/lock_edit.png",
Filter = function(self, entity, client)
if (!gamemode.Call("CanProperty", client, "door_lockunlock", entity)) then return false end
if (!entity:IsDoor()) then return false end
return true
end,
Action = function(self, entity)
self:MsgStart()
net.WriteEntity(entity)
self:MsgEnd()
end,
Receive = function(self, length, client)
local entity = net.ReadEntity()
if (!IsValid(entity)) then return end
if (!self:Filter(entity, client)) then return end
local doorLocked = entity:GetSaveTable()["m_bLocked"]
entity:Fire(doorLocked and "Unlock" or "Lock")
local doorPartner = entity:GetDoorPartner()
if (IsValid(doorPartner)) then
doorPartner:Fire(doorLocked and "Unlock" or "Lock")
end
end
})
if (CLIENT) then
net.Receive("ixDoorPassword", function(length)
local entity = net.ReadEntity()
Derma_StringRequest(
L("containerPasswordWrite"),
L("containerPasswordWrite"),
"",
function(val)
net.Start("ixDoorPassword")
net.WriteEntity(entity)
net.WriteString(val)
net.SendToServer()
end
)
end)
end

View File

@@ -0,0 +1,292 @@
--[[
| 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 netstream = netstream
local IsValid = IsValid
local ix = ix
local PLUGIN = PLUGIN
util.AddNetworkString("ixDoorPassword")
ix.log.AddType("containerlockSetOwner", function(client, inventoryId, ownerSteamID)
return string.format("%s has changed the container's %s owner '%s'.", client:Name(), inventoryId, ownerSteamID)
end)
ix.log.AddType("doorSetLock", function(client, doorEnt)
return string.format("%s has added a lock to a door. MapcreationID: %s, vector position: '%s'", client:Name(), doorEnt:MapCreationID(), doorEnt:GetPos())
end)
function PLUGIN:SetContainerPassword(client, entity, bShouldHaveLock, lockEntityID)
entity.shouldHaveLock = true
netstream.Start(client, "LockSetContainerPassword", entity, bShouldHaveLock, lockEntityID)
end
netstream.Hook("LockSetContainerPassword", function(client, entity, password, lockEntityID)
if (!IsValid(entity)) then return end
if !entity.Sessions and !entity:IsDoor() then
entity.Sessions = {}
end
if !entity.shouldHaveLock then
return false
end
local lockEntity = lockEntityID and Entity(lockEntityID)
if (password:utf8len() != 0) then
if entity:IsDoor() then
if IsValid(lockEntity) then
lockEntity.door = entity
lockEntity.password = password
lockEntity:SetPassword(password)
if client:GetCharacter():GetGroup() then
lockEntity.group = client:GetCharacter():GetGroup():GetID()
end
entity:Fire("Lock")
entity:Fire("Close")
entity.locked = lockEntity
ix.saveEnts:SaveEntity(lockEntity)
local doorPartner = entity:GetDoorPartner()
if (IsValid(doorPartner)) then
doorPartner:Fire("Lock")
doorPartner:Fire("Close")
end
entity:EmitSound("doors/door_latch3.wav")
end
ix.log.Add(client, "doorSetLock", entity, password:utf8len() != 0)
else
if (entity:GetClass() != "ix_wncontainer") then
entity:SetLocked(true)
entity.password = password
if client:GetCharacter():GetGroup() then
entity.group = client:GetCharacter():GetGroup():GetID()
end
end
entity:SetPassword(password)
ix.saveEnts:SaveEntity(entity)
local name = entity:GetDisplayName()
local inventory = entity:GetInventory()
ix.log.Add(client, "containerPassword", name, inventory:GetID(), password:utf8len() != 0)
end
client:NotifyLocalized("containerPassword", password)
else
client:GetCharacter():GetInventory():Add("cont_lock_t1")
if IsValid(lockEntity) then
lockEntity:Remove()
end
client:NotifyLocalized("You did not set a valid password!")
end
entity.shouldHaveLock = false
end)
netstream.Hook("LockOnCancel", function(client, entity)
if !entity.shouldHaveLock then
return false
end
client:GetCharacter():GetInventory():Add("cont_lock_t1")
entity:GetChildren()[1]:Remove()
entity.shouldHaveLock = false
end)
function PLUGIN:PlayerUseDoor(client, door)
if (!IsValid(client)) then return end
local doorPartner = door:GetDoorPartner()
local shouldUseDoorPartner = false
if !door.locked or door.locked and !IsValid(door.locked) then
if !doorPartner then return end
if !doorPartner.locked or doorPartner.locked and !IsValid(doorPartner.locked) then
return
end
shouldUseDoorPartner = true
end
if door.locked and !door.locked.password then
if !doorPartner then return end
if !doorPartner.locked.password then
return
end
shouldUseDoorPartner = true
end
if !door.GetSaveTable or door.GetSaveTable and !door:GetSaveTable() then
if !doorPartner then return end
if !doorPartner.GetSaveTable or doorPartner.GetSaveTable and !doorPartner:GetSaveTable() then
return
end
shouldUseDoorPartner = true
end
if !door:GetSaveTable()["m_bLocked"] then
if !doorPartner then return end
if !doorPartner:GetSaveTable()["m_bLocked"] then
return
end
shouldUseDoorPartner = true
end
if (door.Sessions and door.Sessions[client:SteamID()]) then
door:Fire("Unlock")
door.Sessions[client:SteamID()] = true
if (IsValid(doorPartner)) then
doorPartner:Fire("Unlock")
doorPartner.Sessions = doorPartner.Sessions or {}
doorPartner.Sessions[client:SteamID()] = true
end
door:EmitSound("doors/latchunlocked1.wav")
return
end
net.Start("ixDoorPassword")
net.WriteEntity(shouldUseDoorPartner and doorPartner or door)
net.Send(client)
end
net.Receive("ixDoorPassword", function(length, client)
if ((client.ixNextContainerPassword or 0) > RealTime()) then
client:Notify("Henüz başka bir parola denemesi yapamazsınız. Lütfen birkaç saniye bekleyin!")
return
end
if (!playerPasswordAttempts) then
playerPasswordAttempts = {}
end
if (!playerPasswordAttempts[client:SteamID()]) then
playerPasswordAttempts[client:SteamID()] = 1
elseif (playerPasswordAttempts[client:SteamID()] >= 10) then
client:Notify("Çok fazla yanlış şifre denemesi yaptınız!")
return
end
local entity = net.ReadEntity()
if !entity.locked or (entity.locked and !IsValid(entity.locked)) then return end
if !entity.locked.password then return end
local password = net.ReadString()
local dist = entity:GetPos():DistToSqr(client:GetPos())
if (dist < 16384 and password) then
if (entity.locked.password and entity.locked.password == password) then
entity:Fire("Unlock")
entity.Sessions = entity.Sessions or {}
entity.Sessions[client:SteamID()] = true
local doorPartner = entity:GetDoorPartner()
if (IsValid(doorPartner)) then
doorPartner:Fire("Unlock")
doorPartner.Sessions = doorPartner.Sessions or {}
doorPartner.Sessions[client:SteamID()] = true
end
entity:EmitSound("doors/latchunlocked1.wav")
client:Notify("Kapının kilidini açtınız.")
else
client:NotifyLocalized("wrongPassword")
playerPasswordAttempts[client:SteamID()] = playerPasswordAttempts[client:SteamID()] + 1
end
end
client.ixNextContainerPassword = RealTime() + 5
end)
function PLUGIN:RegisterSaveEnts()
ix.saveEnts:RegisterEntity("ix_containerlock", true, true, true, {
OnSave = function(entity, data) --OnSave
data.door = entity.door:MapCreationID()
data.password = entity.password
data.owner = entity:GetNetVar("owner")
data.group = entity.group
end,
OnRestore = function(entity, data) --OnRestore
local door = ents.GetMapCreatedEntity(data.door)
door.locked = entity
entity.door = door
entity:SetParent(door)
entity:SetNetVar("owner", data.owner)
entity.password = data.password
entity:SetPassword(data.password)
entity.group = data.group
door:Fire("Lock", true)
door:Fire("Close")
local doorPartner = door:GetDoorPartner()
if (IsValid(doorPartner)) then
doorPartner:Fire("Lock")
doorPartner:Fire("Close")
end
end,
ShouldSave = function(entity) --ShouldSave
return IsValid(entity.door)
end,
ShouldRestore = function(data) --ShouldRestore
local door = ents.GetMapCreatedEntity(data.door)
return IsValid(door) and door:IsDoor()
end
})
end
function PLUGIN:PrintDateSinceOnline(client, steamidNot64)
if !steamidNot64 then return end
local steamid64 = util.SteamIDTo64( steamidNot64 )
if !steamid64 or steamid64 and steamid64 == "" then return end
local query = mysql:Select("ix_players")
query:Select("steamid")
query:Select("last_join_time")
query:Select("play_time")
query:Select("steam_name")
query:Where("steamid", steamid64)
query:Limit(1)
query:Callback(function(result)
if (!result or (result and !istable(result)) or (istable(result) and #result == 0)) then
client:Notify("Oyuncu veritabanında bulunamadı!")
return
end
local playTime = math.Round(result[1].play_time / 3600, 1)
client:ChatPrint(result[1].steam_name .. " (" .. steamidNot64 .. "), was online " .. os.date("%x %X", result[1].last_join_time) .. ". Total play time: " .. playTime .. " hours.")
end)
query:Execute()
end