Page 1 of 1
Detect Gibs
Posted: Fri Jan 09, 2009 10:45 am
by crazyfrag
is it possible to detect if someone is gibbed?
and then bring him back 2 life?
i tried
Code: Select all
if (et.gentity_get(targetID,"sess.sessionTeam")==3) or (et.gentity_get(targetID,"health") <= -200) then
i used et_RunFrame to check with samplerate
then i tried 2 revive him or set his new health but it doenst work
Posted: Fri Jan 09, 2009 9:08 pm
by gotenks
once they're gibbed i believe they're in the que which makes them unavailable for world...
Posted: Sat Jan 10, 2009 2:43 am
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
Posted: Sat Jan 10, 2009 3:11 am
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( victim, killer, meansofdeath )
local vteam = tonumber(et.gentity_get(victim, "sess.sessionTeam"))
local vt = string.gsub(et.gentity_get(victim, "pers.netname"), "%^$", "^^ ")
soundindex = et.G_SoundIndex("sound/player/hurt_barbwire.wav" )
if meansofdeath == 36 then
if vteam == 2 then
et.trap_SendConsoleCommand( et.EXEC_NOW, "forcecvar sv_cheats 1" )
et.G_Sound(killer, soundindex )
et.trap_SendServerCommand( killer,"chat \"^7Knife killing is not ^1Allowed!!\n\"")
et.trap_SendConsoleCommand( et.EXEC_NOW, "revive vt" )
et.gentity_set(killer, "health", -200)
et.trap_SendConsoleCommand( et.EXEC_NOW, "forcecvar sv_cheats 0" )
end
end
end
sry if this is a mess --- just started writing luas
Posted: Sun Jan 11, 2009 4:59 am
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
Posted: Sun Jan 11, 2009 9:04 am
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?
Posted: Sun Jan 11, 2009 9:32 am
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(levelTime,randomSeed,restart)
mclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )
count = {}
counti = {}
end
function et_ClientBegin( clientNum )
local team = et.gentity_get(clientNum, "sess.sessionTeam")
if team == 1 then
count[a] = (count[a] + 1)
et.trap_SendServerCommand(clientNum , "chat "AXIS COUNTER : "..count[a].."\n"" )
elseif team == 2 then
counti[b] = (counti[b] + 1)
et.trap_SendServerCommand(clientNum , "chat "ALLIED COUNTER: "..counti[b].."\n"" )
local teamindex = tonnumber(counti[b] * 2)
if teamindex > count[a] then
et.trap_SendConsoleCommand( et.EXEC_NOW, "ref putaxis " .. clientNum .. "\n" )
et.trap_SendServerCommand(clientNum , "chat "^7You have been switched to Axis Team!\n"" )
end
end
end
end
function et_ClientDisconnect( clientNum )
local team = et.gentity_get(clientNum, "sess.sessionTeam")
if team == 1 then
count[a] = (count[a] - 1)
elseif team == 2 then
counti[b] = (counti[b] - 1)
end
end
Posted: Sun Jan 11, 2009 10:23 am
by McSteve
crazyfrag wrote:its not working maybe u could help be!
More debug lines.
Posted: Sun Jan 11, 2009 11:22 am
by crazyfrag
ok i tried a bit more now its looking like this
Code: Select all
function et_InitGame(levelTime,randomSeed,restart)
mclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )
count = 0
counti = 0
end
function et_ClientBegin( clientNum )
local team = tonumber(et.gentity_get(clientNum, "sess.sessionTeam"))
if team == 1 then
count = (count + 1)
elseif team == 2 then
counti = (counti + 1)
local teamindex = (counti + counti) +1
if teamindex > count then
et.trap_SendConsoleCommand( et.EXEC_NOW, "ref putaxis "..clientNum.."\n" )
et.trap_SendServerCommand(clientNum , "chat \"^7You have been switched to Axis Team!\n\"" )
end
end
end
function et_ClientDisconnect( clientNum )
team = et.gentity_get(clientNum, "sess.sessionTeam")
if team == 1 then
count = (count - 1)
elseif team == 2 then
counti = (counti - 1)
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
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...
Posted: Mon Jan 12, 2009 11:12 am
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? (1/0 = yes/no)
includespecs = 1
-- COUNT THE NUMBER OF PLAYERS ON THE SERVER
if includespecs == 1 then
for i = 0, (maxclients - 1) do
if et.gentity_get(i, "sess.sessionTeam") ~= 0 then
--et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3sessionteam " .. i .. " " .. et.gentity_get(i, "sess.sessionTeam") .. "\"\n")
playercount = playercount + 1
end
end
elseif includespecs == 0 then
for i = 0, (maxclients - 1) do
if (tonumber(et.gentity_get(i, "sess.sessionTeam")) == 1) or (tonumber(et.gentity_get(i, "sess.sessionTeam")) == 2) 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(cno, cmd)
if string.lower(cmd) == "team" then
if -- insert condition to be met for whether or not to join axis/allies or whatever
et.trap_SendServerCommand(cno, "cp \"^3Sorry, you cannot join that team.\n\" " )
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.
Posted: Mon Jan 12, 2009 1:30 pm
by crazyfrag
ty dude u helped me alot
now it looks like this
Code: Select all
counta = 0
countb = 0
function et_InitGame(levelTime,randomSeed,restart)
mclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )
end
function et_ClientBegin( clientNum )
for i = 0, (mclients - 1) do
team = et.gentity_get(i, "sess.sessionTeam")
if team == 1 then
counta = counta + 1
elseif team == 2 then
countb = countb + 1
end
end
function et_ClientCommand(clientNum, command)
local teamindex = (countb + countb) + 5
if string.lower(command) == "team" then
if et.trap_Argv(1) == "b" then
if teamindex > counta then
et.trap_SendServerCommand(clientNum, "chat \"^7Sorry, you cannot join the ^1Allied ^3team.\n\" " )
et.trap_SendServerCommand(clientNum, "chat \"^7There must be a ratio of ^12 ^0: ^11 ^7// ^1AXIS ^0: ^1ALLIES\n\" " )
return 1 -- prevents the teamjoin
end
end
end
return 0 -- allows the cmd
end
end
function et_ClientDisconnect( clientNum )
team = et.gentity_get(clientNum, "sess.sessionTeam")
if team == 1 then
counta = (counta - 1)
elseif team == 2 then
countb = (countb - 1)
end
end
Posted: Thu Jan 15, 2009 2:13 pm
by crazyfrag
so ... is there any possibiliti to check when someone gets gibbed?
Posted: Fri Jan 16, 2009 5:11 am
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(levelTime,randomSeed,restart)
maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) ) --gets the maxclients
end
function et_RunFrame( levelTime )
if math.mod(levelTime, samplerate) ~= 0 then return end
-- for all clients
for j = 0, (maxclients - 1) do
-- if the player is not a spectator, and it's health is/or is below 200, then do something with it.
if (et.gentity_get(j,"sess.sessionTeam")!=3) and (et.gentity_get(j,"health") <= -200) then
et.trap_SendServerCommand( -1,"print \"^7a player is gibbed\n\"")
end
end
end
end
Posted: Sat Jan 17, 2009 11:39 am
by crazyfrag
no i found another way
Code: Select all
--global vars
allowedgibs = 1
samplerate = 200
function et_RunFrame( levelTime )
if math.mod(levelTime, samplerate) ~= 0 then return end
-- for all clients
for cno=0, mclients-1, 1 do
if tonumber((et.gentity_get(cno, "sess.gibs"))) > allowedgibs then
name = et.gentity_get(cno, "pers.netname")
et.trap_SendConsoleCommand( et.EXEC_NOW, "ref remove "..name.."\n" )
for k = 0, mclients - 1, 1 do
et.trap_SendServerCommand(k , "chat \""..name.." ^7has made a ^7>>>^1GIB^7<<< ^7and has been removed from his team!\n\"" )
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