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:
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.
--on a player death, check to see if the killer is flagged up for ownage
I recognise that comment!
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.
Thx Steve, I try to change the players hp for the map, not only if they die or something.
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:
--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
--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
--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