-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelsLimit.lua
72 lines (67 loc) · 3.11 KB
/
levelsLimit.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--[[
Written by 'Rolf' for TES3MP 0.8.0/0.8.1.
Description: Set and enforce a level cap for character's level, stats, attributes and skills (TES3MP does not provide individual limit options).
Steps:
1. Place this file inside 'server\scripts\custom' folder, located in your TES3MP directory.
2. Open 'customScripts.lua' file ('server\scripts') and write in it the next line: require('custom/levelsLimit')
3. Save the changes and close it.
4. Note: You need to modify the maximum allowed values in the TES3MP configuration ('config.lua' in 'server\scripts') to overcome those limitations with mine.
--]]
local maxStats = {Level = 200, Health = 5000, Magicka = 2000, Fatigue = 2000}
local maxAttributes = {Strength = 100, Agility = 100, Personality = 100, Speed = 100, Luck = 100, Endurance = 100, Intelligence = 100, Willpower = 100}
local maxSkills = {
Heavyarmor = 100, Mediumarmor = 100, Lightarmor = 100, Unarmored = 100, Spear = 100, Axe = 100, Bluntweapon = 100, Longblade = 100, Shortblade = 100, Marksman = 100, Handtohand = 100, Block = 100,
Illusion = 100, Conjuration = 100, Alteration = 100, Destruction = 100, Mysticism = 100, Restoration = 100, Enchant = 100, Alchemy = 100,
Armorer = 100, Mercantile = 100, Speechcraft = 100, Security = 100, Acrobatics = 100, Athletics = 100, Sneak = 100
}
function capLevels(pid)
local p = Players[pid]
if not p then return end
-- Level:
if tes3mp.GetLevel(pid) > maxStats.Level then
p.data.stats.level = maxStats.Level
p.data.stats.levelProgress = 0
p:LoadLevel()
end
-- Stats:
local stats = p.data.stats
local statsChanged = false
if stats.healthBase > maxStats.Health or stats.healthCurrent > maxStats.Health then
stats.healthBase = maxStats.Health
statsChanged = true
end
if stats.magickaBase > maxStats.Magicka or stats.magickaCurrent > maxStats.Magicka then
stats.magickaBase = maxStats.Magicka
statsChanged = true
end
if stats.fatigueBase > maxStats.Fatigue or stats.fatigueCurrent > maxStats.Fatigue then
stats.fatigueBase = maxStats.Fatigue
statsChanged = true
end
if statsChanged then p:LoadStatsDynamic() end
-- Attributes:
local attrs = p.data.attributes
local attrsChanged = false
for attr, max in pairs(maxAttributes) do
if attrs[attr].base > max then
attrs[attr].base = max
attrs[attr].levelProgress = 0
attrsChanged = true
end
end
if attrsChanged then p:LoadAttributes() end
-- Skills:
local skills = p.data.skills
local skillsChanged = false
for skill, max in pairs(maxSkills) do
if skills[skill].base > max then
skills[skill].base = max
skills[skill].progress = 0
skillsChanged = true
end
end
if skillsChanged then p:LoadSkills() end
-- Timer:
tes3mp.StartTimer(tes3mp.CreateTimerEx('capLevels', 1250, 'i', pid)) -- 1.25s until next check.
end
customEventHooks.registerHandler('OnPlayerConnect', function(_, pid) capLevels(pid) end)