This commit is contained in:
lifestorm
2024-08-05 18:40:29 +03:00
parent 9f505a0646
commit c6d9b6f580
8044 changed files with 1853472 additions and 21 deletions

View File

@@ -0,0 +1,94 @@
--[[
| 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
PLUGIN.name = "Character Playermodel Resize"
PLUGIN.author = "M!NT"
PLUGIN.description = "Resizes a character's playermodel based on their actual IC height."
ix.config.Add("ModelScalingEnable", true, "Allows the server to scale playermodels depending on their height selected during character creation.",
function(oldVal, newVal)
if (!SERVER) then return end
for _, v in ipairs(player.GetAll()) do
if (v:GetCharacter()) then
PLUGIN:resizeCharacter(v:GetCharacter())
end
end
end, {
category = "Resize"
})
ix.config.Add("ModelScalingMinInches", 58, "Minimum bounds for character height (in inches).",
function(oldVal, newVal)
if (!SERVER) then return end
for _, v in ipairs(player.GetAll()) do
if (v:GetCharacter()) then
PLUGIN:resizeCharacter(v:GetCharacter())
end
end
end, {
data = {min = 50, max = 70},
category = "Resize"
})
ix.config.Add("ModelScalingMin", 0.85, "Minimum bounds for character height (in real scale).",
function(oldVal, newVal)
if (!SERVER) then return end
for _, v in ipairs(player.GetAll()) do
if (v:GetCharacter()) then
PLUGIN:resizeCharacter(v:GetCharacter())
end
end
end, {
data = {min = 0.5, max = 1.6, decimals = 2},
category = "Resize"
})
ix.config.Add("ModelScalingMax", 1.3, "Maximum bounds for character height (in real scale).",
function(oldVal, newVal)
if (!SERVER) then return end
for _, v in ipairs(player.GetAll()) do
if (v:GetCharacter()) then
PLUGIN:resizeCharacter(v:GetCharacter())
end
end
end, {
data = {min = 0.5, max = 2.1, decimals = 2},
category = "Resize"
})
ix.config.Add("ModelScalingMaxInches", 78, "Maximum bounds for character height (in inches).",
function(oldVal, newVal)
if (!SERVER) then return end
for _, v in ipairs(player.GetAll()) do
if (v:GetCharacter()) then
PLUGIN:resizeCharacter(v:GetCharacter())
end
end
end, {
data = {min = 65, max = 85},
category = "Resize"
})
ix.config.Add("ModelScalingSexOffset", 0.1, "Offset extra height given to females (bc their base models are smaller)",
function(oldVal, newVal)
if (!SERVER) then return end
for _, v in ipairs(player.GetAll()) do
if (v:GetCharacter()) then
PLUGIN:resizeCharacter(v:GetCharacter())
end
end
end, {
data = {min = 0.01, max = 2, decimals = 2},
category = "Resize"
})
ix.util.Include("sv_hooks.lua")

View 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 PLUGIN = PLUGIN
function PLUGIN:resizeCharacter(character)
local client = character:GetPlayer()
local height = character:GetHeight()
if (!height or height == "" or height == "N/A" or !IsValid(client) or !ix.config.Get("ModelScalingEnable")) then
client:SetModelScale(1, 0.01)
return
end
local heightFt, heightIn = string.match(height, "^(%d+)'(%d+)\"$")
heightFt = tonumber(heightFt)
heightIn = tonumber(heightIn)
if (!isnumber(heightFt) or !isnumber(heightIn)) then
client:SetModelScale(1, 0.01)
return
end
local heightMinIn = ix.config.Get("ModelScalingMinInches", 58) -- minimum inches a character can be
local heightMaxIn = ix.config.Get("ModelScalingMaxInches", 78) -- maximum inches a character can be
local heightMin = ix.config.Get("ModelScalingMin", 0.85) -- minimum scale allowed
local heightMax = ix.config.Get("ModelScalingMax", 1.25) -- maximum scale allowed
local inchesFromBase = ((heightFt * 12) + heightIn) - heightMinIn
local charScaleFromMin = (heightMax - heightMin) / (heightMaxIn - heightMinIn) * inchesFromBase
local sexOffset = 0
if (client:IsFemale()) then -- for some reason this is not character:IsFemale()?? thanks alex
sexOffset = ix.config.Get("ModelScalingSexOffset", 0.1)
end
-- final scale. between heightMin and heightMax
local finalScale = math.Clamp(
heightMin + charScaleFromMin + sexOffset,
heightMin,
heightMax
)
-- scale their entire model
-- for some reason we need to wait awhile (probably because another hook somewhere is resetting this)
timer.Simple(5, function()
client:SetModelScale(finalScale, 0.01)
end)
end
function PLUGIN:CharacterLoaded(character)
PLUGIN:resizeCharacter(character)
end