Health NPC issue

so I have a slight issue where I have a health NPC, however if you are to purchase 25/50 health the number will still surpass the max health of 100. I have realized that due to setting the health it will obviously allow the health to be larger than max health.

Here is the init.lua file where the code is, I am asking if anyone could tell me a way to cap the health limit on the purchases of the NPC.



AddCSLuaFile( "cl_init.lua" ) -- This means the client will download these files
AddCSLuaFile( "shared.lua" )

include('shared.lua') -- At this point the contents of shared.lua are ran on the server only.

function ENT:Initialize( ) --This function is run when the entity is created so it's a good place to setup our entity.
	
	self:SetModel( "models/Humans/Group03m/male_09.mdl" ) -- Sets the model of the NPC.
	self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things.
	self:SetHullSizeNormal( )
	self:SetNPCState( NPC_STATE_SCRIPT )
	self:SetSolid(  SOLID_BBOX ) -- This entity uses a solid bounding box for collisions.
	self:CapabilitiesAdd( CAP_ANIMATEDFACE ) -- Adds what the NPC is allowed to do ( It cannot move in this case ).
	self:CapabilitiesAdd( CAP_TURN_HEAD )
	self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use.
	self:DropToFloor()
	
	self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.
	
end

function ENT:OnTakeDamage()
	return false -- This NPC won't take damage from anything.
end 

util.AddNetworkString("ShopNPCUsed")

function ENT:AcceptInput( Name, Activator, Caller )	

	if Name == "Use" and Caller:IsPlayer() then
		
		net.Start("ShopNPCUsed")
		net.Send(Caller)

	end
	
end

util.AddNetworkString("GiveHealth25")
util.AddNetworkString("GiveHealth50")
util.AddNetworkString("GiveHealth100")

net.Receive("GiveHealth25",function(len,ply)
	if ply:Health() < 100 then
		if ply.DarkRPVars.money > 1250 then
			ply:SetMaxHealth(100)			
			ply:PrintMessage(HUD_PRINTTALK, "You have purchased 25 Health.")
			ply:addMoney(-1250)
			ply:SetHealth(ply:Health()+25)
		else
			ply:PrintMessage(HUD_PRINTTALK, "You cannot afford 25 Health.")
		end
	else
		ply:PrintMessage(HUD_PRINTTALK, "You are already on full Health.")
	end
end)

net.Receive("GiveHealth50",function(len,ply)
	if ply:Health() < 100 then
		if ply.DarkRPVars.money > 2500 then
			ply:SetMaxHealth(100)
			ply:PrintMessage(HUD_PRINTTALK, "You have purchased 50 Health.")
			ply:addMoney(-2500)
			ply:SetHealth(ply:Health()+50)

		else
			ply:PrintMessage(HUD_PRINTTALK, "You cannot afford 50 Health.")
		end
	else
		ply:PrintMessage(HUD_PRINTTALK, "You are already on full Health.")
	end
end)

net.Receive("GiveHealth100",function(len,ply)
	if ply:Health() < 100 then
		if ply.DarkRPVars.money > 5000 then
			ply:PrintMessage(HUD_PRINTTALK, "You have purchased Full Health.")
			ply:addMoney(-5000)
			ply:SetMaxHealth(100)
			ply:SetHealth(100)
		else
			ply:PrintMessage(HUD_PRINTTALK, "You cannot afford Full Health.")
		end
	else
		ply:PrintMessage(HUD_PRINTTALK, "You are already on full Health.")
	end
end)


[editline]5th September 2016[/editline]

Solved it ty anyone looking.