From 35bc5f6bd197556b31852ba2729823047cf3db74 Mon Sep 17 00:00:00 2001 From: Tensa Date: Fri, 7 Apr 2017 15:25:03 +0900 Subject: [PATCH] Bug fix, Hooks Add. --- nutscript/gamemode/sh_config.lua | 2 +- nutscript/plugins/improvedcooking/sv_plugin.lua | 15 ++++----------- nutscript/plugins/improvedstamina/sv_hooks.lua | 11 +++++++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/nutscript/gamemode/sh_config.lua b/nutscript/gamemode/sh_config.lua index 0f65f33..96340ed 100644 --- a/nutscript/gamemode/sh_config.lua +++ b/nutscript/gamemode/sh_config.lua @@ -13,7 +13,7 @@ end nut.config = nut.config or {} // Don't Touch This, This's Version Counter. // -nut.config.frameworkVersion = "0.18.2"; +nut.config.frameworkVersion = "0.19.2"; -- What language Nutscript shall use. nut.config.language = "korean" diff --git a/nutscript/plugins/improvedcooking/sv_plugin.lua b/nutscript/plugins/improvedcooking/sv_plugin.lua index ec0b107..e856e2f 100644 --- a/nutscript/plugins/improvedcooking/sv_plugin.lua +++ b/nutscript/plugins/improvedcooking/sv_plugin.lua @@ -41,18 +41,14 @@ local math_Clamp = math.Clamp function PLUGIN:Think() local curTime = CurTime() - if HUNGER_RATE < curTime then for _, player in pairs( player.GetAll() ) do - local character = player.characterlocal hunger_curtime = 0; -local thirst_curtime = 0; + local character = player.character; + local thirst_curtime = 0; if character then local hunger = character:GetVar("hunger", 0) - if(math.random(1, 50) <= 1) then - continue - end - + character:SetVar("hunger", math_Clamp( hunger - math.random(1, 3), 0, HUNGER_MAX )) ------------------------------------------------------------------------------- @@ -76,10 +72,7 @@ local thirst_curtime = 0; if character then local thirst = character:GetVar("thirst", 0) - if(math.random(1, 50) <= 1) then - continue - end - + character:SetVar("thirst", math.Clamp( thirst - math.random(1, 3), 0, THIRST_MAX )) ------------------------------------------------------------------------------- diff --git a/nutscript/plugins/improvedstamina/sv_hooks.lua b/nutscript/plugins/improvedstamina/sv_hooks.lua index e1f233d..d3ddc77 100644 --- a/nutscript/plugins/improvedstamina/sv_hooks.lua +++ b/nutscript/plugins/improvedstamina/sv_hooks.lua @@ -35,9 +35,9 @@ function PLUGIN:PlayerLoadedChar(client) end; end; end; - - client:SetRunSpeed(math.Max(nut.config.walkSpeed / 2, (nut.config.runSpeed * 1.25) + (client:GetAttrib(ATTRIB_SPD, 1) * 0.25) - (100 / (math.Max(client.character:GetVar("stamina"), 1) * 0.5)))); - client:SetWalkSpeed(math.Max(nut.config.walkSpeed / 2, (nut.config.walkSpeed * 1.25) + (client:GetAttrib(ATTRIB_SPD, 1) * 0.05) - (100 / (math.Max(client.character:GetVar("stamina"), 1) * 0.5)))); + + client:SetRunSpeed(hook.Run("PlayerGetRunSpeed", client, math.Max(nut.config.walkSpeed / 2, (nut.config.runSpeed * 1.25) + (client:GetAttrib(ATTRIB_SPD, 1) * 0.25) - (100 / (math.Max(client.character:GetVar("stamina"), 1) * 0.5))))); + client:SetWalkSpeed(hook.Run("PlayerGetWalkSpeed", client, math.Max(nut.config.walkSpeed / 2, (nut.config.walkSpeed * 1.25) + (client:GetAttrib(ATTRIB_SPD, 1) * 0.05) - (100 / (math.Max(client.character:GetVar("stamina"), 1) * 0.5))))); end); end @@ -45,4 +45,7 @@ function PLUGIN:PlayerSpawn(client) if (client.character) then client.character:SetVar("stamina", client.character:GetData("stamina") or 100); end -end \ No newline at end of file +end + +function PLUGIN:PlayerGetRunSpeed(client, calcSpeed) return calcSpeed; end; +function PLUGIN:PlayerGetWalkSpeed(client, calcSpeed) return calcSpeed; end; \ No newline at end of file