LUA script - bringing a player back to life

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

Post Reply
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

LUA script - bringing a player back to life

Post by McSteve »

I have a small mod that I use to play around with botters who come on the server. One of the functions kills the client whenever they kill someone. Initially, I planned to bring their victim back to life but the simple method of trying to set their health back to positive doesn't work properly. Any suggestions?

Code: Select all

--on a player death, check to see if the killer is flagged up for ownage
function et_Obituary( victim, killer, meansOfDeath )

	-- if the killer is flagged for ownage, then own the bastard
	if own_client[killer] == 1 then

		-- explanation -  et.G_Damage( target, inflictor, attacker, damage, dflags, mod ), mod 0 = unknown
		et.G_Damage( killer, 80, victim, 1000, 8, meansOfDeath )

		-- bring the victim back to life here
		-- note: this doesn't work very well; victim seems to be "dead" hence another kill doesnt register
		-- et.gentity_set(victim, "health", 100)

	end
end
p.s. note, I am scared of the ET source code :S
GhosT:McSteve
Ghostworks Gaming Community
User avatar
mortis
Posts: 360
Joined: Tue Jul 06, 2004 11:57 pm
Location: at the center of the e-universe
Contact:

Post by mortis »

I don't know where it is in the code, but I remember some warning rain wrote in the oasis script about the "revive box being called" maybe you should look at "reviving" them.
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

Yes, this is more accurately what I'm asking for. By using the code that's commented out above, I can bring an ungibbed person back to life but it has repercussions. They dont seem to be 'officially' alive so funny things happen when they kill people or get killed again.
GhosT:McSteve
Ghostworks Gaming Community
User avatar
mortis
Posts: 360
Joined: Tue Jul 06, 2004 11:57 pm
Location: at the center of the e-universe
Contact:

Post by mortis »

can you create a temporary spawn point and respawn them there?
Nappy
Posts: 15
Joined: Mon Apr 10, 2006 4:52 pm

Post by Nappy »

I believe you need something that will trigger et_ClientSpawn( clientNum, revived ).
User avatar
ReyalP
Posts: 1663
Joined: Fri Jul 25, 2003 11:44 am

Post by ReyalP »

Nappy wrote:I believe you need something that will trigger et_ClientSpawn( clientNum, revived ).
Correct. There is a lot more to the revive code than just adding the health. You can't currently do it from lua.

You could try using the revive server console command, but that requires cheats be enabled. You might be able to twiddle sv_cheats quickly while you send the revive command, I suppose. I suspect this would end up being more of a kludge than you want.
send lawyers, guns and money
User avatar
Clutch152
Posts: 33
Joined: Thu Oct 12, 2006 8:52 pm

Post by Clutch152 »

yea i fiddled with a playdead command for KMOD. The player would fall down normally but when you stood back up and started running round you still appeared injured/limbo waiting for a revive. To see a person wanting to be revived jumping around and running and shooting was really funny. After you stand back up you can't hear your footsteps either unless you jump.
Image
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

I did a version using a sv_cheats switch and a console command to revive the player. It works, but it has the same problems as simply setting the player's health, i.e. sometimes the revived player's kills and next death dont register.

Too much of a push for lua I reckon, will happily post up what I had if anyone is interested.
GhosT:McSteve
Ghostworks Gaming Community
User avatar
ReyalP
Posts: 1663
Joined: Fri Jul 25, 2003 11:44 am

Post by ReyalP »

McSteve wrote:I did a version using a sv_cheats switch and a console command to revive the player. It works, but it has the same problems as simply setting the player's health, i.e. sometimes the revived player's kills and next death dont register.

Too much of a push for lua I reckon, will happily post up what I had if anyone is interested.
You used the 'revive <playername>' server console command ? This should work almost exactly like getting hit with a needle (except that the players being revived is also counted as the reviver, for things like whether they get a full revive or not)

It won't work quite right if the player is already gibbed. Also note that 'revive' takes a player name, matching an exact (less color codes) name first, or failing that, a partial match.
send lawyers, guns and money
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

Hmm, I would have to go back and double-check, but I'm reasonably certain I got strange behaviour even if reviving an ungibbed player.

Its not a big issue anyway, it was only a niceity to polish off that script. You've made me curious now though, I might go back and have another look at the different cases.
GhosT:McSteve
Ghostworks Gaming Community
Post Reply