From 699df0d5df4e7d00a0d2b838b8c851c9b5027cea Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 22 May 2016 15:53:31 -0400 Subject: Made mediceine work like it used to, and added sound --- gamemode/itemsystem/items/medicine.lua | 28 ++++++++++++++++++---------- gamemode/processes.lua | 23 ----------------------- 2 files changed, 18 insertions(+), 33 deletions(-) (limited to 'gamemode') diff --git a/gamemode/itemsystem/items/medicine.lua b/gamemode/itemsystem/items/medicine.lua index 405188d..d741b04 100644 --- a/gamemode/itemsystem/items/medicine.lua +++ b/gamemode/itemsystem/items/medicine.lua @@ -6,27 +6,35 @@ ITEM.Description = "Heals you!" ITEM.Icon = "items/medicine.png" ITEM.UniqueData = false -if(SERVER) then +if (SERVER) then util.AddNetworkString( "gms_usemedicine" ) end local client_use = function() - net.Start("gms_usemedicine") + net.Start("gms_usemedicine") net.SendToServer() end local finisheduseing = function(player) - player:DecResource( "Medicine", 1 ) - player:SendMessage( "You're feeling a bit better now.", 3, Color( 10, 200, 10, 255 ) ) - player:Heal( 10 ) + player:DecResource( "Medicine", 1 ) + player:SendMessage( "You're feeling a bit better now.", 3, Color( 10, 200, 10, 255 ) ) + player:Heal( 10 ) end local use_medicine = function(ln, player) - if ( player:GetResource( "Medicine" ) < 1 ) then - player:SendMessage( "You need Medicine.", 3, Color( 200, 0, 0, 255 ) ) - return - end - startProcessGeneric(player,"Patching yourself up",1.5,finisheduseing) + if ( player:GetResource( "Medicine" ) < 1 ) then + player:SendMessage( "You need Medicine.", 3, Color( 200, 0, 0, 255 ) ) + return + end + local maxhealth = 100 + if player:HasUnlock("Adept_Survivalist") then maxhealth = maxhealth + 50 end + if player:HasUnlock("Master_Survivalist") then maxhealth = maxhealth + 50 end + if player:Health() >= maxhealth then + player:SendMessage( "You feel fine!", 3, Color( 200, 0, 0, 255 ) ) + return + end + player:EmitSound( Sound("items/smallmedkit1.wav" ) ) + startProcessGeneric(player,"Patching yourself up",1.5,finisheduseing) end net.Receive( "gms_usemedicine", use_medicine) diff --git a/gamemode/processes.lua b/gamemode/processes.lua index 854a3d8..d475127 100644 --- a/gamemode/processes.lua +++ b/gamemode/processes.lua @@ -827,29 +827,6 @@ end GMS.RegisterProcess( "BottleWater", PROCESS ) -/*--------------------------------------------------------- - Take Medicine ----------------------------------------------------------*/ -local PROCESS = {} - -function PROCESS:OnStart() - if ( self.Owner:Health() >= 200 or ( self.Owner:Health() >= 150 and self.Owner:HasUnlock( "Master_Survivalist" ) != true ) or ( self.Owner:Health() >= 100 and self.Owner:HasUnlock( "Adept_Survivalist" ) != true ) ) then - self.Owner:SendMessage( "You're feeling good, why would you heal yourself.", 3, Color( 200, 0, 0, 255 ) ) - else - self.Owner:MakeProcessBar( "Taking Medicine", self.Time, self.Cancel ) - self.Owner:EmitSound( Sound( "items/smallmedkit1.wav" ) ) - end -end - -function PROCESS:OnStop() - if ( self.Owner:Health() >= 200 or ( self.Owner:Health() >= 150 and self.Owner:HasUnlock( "Master_Survivalist" ) != true ) or ( self.Owner:Health() >= 100 and self.Owner:HasUnlock( "Adept_Survivalist" ) != true ) ) then return end - self.Owner:DecResource( "Medicine", 1 ) - self.Owner:SendMessage( "You're feeling a bit better now.", 3, Color( 10, 200, 10, 255 ) ) - self.Owner:Heal( 10 ) -end - -GMS.RegisterProcess( "TakeMedicine", PROCESS ) - /*--------------------------------------------------------- Cooking ---------------------------------------------------------*/ -- cgit v1.2.3-70-g09d2