Forum

> > CS2D > Scripts > disconnected alive or dead
Forums overviewCS2D overview Scripts overviewLog in to reply

English disconnected alive or dead

12 replies
To the start Previous 1 Next To the start

old disconnected alive or dead

EnderCrypt
User Off Offline

Quote
hi
i have a leave hook
is it possible to know if they player disconnected when alive, or when dead (or in spect)

cause i would like to have somheting to tell if player was alive or not

thx

old Re: disconnected alive or dead

KimKat
GAME BANNED Off Offline

Quote
I think the leave hook would solve all of this.

Why would one want to check if the players are dead or alive when they disconnect from the server? just asking.

Anyways I think this would solve it...
1
2
3
4
5
6
7
8
9
10
addhook("leave","health_check")
function health_check(id)
	if player(id,"health")==0 then
		msg2(id,"©255255000"..player(id,"name").." disconnected while DEAD!")
		return 0
	elseif player(id,"health")>=0 then
		msg2(id,"©255255000"..player(id,"name").." disconnected while ALIVE!")
		return 0
	end
end
This should work.
edited 3×, last 28.02.11 11:04:17 pm

old Re: disconnected alive or dead

EnderCrypt
User Off Offline

Quote
gonna try

edit: why it never works...

i tink everyone has 0 hp when leaving... that would explain why no message apper
edited 2×, last 02.03.11 04:31:25 pm

old Re: disconnected alive or dead

KimKat
GAME BANNED Off Offline

Quote
pheangsri has written
gonna try

edit: why it never works...

i tink everyone has 0 hp when leaving... that would explain why no message apper
I simply forgot to make it so that all on server can see the messages...

1
2
3
4
5
6
7
8
9
10
11
12
addhook("leave","health_check")
function health_check(id)
	local p_hp = player(id,"health")
	local p_nm = player(id,"name")
	if p_hp==0 then
		msg([[©255255000"..p_nm.." disconnected while DEAD!]])
	return 0
	elseif p_hp>=0 then
		msg([[©255255000"..p_nm.." disconnected while ALIVE but injured to "..p_hp.." health!]])
	return 0
	end
end
That should work, flawlessly.

old Re: disconnected alive or dead

EnderCrypt
User Off Offline

Quote
anyone else got a idea?

edit... hm my fault should have added stuff before tested

seems to work now thx
edit 2, i tink i know what was wrong
when i changed name of this to what i normally use in this hook, then it didnt work, so there was problably a name conflict, even if there only was that name on 2 places in my lua

adhook and function...
edited 1×, last 06.03.11 09:22:02 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview