mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
46
gamemodes/darkrp/plugins/extendedchardesc/cl_hooks.lua
Normal file
46
gamemodes/darkrp/plugins/extendedchardesc/cl_hooks.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
--[[
|
||||
| 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 string = string
|
||||
local derma = derma
|
||||
local netstream = netstream
|
||||
local hook = hook
|
||||
local vgui = vgui
|
||||
local surface = surface
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
function PLUGIN:PopulateCharacterInfo(client, character, container)
|
||||
local maxLen = ix.config.Get("descriptionDisplayLength", 256)
|
||||
local descriptionText = character:GetDescription()
|
||||
|
||||
if (string.utf8len(descriptionText) >= maxLen) then
|
||||
local fullDescription = container:AddRowAfter("description", "fullDescription")
|
||||
fullDescription:SetBackgroundColor(derma.GetColor("Info", container))
|
||||
fullDescription:SetText("Appuyez sur E pour voir la description complète.")
|
||||
fullDescription:SizeToContents()
|
||||
fullDescription:SetZPos(100)
|
||||
end
|
||||
end
|
||||
|
||||
netstream.Hook("ixExtendedDescription", function(client, edit)
|
||||
local character = client:GetCharacter()
|
||||
if (character) then
|
||||
local characterName = hook.Run("GetCharacterName", client, "ic") or character:GetName()
|
||||
local panel = vgui.Create("ixExtendedDescription")
|
||||
panel:SetDescription(character:GetDescription())
|
||||
panel:SetEditable(edit)
|
||||
panel:SetTitle("Description de "..characterName)
|
||||
panel.characterId = character:GetID()
|
||||
|
||||
surface.PlaySound("helix/ui/press.wav")
|
||||
end
|
||||
end)
|
||||
87
gamemodes/darkrp/plugins/extendedchardesc/derma/cl_desc.lua
Normal file
87
gamemodes/darkrp/plugins/extendedchardesc/derma/cl_desc.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
--[[
|
||||
| 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()
|
||||
local scrW, scrH = ScrW(), ScrH()
|
||||
|
||||
self:SetSize(scrW * 0.3, scrH * 0.4)
|
||||
self.text = vgui.Create("DTextEntry", self)
|
||||
self.text:Dock(FILL)
|
||||
self.text:DockMargin(0, 0, 0, SScaleMin(4 / 3))
|
||||
self.text:SetMultiline(true)
|
||||
self.text:SetEditable(false)
|
||||
self.text:SetTextColor(Color(200, 200, 200, 255))
|
||||
self.text:SetCursorColor(Color(200, 200, 200, 255))
|
||||
self.text:SetFont("MenuFontNoClamp")
|
||||
self.text:SetText("")
|
||||
self.text.Paint = function(panel, w, h)
|
||||
surface.SetDrawColor(Color(0, 0, 0, 100))
|
||||
surface.DrawRect(0, 0, w, h)
|
||||
|
||||
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
|
||||
surface.DrawOutlinedRect(0, 0, w, h)
|
||||
|
||||
panel:DrawTextEntryText( panel:GetTextColor(), panel:GetHighlightColor(), panel:GetCursorColor() )
|
||||
end
|
||||
|
||||
self.text.OnChange = function()
|
||||
self.save:SetDisabled(false)
|
||||
end
|
||||
|
||||
local maxLen = ix.config.Get("maxDescriptionLength", 512)
|
||||
|
||||
self.text.AllowInput = function()
|
||||
local text = self.text:GetValue()
|
||||
if (string.utf8len(text) > maxLen) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
self.save = vgui.Create("DButton", self)
|
||||
self.save:SetText("Sauvegarder")
|
||||
self.save:SetFont("MenuFontNoClamp")
|
||||
self.save:SetTextColor(color_white)
|
||||
self.save:SetTall(SScaleMin(30 / 3))
|
||||
self.save:Dock(BOTTOM)
|
||||
self.save:SetDisabled(true)
|
||||
self.save.DoClick = function(btn)
|
||||
local curTime = CurTime()
|
||||
|
||||
if (!btn.nextClick or btn.nextClick <= curTime) then
|
||||
surface.PlaySound("helix/ui/press.wav")
|
||||
self.save:SetDisabled(true)
|
||||
|
||||
netstream.Start("ixChangeDescription", self.characterId, self.text:GetValue())
|
||||
|
||||
btn.nextClick = curTime + 0.5
|
||||
end
|
||||
end
|
||||
|
||||
self:Center()
|
||||
DFrameFixer(self)
|
||||
end
|
||||
|
||||
function PANEL:SetDescription(desc)
|
||||
self.text:SetText(desc)
|
||||
self:FixLabelTitle()
|
||||
end
|
||||
|
||||
function PANEL:FixLabelTitle()
|
||||
self.lblTitle:SetFont("MenuFontNoClamp")
|
||||
self.lblTitle:SizeToContents()
|
||||
end
|
||||
|
||||
function PANEL:SetEditable(edit)
|
||||
self.text:SetEditable(edit)
|
||||
end
|
||||
|
||||
vgui.Register("ixExtendedDescription", PANEL, "DFrame")
|
||||
24
gamemodes/darkrp/plugins/extendedchardesc/sh_commands.lua
Normal file
24
gamemodes/darkrp/plugins/extendedchardesc/sh_commands.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
--[[
|
||||
| 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 bit = bit
|
||||
local netstream = netstream
|
||||
local hook = hook
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
ix.command.Add("EditDesc", {
|
||||
description = "Modifier la description du personnage.",
|
||||
arguments = bit.bor(ix.type.player, ix.type.optional),
|
||||
OnRun = function(self, client, target)
|
||||
netstream.Start(client, "ixExtendedDescription", target or client, hook.Run("CanPlayerEditDescription", client, target))
|
||||
end
|
||||
})
|
||||
57
gamemodes/darkrp/plugins/extendedchardesc/sh_plugin.lua
Normal file
57
gamemodes/darkrp/plugins/extendedchardesc/sh_plugin.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
--[[
|
||||
| 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 string = string
|
||||
local tostring = tostring
|
||||
|
||||
|
||||
PLUGIN.name = "Extended Character Description"
|
||||
PLUGIN.author = "AleXXX_007"
|
||||
PLUGIN.description = "Adds new panel for longer character descriptions."
|
||||
|
||||
ix.util.Include("cl_hooks.lua")
|
||||
ix.util.Include("sh_commands.lua")
|
||||
ix.util.Include("sv_hooks.lua")
|
||||
|
||||
ix.config.Add("maxDescriptionLength", 512, "Nombre maximal de caractères dans la description.", nil, {
|
||||
data = {min = 64, max = 2048},
|
||||
category = "characters"
|
||||
})
|
||||
|
||||
ix.lang.AddTable("english", {
|
||||
descMaxLen = "Your description must not be more than %d characters!"
|
||||
})
|
||||
|
||||
ix.lang.AddTable("french", {
|
||||
descMaxLen = "Votre description ne doit pas comporter plus de %d caractères !"
|
||||
})
|
||||
|
||||
ix.lang.AddTable("spanish", {
|
||||
descMaxLen = "¡Tu descripción no puede tener más de %d carácteres!"
|
||||
})
|
||||
|
||||
do
|
||||
ix.char.vars.description.OnValidate = function(self, value, payload)
|
||||
value = string.Trim((tostring(value):gsub("\r\n", ""):gsub("\n", "")))
|
||||
local minLength = ix.config.Get("minDescriptionLength", 16)
|
||||
local maxLength = ix.config.Get("maxDescriptionLength", 512)
|
||||
|
||||
if (value:utf8len() < minLength) then
|
||||
return false, "descMinLen", minLength
|
||||
elseif (value:utf8len() > maxLength) then
|
||||
return false, "descMaxLen", maxLength
|
||||
elseif (!value:find("%S")) then
|
||||
return false, "invalid", "description"
|
||||
end
|
||||
|
||||
return value
|
||||
end
|
||||
end
|
||||
80
gamemodes/darkrp/plugins/extendedchardesc/sv_hooks.lua
Normal file
80
gamemodes/darkrp/plugins/extendedchardesc/sv_hooks.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
--[[
|
||||
| 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 CAMI = CAMI
|
||||
local IsValid = IsValid
|
||||
local CurTime = CurTime
|
||||
local netstream = netstream
|
||||
local hook = hook
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
function PLUGIN:CanPlayerEditDescription(client, target)
|
||||
local character = target:GetCharacter()
|
||||
|
||||
if (!character) then
|
||||
return false
|
||||
end
|
||||
|
||||
if (character:GetID() == client:GetCharacter():GetID()) then
|
||||
return true
|
||||
end
|
||||
|
||||
if (CAMI.PlayerHasAccess(client, "Basic Admin Commands")) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerUse(client, target)
|
||||
if (IsValid(target) and target:IsPlayer() and !target:IsRestricted()) then
|
||||
local character = target:GetCharacter()
|
||||
|
||||
if (character) then
|
||||
local curTime = CurTime()
|
||||
|
||||
if (!client.nextUse or client.nextUse <= curTime) then
|
||||
netstream.Start(client, "ixExtendedDescription", target, hook.Run("CanPlayerEditDescription", client, target))
|
||||
|
||||
client.nextUse = curTime + 0.5
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:OnCharDescRequested(client)
|
||||
netstream.Start(client, "ixExtendedDescription", client, hook.Run("CanPlayerEditDescription", client, client))
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
netstream.Hook("ixChangeDescription", function(client, characterId, description)
|
||||
if (characterId == client:GetCharacter():GetID() or CAMI.PlayerHasAccess(client, "Basic Admin Commands")) then
|
||||
local character = ix.char.loaded[characterId]
|
||||
|
||||
if (character) then
|
||||
local info = ix.char.vars.description
|
||||
local result, fault, count = info:OnValidate(description)
|
||||
|
||||
if (result == false) then
|
||||
client:NotifyLocalized("@"..fault, count)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
character:SetDescription(string.Replace(description, "\n", " "))
|
||||
|
||||
if (characterId != client:GetCharacter():GetID()) then
|
||||
client:NotifyLocalized("Description changée pour : "..character:GetName())
|
||||
end
|
||||
|
||||
character:GetPlayer():NotifyLocalized("Votre description a été modifiée avec succès.")
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user