PDA

View Full Version : {solved} [CS:S] Show alive player in players HUD


stoneyschillhouse
06-10-2016, 05:25
Hi there

GAME -> Counter Strike Source (runs on linux)
PC -> Windows

If someone knows a plugin with which it is possible to show the number of
the surviving players from the other team?

Terrors: 1 alive
Counter-Terrorists: 5 alive

or only the alive player from the other team

Terrors: 1 alive

Or does anyone know a playerside hud application ?
__________________

sdz
06-10-2016, 05:53
I'm not even sure if HudText works in CS:S, so I included HintText in this.

stoneyschillhouse
06-10-2016, 07:16
HI EasSidezz

thx for that.

But i found these in the error logs since running the plugin

L 06/10/2016 - 13:13:34: [SM] [0] Line 29, /home/forums/content/files/1/7/1/6/4/7/155368.attach::hudTick()
L 06/10/2016 - 13:13:34: [SM] Native "IsPlayerAlive" reported: Client 4 is not in game

The Client * number can be also 5 or 6

sdz
06-10-2016, 07:39
HI EasSidezz

thx for that.

But i found these in the error logs since running the plugin

L 06/10/2016 - 13:13:34: [SM] [0] Line 29, /home/forums/content/files/1/7/1/6/4/7/155368.attach::hudTick()
L 06/10/2016 - 13:13:34: [SM] Native "IsPlayerAlive" reported: Client 4 is not in gameThe Client * number can be also 5 or 6

Yes my friend sorry, I forgot to add the checks in the loops. This should work.

xines
06-10-2016, 07:52
Yes my friend sorry, I forgot to add the checks in the loops. This should work.

Updated this abit hope that's okay.
Also removed hint text, as this will result in a "sound" each loop, annoying as you can imagine.
For information Hudtext works totally fine at CSS and for further scripts do not check if client isconnected when you also check if they're ingame, as the isconnected check is a waste of cpu because a ingame client is always a connected client, but a connected client is not always a ingame client :bee:

Rest of the edits you can see below lol :up:

#include <sourcemod>
#include <cstrike>

public Plugin myinfo =
{
name = "Show last alive on HUD",
author = "Sidezz",
description = "",
version = "1.0",
url = "http://www.coldcommunity.com"
}

public void OnClientPostAdminCheck(int client)
{
CreateTimer(1.0, hudTick, client, TIMER_REPEAT);
}

public Action hudTick(Handle timer, any client)
{
if(!IsClientInGame(client))
{
KillTimer(timer);
return Plugin_Handled;
}

char text[512], tAlive, ctAlive;
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsPlayerAlive(i))
{
switch(GetClientTeam(i))
{
case CS_TEAM_CT: ctAlive++;
case CS_TEAM_T: tAlive++;
}
}
}

if(tAlive > 1)
{
Format(text, sizeof(text), "Terrorists Alive: %i", tAlive);
}
else if(tAlive == 1)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_T)
{
Format(text, sizeof(text), "Last Terrorist: %N", i);
}
}
}

if(ctAlive > 1)
{
Format(text, sizeof(text), "%s\nCounter-Terrorists Alive: %i", text, ctAlive);
}
else if(ctAlive == 1)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT)
{
Format(text, sizeof(text), "%s\nLast Counter-Terrorist: %N", text, i);
}
}
}

SetHudTextParams(-1.0, 0.865, 1.0, 255, 255, 255, 255, 0, 6.0, 0.1, 0.2);
ShowHudText(client, -1, text);
return Plugin_Handled;
}

sdz
06-10-2016, 08:00
Learn something new every day eh?

stoneyschillhouse
06-10-2016, 08:09
wow thx guys

thanks guys thats awesome.

but is there a simple way to turn it on / off for clientside ?

like !alive chatcommand ?

xines
06-10-2016, 08:21
Learn something new every day eh?

Hehe, indeed. 8)

sdz
06-10-2016, 08:35
wow thx guys

thanks guys thats awesome.

but is there a simple way to turn it on / off for clientside ?

like !alive chatcommand ?

Yeah, I'll make you the command with edits xines has implemented as well
Edit: attached.

stoneyschillhouse
06-10-2016, 09:03
its unbelievable.

BIG THANKS :-)

stoneyschillhouse
06-16-2016, 04:38
Hi

sorry but
is it possible to save the option on/off for each player ?

at the moment you must turn it off after mapchange.

Arkarr
06-16-2016, 08:07
Hi

sorry but
is it possible to save the option on/off for each player ?

at the moment you must turn it off after mapchange.
Take a look at cookies :3 !

xines
06-16-2016, 11:32
Take a look at cookies :3 !

Well bro, remember this is a request thread and not the scripting one, sooo hes asking us to do it :bee:


Anyway here is what i put together there may or may not be flaws or code that can be optimized, but give it a try:

Arkarr
06-16-2016, 12:20
Well bro, remember this is a request thread and not the scripting one, sooo hes asking us to do it :bee:


Anyway here is what i put together there may or may not be flaws or code that can be optimized, but give it a try:
Right. But maybe if people where a bit curious they could learn by themself and share great stuff too :3 !

xines
06-16-2016, 13:10
Right. But maybe if people where a bit curious they could learn by themself and share great stuff too :3 !

Indeed, but sadly thats rare :P

Everything needs to be so priv priv private :lol::lol:

stoneyschillhouse
06-16-2016, 15:14
thx xines

it works!

I would love to learn it but I do not know how to start, because my English is not so good, the English tutorials are very hard for me.

If a German speaking would find would teach me or would help to least would be great