util.AddNetworkString( "SetHealth1" )
net.Receive( "SetHealth1", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 25)
end
end)
util.AddNetworkString( "SetHealth2" )
net.Receive( "SetHealth2", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 50)
end
end)
util.AddNetworkString( "SetHealth3" )
net.Receive( "SetHealth3", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 75)
end
end)
util.AddNetworkString( "SetHealth4" )
net.Receive( "SetHealth4", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 100)
end
end)
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 100)
How much is the health going over maxhealth? Because if the player has 99 health, which is less than 100, he still can get 25,50,75 or 100. As long as its under 100 it works. Because SetHealth will go further and further. theres no limit (i mean there is because 64 bit but..its a insane big number)
So as long as the players health is lower than 100, which starts at 99 and less, he can get more health, which will go over 100 then
move thread?
but is for that any coding or not?
and pls move the thread to Not help & support for gmod in general
im not a admin/mod, i cant move anything.
And if you ask if its fixable, of course it is. But for that i need to know:
You dont want to overheal the player, right? its supposed to stay inside 100 and not go over that?
yeah
then just reedit the numbers that get compared to the players health.
for example on the 25 health pack
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth - 25 then
ply:SetHealth(ply:Health() + 100)
basically let it check if Players healt his less than maxhealth minus 25, so he will only get the 25 health pack when his life is less than his maxhealth minus 25. So when he gets 25 health it will definetly stay under maxhealth, cause he doesnt have enough health i nthe first place to overheal with 25 health
for 50,75 and 100 just replace the 25 with the numbers
when i do this its now even giving me health
util.AddNetworkString( "SetHealth1" )
net.Receive( "SetHealth1", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth - 25 then
ply:SetHealth(ply:Health() + 25)
end
end)
util.AddNetworkString( "SetHealth2" )
net.Receive( "SetHealth2", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth - 50 then
ply:SetHealth(ply:Health() + 50)
end
end)
util.AddNetworkString( "SetHealth3" )
net.Receive( "SetHealth3", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth - 75 then
ply:SetHealth(ply:Health() + 75)
end
end)
util.AddNetworkString( "SetHealth4" )
net.Receive( "SetHealth4", function( bits, ply )
local maxhealth = ply:GetMaxHealth() or 100
if ply:Health() < maxhealth - 20 then
ply:SetHealth(ply:Health() + 100)
end
end)
1: This script there is clientside i suppose? You do not need to util.AddNetWorkString there, since its the one recieving it. The Server, who sends the SetHealth1/2/3/4 messages need util.AddNetWorkString, but not the reciever. The reciver just needs the net.recieve.
Also what do you mean with its not even giving me health? Isnt that whats its supposed to do?
Also also, on SetHealth4, why do you do
if ply:Health() < maxhealth - 20 then
ply:SetHealth(ply:Health() + 100)
? Why check if its less than 20, and then add 100? that would overheal by 80
Sorry, you need to Log In to post a reply to this thread.