banimod / etpro / ettv forums Forum Index banimod / etpro / ettv forums
Bani's Discussion Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Players Health

 
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Modding
View previous topic :: View next topic  
Author Message
Micha!



Joined: 23 Oct 2008
Posts: 17

PostPosted: Sat May 09, 2009 10:14 am    Post subject: Players Health Reply with quote

Hi I tried to change players hp but I'm a lua noob. (For the hole map not only if you die or etc)
It would be nice if you can change the hp for each class.
So here is my try:
Code:
Version =    1.0
Author  =   "^wMicha^0!"
Description = "^7Health"
Homepage = "^7www^1.^7gs2175^1.^wfastdl^1.^7de "

--global vars
samplerate = 200
et.CS_PLAYERS = 689

--


function et_InitGame(levelTime,randomSeed,restart)
   mclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )
   et.G_Print("[Health] Version:1.0 Loaded\n")
      et.RegisterModname("Health")
   et.trap_SendServerCommand(-1, "b 8 \""..Description.." ^0[^7LUA^0] ^7powered by "..Author.." ^7visit "..Homepage.." \n\"" )
      count = {}
         for i = 0, mclients - 1 do
         count[i] = 0   
   end   
end

--on a player death, check to see if the killer is flagged up for ownage
function et_Obituary( victim, killer, meansOfDeath )
      local vteam = tonumber(et.gentity_get(victim, "sess.sessionTeam"))
      local vteam1 = tonumber(et.gentity_get(killer, "sess.sessionTeam"))
      local vt1 = string.gsub(et.gentity_get(victim, "pers.netname"), "%^$", "^^ ")
      local vt2 = string.gsub(et.gentity_get(killer, "pers.netname"), "%^$", "^^ ")
      if meansofdeath == 6 then
       if vteam == 2  then
         if vteam1 == 1 then
               et.gentity_set(victim, "health", 300)
         end
      end
end
   if meansofdeath == 1 then
         et.gentity_set(victim, "health", 200)
           end
end

function et_ClientBegin( clientNum )
      if et.gentity_get("health") <= 0 then
         et.gentity_set("health", 200)
      end
end


Can you help me with that pls?


Last edited by Micha! on Sat May 09, 2009 3:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
McSteve



Joined: 12 Sep 2006
Posts: 112

PostPosted: Sat May 09, 2009 11:04 am    Post subject: Re: Players Health Reply with quote

Code:

--on a player death, check to see if the killer is flagged up for ownage


I recognise that comment! Wink

Anyway, if I read your post correctly, you say you want to set different hp for each class. I wrote a script once that inflicted punishments in health and ammo for people the more times they selfkilled. Thing is, this only set the hp at spawn time (tip: function et_ClientSpawn(cno, revived) , not et_clientbegin()) and did not affect its maximum value. I'm not sure if this will be of use but here is the link just in case it is.

I've never tried messing with the maximums, so can't help you there. Maybe one of the lua gurus knows if it is possible. If you only want to lower hp, that makes things a lot easier. By the looks of it, you want to increase hp on some occasion, which will take some experimenting.
_________________
GhosT:McSteve
Ghostworks Gaming Community
Back to top
View user's profile Send private message
Micha!



Joined: 23 Oct 2008
Posts: 17

PostPosted: Sat May 09, 2009 12:28 pm    Post subject: Reply with quote

Thx Steve, I try to change the players hp for the map, not only if they die or something. Razz
Like 300 hp or somethign would be funny.
I know that this is possible with .dll or .so, but you need to change the mdo then and I don't want to do it^^


Btw the middle was taken of a other lua to test if this works.

*EDIT*
Perlung aka crazy helped me and that came out:
Code:
--Do not change--
Modname = "HealthBoost"
Version = "1.0"
Author  = "Perlo_0ung?!"
Description = "^7HealthBoost"
Homepage = "www.gs2175.fastdl.de"
Text = "^1| ^7Maximal: ^3300 ^1| ^7Increase: ^320"
--
 
--global vars
samplerate = 5000
et.CS_PLAYERS = 689
--

function et_InitGame(levelTime,randomSeed,restart)
   maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )   --gets the maxclients
   et.G_Print("[HealthBoost] Version:1.0 Loaded\n")
      et.RegisterModname(Modname .. " " .. Version)
   et.trap_SendServerCommand(-1, "b 8 \""..Description.." ^0[^7LUA^0] "..Text.." \n\"" )
      count = {}
         for i = 0, mclients - 1 do
         count[i] = 0   
   end   

end   

function et_RunFrame( levelTime )
   if math.mod(levelTime, samplerate) ~= 0 then return end
   for j = 0, (maxclients - 1) do
   hp = tonumber(et.gentity_get(j,"health"))

   ---------------20: HP increase----------------

   shp = (tonumber(et.gentity_get(j,"health")) + 20 )

   ----------300: Maximal Healthpoints-----------

   if hp > 300 then return end
   if hp < 300 then

   ----------------------------------------------

      et.gentity_set(j, "health", shp)
   end
end
end
Back to top
View user's profile Send private message
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Sun May 10, 2009 1:12 am    Post subject: Reply with quote

increasing the hp pemanently is atm not possible cause hp gets lowered itself if its higher than the maxhp of the class
Back to top
View user's profile Send private message MSN Messenger
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Sun May 10, 2009 2:06 am    Post subject: Reply with quote

here's my hp increase beta version:

