Detect Gibs

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

Moderators: Forum moderators, developers

Post Reply
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Detect Gibs

Post by crazyfrag »

is it possible to detect if someone is gibbed?
and then bring him back 2 life?

i tried

Code: Select all

if &#40;et.gentity_get&#40;targetID,"sess.sessionTeam"&#41;==3&#41; or &#40;et.gentity_get&#40;targetID,"health"&#41; <= -200&#41; then
i used et_RunFrame to check with samplerate
then i tried 2 revive him or set his new health but it doenst work :(
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

once they're gibbed i believe they're in the que which makes them unavailable for world...
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

if someone ist dead and hie is speccing a player
an u do " rcon revive name" hie will be revived near the guy he's spectating
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

so i tried thi but it doenst work because the revive can't fidne the target :-( ho do i get the color codes out of the name?

Code: Select all

function et_Obituary&#40; victim, killer, meansofdeath &#41; 
		local vteam = tonumber&#40;et.gentity_get&#40;victim, "sess.sessionTeam"&#41;&#41; 
		local vt = string.gsub&#40;et.gentity_get&#40;victim, "pers.netname"&#41;, "%^$", "^^ "&#41; 
		soundindex = et.G_SoundIndex&#40;"sound/player/hurt_barbwire.wav" &#41;
		if meansofdeath == 36 then
		 if vteam == 2 then
			et.trap_SendConsoleCommand&#40; et.EXEC_NOW, "forcecvar sv_cheats 1" &#41;
			et.G_Sound&#40;killer, soundindex &#41;
			et.trap_SendServerCommand&#40; killer,"chat \"^7Knife killing is not ^1Allowed!!\n\""&#41;
			et.trap_SendConsoleCommand&#40; et.EXEC_NOW, "revive vt" &#41;
			et.gentity_set&#40;killer, "health", -200&#41;
			et.trap_SendConsoleCommand&#40; et.EXEC_NOW, "forcecvar sv_cheats 0" &#41;
		end
	end
end

sry if this is a mess --- just started writing luas :-(
Last edited by crazyfrag on Sun Jan 11, 2009 8:49 am, edited 2 times in total.
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

ok that thing with the color codes :-) did it and it worked but te console still thinks im not alive if i rcon revive me :(
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

crazyfrag wrote:ok that thing with the color codes :-) did it and it worked but te console still thinks im not alive if i rcon revive me :(
A few people have tried messing around with the 'revive' thing and have failed to get it to work properly. I got the same thing as what you said above, and I'm pretty sure Clutch did too. I never figured out how to get normal behaviour back.

Out of interest, is this for the no-knife kill rule on Hide and Seek servers?
GhosT:McSteve
Ghostworks Gaming Community
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

McSteve wrote:
crazyfrag wrote:ok that thing with the color codes :-) did it and it worked but te console still thinks im not alive if i rcon revive me :(
A few people have tried messing around with the 'revive' thing and have failed to get it to work properly. I got the same thing as what you said above, and I'm pretty sure Clutch did too. I never figured out how to get normal behaviour back.

Out of interest, is this for the no-knife kill rule on Hide and Seek servers?
yes for hidn seek!
now if an axis knifes an allies he get bashed and allies players life is set to 100 ... and it works
now i trie to that allies team has half of players than axis team heres mycode :-( its not working maybe u could help be!

regards crazy

Code: Select all

function et_InitGame&#40;levelTime,randomSeed,restart&#41;
	mclients = tonumber&#40; et.trap_Cvar_Get&#40; "sv_maxClients" &#41; &#41;
	count =  &#123;&#125;
	counti = &#123;&#125;
end	

function et_ClientBegin&#40; clientNum &#41; 
	local team = et.gentity_get&#40;clientNum, "sess.sessionTeam"&#41;
	if team == 1 then
		count&#91;a&#93; = &#40;count&#91;a&#93; + 1&#41;
		et.trap_SendServerCommand&#40;clientNum , "chat "AXIS COUNTER &#58; "..count&#91;a&#93;.."\n"" &#41;
	elseif team == 2 then
		counti&#91;b&#93; = &#40;counti&#91;b&#93; + 1&#41;
		et.trap_SendServerCommand&#40;clientNum , "chat "ALLIED COUNTER&#58; "..counti&#91;b&#93;.."\n"" &#41;
	local teamindex = tonnumber&#40;counti&#91;b&#93; * 2&#41;
	if teamindex > count&#91;a&#93; then
	    et.trap_SendConsoleCommand&#40; et.EXEC_NOW, "ref putaxis " .. clientNum .. "\n" &#41;
	    et.trap_SendServerCommand&#40;clientNum , "chat "^7You have been switched to Axis Team!\n"" &#41;
			end
		end
	end
end
function et_ClientDisconnect&#40; clientNum &#41;
	local team = et.gentity_get&#40;clientNum, "sess.sessionTeam"&#41;
	if team == 1 then
		count&#91;a&#93; = &#40;count&#91;a&#93; - 1&#41;
	elseif team == 2 then
		counti&#91;b&#93; = &#40;counti&#91;b&#93; - 1&#41;
	end
end

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

Post by McSteve »

crazyfrag wrote:its not working maybe u could help be!
More debug lines.

:P
GhosT:McSteve
Ghostworks Gaming Community
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

ok i tried a bit more now its looking like this

Code: Select all

function et_InitGame&#40;levelTime,randomSeed,restart&#41;
	mclients = tonumber&#40; et.trap_Cvar_Get&#40; "sv_maxClients" &#41; &#41;
	count = 0
	counti = 0
end		



function et_ClientBegin&#40; clientNum &#41; 
	local team = tonumber&#40;et.gentity_get&#40;clientNum, "sess.sessionTeam"&#41;&#41; 
	if team == 1 then
		count = &#40;count + 1&#41; 
	elseif team == 2 then
		counti = &#40;counti + 1&#41;
	local teamindex = &#40;counti + counti&#41; +1 
	if teamindex > count then
	       et.trap_SendConsoleCommand&#40; et.EXEC_NOW, "ref putaxis "..clientNum.."\n" &#41;
	       et.trap_SendServerCommand&#40;clientNum , "chat \"^7You have been switched to Axis Team!\n\"" &#41;
	 end
    end
end
function et_ClientDisconnect&#40; clientNum &#41;
	team = et.gentity_get&#40;clientNum, "sess.sessionTeam"&#41;
	if team == 1 then
		count = &#40;count - 1&#41;
	elseif team == 2 then
		counti = &#40;counti - 1&#41;
	end
end

the prob is: now alle players geht switched to axis if the teamindex is to hight lol :////

is there any possibility to call 1/3 of all connected players?


my other possiblities look like this:
to use
et_print to find "player has joined the axis team"
but then i have the problem that if a player gets out of a team the console does not know inn which team the player was :D and i do not know how to get the "players" name out of that string

3rd:
i get allies team locked when the teamindex is to high and get it unlocked if its ok hmn...
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

It is difficult to help as I do not know all the specifics of what you want to do. However, it does appear that you are currently using et_clientbegin and et_clientdisconnect to control when actions are taken, and I would suggest this is not the appropriate time to do things. Using et_clientcommand may be a better option.

I can offer some excerpts from a couple of my scripts that hopefully will be of some help.

This is how I counted players on the server, with an option to include specs or not.

Code: Select all


-- Shall spectators be counted in the playercount? &#40;1/0 = yes/no&#41;
includespecs = 1

	-- COUNT THE NUMBER OF PLAYERS ON THE SERVER
	if includespecs == 1 then
		for i = 0, &#40;maxclients - 1&#41; do
			if et.gentity_get&#40;i, "sess.sessionTeam"&#41; ~= 0 then
				--et.trap_SendConsoleCommand&#40;et.EXEC_APPEND, "qsay \"^3sessionteam "  .. i .. " " .. et.gentity_get&#40;i, "sess.sessionTeam"&#41; .. "\"\n"&#41;
				playercount = playercount + 1
			end	
		end
	elseif includespecs == 0 then
		for i = 0, &#40;maxclients - 1&#41; do
			if &#40;tonumber&#40;et.gentity_get&#40;i, "sess.sessionTeam"&#41;&#41; == 1&#41; or &#40;tonumber&#40;et.gentity_get&#40;i, "sess.sessionTeam"&#41;&#41; == 2&#41; then
				playercount = playercount + 1
			end	
		end
	end
It may be appropriate to enforce your restriction using et_clientcommand, like in this example:

Code: Select all

-- called on client command
function et_ClientCommand&#40;cno, cmd&#41;		

		if string.lower&#40;cmd&#41; == "team" then
				
			if -- insert condition to be met for whether or not to join axis/allies or whatever
				et.trap_SendServerCommand&#40;cno, "cp \"^3Sorry, you cannot join that team.\n\" " &#41;				
				return 1	-- prevents the teamjoin
			end
		end

	return 0	-- allows the cmd
end
I would also suggest avoiding the use of et_print if at all possible. At best, it is a pain in the ass: at worst, unforseen events break everything.
GhosT:McSteve
Ghostworks Gaming Community
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

ty dude u helped me alot :)
now it looks like this

Code: Select all

counta = 0
countb = 0

function et_InitGame&#40;levelTime,randomSeed,restart&#41;
	mclients = tonumber&#40; et.trap_Cvar_Get&#40; "sv_maxClients" &#41; &#41;
end		

function et_ClientBegin&#40; clientNum &#41;
		for i = 0, &#40;mclients - 1&#41; do 
		team = et.gentity_get&#40;i, "sess.sessionTeam"&#41; 
		  if team == 1 then
			counta = counta + 1 
		elseif team == 2 then
			countb = countb + 1 
    	end 
end

function et_ClientCommand&#40;clientNum, command&#41;
	local teamindex = &#40;countb + countb&#41; + 5
  if string.lower&#40;command&#41; == "team" then
	if et.trap_Argv&#40;1&#41; == "b" then
         if teamindex > counta then
            et.trap_SendServerCommand&#40;clientNum, "chat \"^7Sorry, you cannot join the ^1Allied ^3team.\n\" " &#41;
		et.trap_SendServerCommand&#40;clientNum, "chat \"^7There must be a ratio of ^12 ^0&#58; ^11 ^7// ^1AXIS ^0&#58; ^1ALLIES\n\" " &#41;             
            return 1   -- prevents the teamjoin
          end
         end
	end
   return 0   -- allows the cmd
end 
end

function et_ClientDisconnect&#40; clientNum &#41;
   team = et.gentity_get&#40;clientNum, "sess.sessionTeam"&#41;
   if team == 1 then
      counta = &#40;counta - 1&#41;
   elseif team == 2 then
      countb = &#40;countb - 1&#41;
   end
end 

crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

so ... is there any possibiliti to check when someone gets gibbed?
User avatar
dutchmeat
Posts: 62
Joined: Tue Jan 28, 2003 8:08 am
Location: Netherlands
Contact:

Post by dutchmeat »

You can not revive a gibbed player because it doesn't have a body anymore, and the revive function won't let you revive him.

If it were posible then you could've done something like this:

Code: Select all

samplerate = 200 
maxclients = 0

function et_InitGame&#40;levelTime,randomSeed,restart&#41; 
   maxclients = tonumber&#40; et.trap_Cvar_Get&#40; "sv_maxClients" &#41; &#41;   --gets the maxclients 
end 

function et_RunFrame&#40; levelTime &#41; 
     
   if math.mod&#40;levelTime, samplerate&#41; ~= 0 then return end 
   -- for all clients 
   for j = 0, &#40;maxclients - 1&#41; do 
	-- if the player is not a spectator, and it's health is/or is below 200, then do something with it.
	if &#40;et.gentity_get&#40;j,"sess.sessionTeam"&#41;!=3&#41; and &#40;et.gentity_get&#40;j,"health"&#41; <= -200&#41; then
		et.trap_SendServerCommand&#40; -1,"print \"^7a player is gibbed\n\""&#41; 
	end
      end       
   end 
       
end 
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

no i found another way :)

Code: Select all


--global vars
allowedgibs = 1
samplerate = 200

function et_RunFrame&#40; levelTime &#41;
 	
	if math.mod&#40;levelTime, samplerate&#41; ~= 0 then return end
	-- for all clients
	for cno=0, mclients-1, 1 do
			if tonumber&#40;&#40;et.gentity_get&#40;cno, "sess.gibs"&#41;&#41;&#41; > allowedgibs then		
			     name = et.gentity_get&#40;cno, "pers.netname"&#41;
				et.trap_SendConsoleCommand&#40; et.EXEC_NOW, "ref remove "..name.."\n" &#41;
				for k = 0, mclients - 1, 1 do
				et.trap_SendServerCommand&#40;k , "chat \""..name.." ^7has made a ^7>>>^1GIB^7<<< ^7and has been removed from his team!\n\"" &#41;
					end
				end	
			end		
		end	
	end
end
when then lua detectes the amount of "allowedgibs" definded then it puts the player spec .. when he has been put spec his stats get deleted ! so the run frame wont call again :-)


but if u use rcon revive when a player is gibbed he gets revive near the guy he's atm following
Post Reply