mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
@@ -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("Il n'y a pas de mot de passe sur cette serrure, ce qui évite le verrouillage.")
|
||||
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("Vous avez encore fermé à clé.")
|
||||
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
|
||||
@@ -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 = "Serrure de conteneur"
|
||||
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
|
||||
19
gamemodes/darkrp/plugins/containerlocks/items/sh_safe.lua
Normal file
19
gamemodes/darkrp/plugins/containerlocks/items/sh_safe.lua
Normal 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 = "Coffre"
|
||||
ITEM.uniqueID = "container_safe"
|
||||
ITEM.model = "models/willardnetworks/safe.mdl"
|
||||
ITEM.width = 2
|
||||
ITEM.height = 2
|
||||
ITEM.description = "Un coffre-fort incassable de taille 4x4 pour conserver vos objets. Assurez-vous de contacter un administrateur pour configurer ce conteneur lorsque vous avez fabriqué cet objet."
|
||||
ITEM.category = "Stockage"
|
||||
ITEM.colorAppendix = {["red"] = "Contactez un administrateur pour le convertir en un conteneur fonctionnel.", ["blue"] = "Nous avons une limite de 2 petits conteneurs personnels OU 1 moyen par joueur.\nLes groupes peuvent également obtenir 3 grands conteneurs."}
|
||||
145
gamemodes/darkrp/plugins/containerlocks/items/sh_t1lock.lua
Normal file
145
gamemodes/darkrp/plugins/containerlocks/items/sh_t1lock.lua
Normal file
@@ -0,0 +1,145 @@
|
||||
--[[
|
||||
| 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 = "Cadenas"
|
||||
ITEM.uniqueID = "cont_lock_t1"
|
||||
ITEM.model = "models/props_wasteland/prison_padlock001a.mdl"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
ITEM.description = "Peut définir un mot de passe sur certains conteneurs/portes lorsqu'il est utilisé."
|
||||
ITEM.category = "Outils"
|
||||
ITEM.colorAppendix = {["blue"] = "Ce cadenas fonctionne également sur les portes.", ["red"] = "Ce cadenas peut être détruit, mais uniquement si le propriétaire est en ligne."}
|
||||
|
||||
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_junk/wood_crate001a.mdl",
|
||||
"models/props_junk/wood_crate002a.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("Ceci n'est pas un conteneur / porte valide !")
|
||||
return false
|
||||
end
|
||||
|
||||
local traceClass = trace.Entity:GetClass()
|
||||
|
||||
if (traceClass != "ix_container" and traceClass != "ix_wncontainer" and !traceClass:find("door")) then
|
||||
client:NotifyLocalized("Ceci n'est pas un conteneur / porte valide !")
|
||||
return false
|
||||
end
|
||||
|
||||
if (trace.Entity.GetLocked and trace.Entity:GetLocked()) or (trace.Entity.locked and IsValid(trace.Entity.locked)) then
|
||||
client:NotifyLocalized("Ce conteneur / porte a déjà un verrou dessus !")
|
||||
return false
|
||||
end
|
||||
|
||||
local model = string.utf8lower(trace.Entity:GetModel())
|
||||
if (!table.HasValue(allowedModels, model)) then
|
||||
client:NotifyLocalized("Ce n'est pas un modèle valide !")
|
||||
return false
|
||||
end
|
||||
|
||||
if (client.ixPlacingLock and client.ixPlacingLock > CurTime()) then
|
||||
client:NotifyLocalized("Vous devez attendre avant de pouvoir placer ceci !")
|
||||
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("Vous ne pouvez pas placer de verrou sur ce conteneur !")
|
||||
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
|
||||
}
|
||||
277
gamemodes/darkrp/plugins/containerlocks/sh_plugin.lua
Normal file
277
gamemodes/darkrp/plugins/containerlocks/sh_plugin.lua
Normal 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 = "Ajoute un mécanisme de verrouillage."
|
||||
|
||||
ix.container.Register("models/willardnetworks/safe.mdl", {
|
||||
name = "Safe",
|
||||
description = "Un coffre-fort incassable pour garder vos objets.",
|
||||
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("Vous avez changé le mot de passe de cette porte a "..password)
|
||||
ix.saveEnts:SaveEntity(entity)
|
||||
else
|
||||
client:Notify("Pas de conteneur/serrure de porte sur cette porte.")
|
||||
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("No owner assigned.") return end
|
||||
|
||||
local ownerEnt = player.GetBySteamID(steamidNot64) or false
|
||||
|
||||
if (ownerEnt and IsValid(ownerEnt)) then
|
||||
client:Notify("Le propriétaire de la serrure est "..ownerEnt:SteamName().." ("..steamidNot64.."). Ce joueur est en ligne!")
|
||||
else
|
||||
client:Notify("Le SteamID du propriétaire de la serrure est : "..steamidNot64.." - Ce joueur est hors ligne !")
|
||||
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("Le propriétaire de la serrure a été modifié avec succès")
|
||||
else
|
||||
entity:SetNetVar("owner")
|
||||
|
||||
client:Notify("Propriétaire de la serrure supprimé avec succès")
|
||||
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
|
||||
292
gamemodes/darkrp/plugins/containerlocks/sv_plugin.lua
Normal file
292
gamemodes/darkrp/plugins/containerlocks/sv_plugin.lua
Normal 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("You cannot make another password attempt yet. Please wait a couple of seconds!")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if (!playerPasswordAttempts) then
|
||||
playerPasswordAttempts = {}
|
||||
end
|
||||
|
||||
if (!playerPasswordAttempts[client:SteamID()]) then
|
||||
playerPasswordAttempts[client:SteamID()] = 1
|
||||
elseif (playerPasswordAttempts[client:SteamID()] >= 10) then
|
||||
client:Notify("You have made too many wrong password attempts!")
|
||||
|
||||
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("You have unlocked the door.")
|
||||
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("Player not found in database!")
|
||||
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
|
||||
Reference in New Issue
Block a user