Code:

--Do not change--
Modname = "HealthBoost"
Version = "1.1"
Author  = "Perlo_0ung?!"
Description = "^7HealthBoost"
Homepage = "www.gs2175.fastdl.de"
Text = "^1| ^7Maximal: ^3300 ^1| ^7Increase: ^320"
--
 
--global vars
et.CS_PLAYERS = 689
samplerate = 1000
medic_max_hp = 200
class_max_hp = 150

--


function et_InitGame(levelTime,randomSeed,restart)
   maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )   --gets the maxclients
   et.G_Print("[HealthBoost] Version:1.0 Loaded\n")
      et.RegisterModname(Modname .. " " .. Version)
   et.trap_SendServerCommand(-1, "b 8 \""..Description.." ^0[^7LUA^0] "..Text.." \n\"" )
      count = {}
         for cno = 0, maxclients - 1 do
         count[cno] = 1   
   end   

end 
 
function et_ClientSpawn(cno,revived)
   if revived == 0 then
   count[cno] = 1
   end
end
function et_ClientDisconnect(cno)
   count[cno] = 0
end

function et_RunFrame( levelTime )
   for cno = 0, (maxclients - 1) do
   if count[cno] == 1 then
  local class = et.gentity_get(cno,"sess.playertype")
     if class == 1 then
      local mhp = ( medic_max_hp - (et.gentity_get(cno,"health")))
      local newmhp = (et.gentity_get(cno,"health") + mhp)
            et.gentity_set(cno, "health", newmhp)
      count[cno] = 0
     elseif class == 0 or class == 2 or class == 3 or class == 4 then
      local chp = ( class_max_hp  - (et.gentity_get(cno,"health")))
      local newchp = (et.gentity_get(cno,"health") + chp)
            et.gentity_set(cno, "health", newchp)
      count[cno] = 0
      end   
   end
   end
 if math.mod(levelTime, samplerate) ~= 0 then return end
   for cno = 0, (maxclients - 1) do
  local class = et.gentity_get(cno,"sess.playertype")
  local shp = (tonumber(et.gentity_get(cno,"health")) + 1)
   if class == 1 then
         if shp > 189 then return end
            if shp < 189 then
         et.gentity_set(cno, "health", shp)
      end
   elseif class == 0 or class == 2 or class == 3 or class == 4 then
         if shp > 151 then return end
            if shp < 151 then
         et.gentity_set(cno, "health", shp)
      end
   end
   end
end
Back to top
View user's profile Send private message MSN Messenger
Micha!



Joined: 23 Oct 2008
Posts: 17

PostPosted: Sun May 10, 2009 4:40 am    Post subject: Reply with quote

Code:
--Do not change--
Modname = "HealthBoost"
Version = "1.1"
Author  = "Perlo_0ung?!"
Description = "^7HealthBoost2"
Homepage = "www.gs2175.fastdl.de"
Text = "^1| ^7Medic: ^3200 ^1| ^7Rest: ^3150"
--
 
--global vars
et.CS_PLAYERS = 689
samplerate = 1000
medic_max_hp = 200
class_max_hp = 150

--


function et_InitGame(levelTime,randomSeed,restart)
   maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )   --gets the maxclients
   et.G_Print("[HealthBoost] Version:1.1 Loaded\n")
      et.RegisterModname(Modname .. " " .. Version)
   et.trap_SendServerCommand(-1, "b 8 \""..Description.." ^0[^7LUA^0] "..Text.." \n\"" )
      count = {}
         for cno = 0, maxclients - 1 do
         count[cno] = 1   
   end   

end
 
function et_ClientSpawn(cno,revived)
   if revived == 0 then
   count[cno] = 1
   end
end
function et_ClientDisconnect(cno)
   count[cno] = 0
end

function et_RunFrame( levelTime )
   for cno = 0, (maxclients - 1) do
   if count[cno] == 1 then
  local class = et.gentity_get(cno,"sess.playertype")
     if class == 1 then
      local mhp = ( medic_max_hp - (et.gentity_get(cno,"health")))
      local newmhp = (et.gentity_get(cno,"health") + mhp)
            et.gentity_set(cno, "health", newmhp)
      count[cno] = 0
     elseif class == 0 or class == 2 or class == 3 or class == 4 then
      local chp = ( class_max_hp  - (et.gentity_get(cno,"health")))
      local newchp = (et.gentity_get(cno,"health") + chp)
            et.gentity_set(cno, "health", newchp)
      count[cno] = 0
      end   
   end
   end
 if math.mod(levelTime, samplerate) ~= 0 then return end
   for cno = 0, (maxclients - 1) do
  local class = et.gentity_get(cno,"sess.playertype")
  local shp = (tonumber(et.gentity_get(cno,"health")) + 1)
   if class == 1 then
         if shp > 189 then return end
            if shp < 189 then
         et.gentity_set(cno, "health", shp)
      end
   elseif class == 0 or class == 2 or class == 3 or class == 4 then
         if shp > 151 then return end
            if shp < 151 then
         et.gentity_set(cno, "health", shp)
      end
   end
   end
end
Back to top
View user's profile Send private message
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Wed Jun 10, 2009 7:45 am    Post subject: Reply with quote

increase max hp:

Code:

function et_ClientSpawn(cno,revived)
   et.gentity_set(cno, "ps.stats", 4,130)   -- 130 =maxhp
end
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Modding All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group