Raised This Month: $51 Target: $400
 12% 

[REQ] Hud Msg for alive players


Post New Thread Reply   
 
Thread Tools Display Modes
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 03-20-2011 , 05:37   Re: [REQ] Hud Msg for alive players
Reply With Quote #11

Quote:
Originally Posted by malec321 View Post
Thanks a lot guys!
which guys !?

you're welcome
__________________
vato loco [GE-S] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-20-2011 , 06:15   Re: [REQ] Hud Msg for alive players
Reply With Quote #12

Would be preferable to use get_players.

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN  "Alive Player"
#define VERSION "1.0"
#define AUTHOR  "vato loco [GE-S]"

#define TASK_GETPLAYER    37852
#define TASK_LOOP_TIME    2.0

new g_SyncTeamCount

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
state OutOfRound

    g_SyncTeamCount 
CreateHudSyncObj()

    
register_logevent("LogEvent_Round_Start"2"1=Round_Start")
    
register_logevent("Logevent_Round_End"2"1=Round_End")

    
RegisterHam(Ham_Spawn"player""client_disconnect"true)
    
RegisterHam(Ham_Killed"player""client_disconnect"true)
}

public 
client_disconnect() <OutOfRound> {}
public 
client_disconnect() <InRound>
{
    
GetPlayers()
}

public 
LogEvent_Round_Start()
{
    
state InRound
    remove_task
TASK_GETPLAYER )
    
set_task(TASK_LOOP_TIME"GetPlayers"TASK_GETPLAYER, .flags="b")
}

public 
Logevent_Round_End()
{
    
state OutOfRound
    remove_task
TASK_GETPLAYER )
}

public 
GetPlayers()
{
    new 
iPlayers[32], iNumiTnumiCTnum
    get_players
(iPlayersiNum"a")
    for(--
iNumiNum>=0iNum--)
    {
        switch( 
cs_get_user_teamiPlayers[iNum] ) )
        {
            case 
CS_TEAM_T:++iTnum
            
case CS_TEAM_CT:++iCTnum
        
}
    }

    
set_hudmessage(255500, -1.00.04__TASK_LOOP_TIME+0.01_,  _1)
    
ShowSyncHudMsg(0g_SyncTeamCount"[Alive T: %d] - [Alive CT: %d]"iTnumiCTnum)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 03-20-2011 , 17:21   Re: [REQ] Hud Msg for alive players
Reply With Quote #13

Quote:
Originally Posted by vato loco [GE-S] View Post
which guys !?

you're welcome
You Thanks
__________________
Ayyylmao
malec321 is offline
blacktample
Junior Member
Join Date: May 2010
Old 10-23-2011 , 07:40   Re: [REQ] Hud Msg for alive players
Reply With Quote #14

Quote:
Originally Posted by ConnorMcLeod View Post
Would be preferable to use get_players.

PHP Code:
//code... 
PHP Code:
if(iTnum == 1)
{
ShowSyncHudMsg(0g_SyncTeamCount"Alive hiders: Only one!! || Alive seekers: %d"iCTnum)
}
else if(
iTnum == || iCTnum == 1)
{
ShowSyncHudMsg(0g_SyncTeamCount"[ 1 vs 1 ]")
}
else
{
ShowSyncHudMsg(0g_SyncTeamCount"Alive hiders: %d || Alive seekers: %d"iTnumiCTnum)

how to code 1 vs 1
__________________
PHP, HTML, CSS, JS !!

Last edited by blacktample; 10-24-2011 at 13:02.
blacktample is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 10-23-2011 , 16:46   Re: [REQ] Hud Msg for alive players
Reply With Quote #15

@ConnorMcLeod, will do it [Alive T: %d] in red color and [Alive CT: %d] in blue.
Lolz0r is offline
Old 04-29-2023, 12:52
MAJESTIC_SZ
This message has been deleted by MAJESTIC_SZ. Reason: solved
Old 04-29-2023, 13:15
MAJESTIC_SZ
This message has been deleted by MAJESTIC_SZ.
MAJESTIC_SZ
Senior Member
Join Date: Mar 2020
Location: Portugal
Old 04-29-2023 , 15:33   Re: [REQ] Hud Msg for alive players
Reply With Quote #16

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>

#define PLUGIN  "Alive Player"
#define VERSION "1.0"
#define AUTHOR  "vato loco [GE-S]"

#define TASK_GETPLAYER     37852
#define SetBits(%1,%2)       %1 |= 1<<(%2 & 31)
#define ClearBits(%1,%2)   %1 &= ~(1<<(%2 & 31))
#define GetBits(%1,%2)       %1 &  1<<(%2 & 31)

new g_bitAlive
new g_SyncTeam1
new g_SyncTeam2
new g_iMaxPlayers

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn"1)
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled"1)
    
    
g_SyncTeam1 CreateHudSyncObj()
    
g_SyncTeam2 CreateHudSyncObj()
    
g_iMaxPlayers get_maxplayers()
    
    
set_task(0.5"GetPlayer"TASK_GETPLAYER__"b")
}

public 
client_putinserver(id)
{
    
ClearBits(g_bitAliveid)
}

public 
client_disconnected(id)
{
    
ClearBits(g_bitAliveid)
}

public 
fw_PlayerSpawn(id)
{
    if(
is_user_alive(id))
    {
        
SetBits(g_bitAliveid)
    }
}

public 
fw_PlayerKilled(id)
{
    
ClearBits(g_bitAliveid)
}

public 
GetPlayer()
{
    static 
idiTeam
    
new iPlayerTrroNumiPlayerCtNum
    
    
for(id 1id <= g_iMaxPlayersid++)
    {
        if(
GetBits(g_bitAliveid))
        {
            
iTeam get_user_team(id)
            
            switch(
iTeam)
            {
                case 
1: ++iPlayerTrroNum
                    
                
case 2: ++iPlayerCtNum
                    
            
}
            
ShowCustomSync(idg_SyncTeam1"TE vivos: %d"255000.011iPlayerTrroNum)
            
ShowCustomSync(idg_SyncTeam2"^nCT vivos: %d"01002550.012iPlayerCtNum)
        }
    }
}

ShowCustomSync(idSyncTypeMsg[], RedGreenBlueFloat:xPosChannelTeamCount
{
    
set_hudmessage(RedGreenBluexPos0.14__2.0_,  _Channel)
    
ShowSyncHudMsg(idSyncTypeMsgTeamCount)

Hello 12 years later
The code wrote by ConnorMcLeod is not working properly for me.
I have edited line 75 so the plugin shows 2 separated messages, 1 on each line.
But the plugin is not counting players as it should.
Example:
We are 20 on server, 10 vs 10.
Plugin shows 8 vs 7.
Some times we are 9 vs 8.
The plugin shows 5 vs 5.
Or like the image below:


Or any other amounts.
What can it be?
I compiled it using the latest amx 10.
I use rehlds, regame, amx10 and metamod-r.

Thank you.

Last edited by MAJESTIC_SZ; 04-29-2023 at 15:42.
MAJESTIC_SZ is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 04-29-2023 , 19:21   Re: [REQ] Hud Msg for alive players
Reply With Quote #17

Pai sapo?
Btw, the code seems ok. It should work perfectly if you use default amxmodx. Since you running rehlds and other stuff i have no idea what kind of impact it can have on plugin’s performance.

Edit:
Try with get_players, flags ae, will instantly give you the count per team. Maybe this way it works
__________________

Last edited by Jhob94; 04-29-2023 at 19:33.
Jhob94 is offline
MAJESTIC_SZ
Senior Member
Join Date: Mar 2020
Location: Portugal
Old 04-30-2023 , 07:25   Re: [REQ] Hud Msg for alive players
Reply With Quote #18

Quote:
Originally Posted by Jhob94 View Post
Pai sapo?
Btw, the code seems ok. It should work perfectly if you use default amxmodx. Since you running rehlds and other stuff i have no idea what kind of impact it can have on plugin’s performance.

Edit:
Try with get_players, flags ae, will instantly give you the count per team. Maybe this way it works
Thank you for your answer!
I don't really know how to code, i can edit somethings only...
Where do i edit that? Here?
PHP Code:
set_task(0.5"GetPlayer"TASK_GETPLAYER__"b"
to:
PHP Code:
set_task(0.5"GetPlayers"TASK_GETPLAYERS__"ae"
?

Another thing i noticed is the hud info is not permanently shown on screen. It fades away and then comes back, this happens randomly, but since the purpose is to help alive players, it should be permanent.

Last edited by MAJESTIC_SZ; 04-30-2023 at 07:39.
MAJESTIC_SZ is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 05-02-2023 , 16:36   Re: [REQ] Hud Msg for alive players
Reply With Quote #19

This will accurately count and display in team colors. Green for hostages.
PHP Code:
/*Spin-off idea derived from request by malec321*/
#include <amxmodx>
#include <engine_stocks>
#include <fakemeta>

#define PLUGIN  "!Alive"
#define VERSION "1.0.1"
#define AUTHOR  "SPiNX | vato loco [GE-S]"

#define TASK_GETPLAYER    37852
#define TASK_LOOP_TIME    1.0

#define SetBits(%1,%2)       %1 |=   1<<(%2 & 31)
#define ClearBits(%1,%2)     %1 &= ~(1<<(%2 & 31))
#define GetBits(%1,%2)       %1 &    1<<(%2 & 31)

#if !defined client_disconnect
#define client_disconnected client_disconnect
#endif

#define charsmin -1

new g_AIg_cvar_contg_continuousg_rescue
static g_Hostie

static g_SyncTeamCount_CT,  g_SyncTeamCount_Hg_SyncTeamCount_T

new const szEnt[] = "hostage_entity"
new const szRescue[] = "2=Rescued_A_Hostage"
new const CvarDesc[] = "Show who is alive as round ends. 2 is debugger."

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
g_SyncTeamCount_CT CreateHudSyncObj()
    
g_SyncTeamCount_H CreateHudSyncObj()
    
g_SyncTeamCount_T CreateHudSyncObj()

    
register_logevent("@rescue"3szRescue)
    
register_logevent("@LogEvent_Round_Start"2"1=Round_Start")
    
g_continuous register_logevent("@Logevent_Round_End"2"1=Round_End")
    
bind_pcvar_num(create_cvar("continuous_player_alive""0",FCVAR_SERVERCvarDesc,.has_min true, .min_val 0.0, .has_max true, .max_val 2.0), g_cvar_cont)
    
g_Hostie has_map_ent_class(szEnt) ? 0
    state OFF
}

@
rescue()
    ++
g_rescue

@LogEvent_Round_Start()
{
    
g_rescue 0
    state ON
    
@solid_state()

    
g_cvar_cont disable_logevent(g_continuous) : enable_logevent(g_continuous)
}

@
Logevent_Round_End()
    @
solid_state()

public 
client_putinserver(id)
{
    if(
is_user_connected(id) && is_user_bot(id))
    {
        
SetBits(g_AIid)
    }
}

public 
client_disconnected(id)
    
ClearBits(g_AIid)

@
solid_state()<ON>{set_task(TASK_LOOP_TIME"@GetPlayers"TASK_GETPLAYER, .flags="b");if(g_cvar_cont>1)server_print("%s is on..."PLUGIN);}

@
solid_state()<OFF>{remove_taskTASK_GETPLAYER );if(g_cvar_cont>1)server_print("%s is off.."PLUGIN);}

@
GetPlayers()
{
    new
    
ALIVE,
    
R,G,Bid,
    
Float:XFloat:Y,
    
iPlayers[MAX_PLAYERS], iNumiTnumiCTnum;

    
get_players(iPlayersiNum"a")

    if(
iNum)
    {
        for(new 
ALIVEALIVE iNum; ++ALIVE)
        {
            switch( 
get_user_teamiPlayers[ALIVE] ) )
            {
                case 
1: ++iTnum
                
case 2: ++iCTnum
            
}
        }

        
id iPlayers[ALIVE]

        if(
iTnum && iCTnum)
        {
            if(~
GetBits(g_AIid))
            {
                
2550.391;
                
set_hudmessage(RGBXY__TASK_LOOP_TIME+0.01_,  _1)

                
ShowSyncHudMsg(idg_SyncTeamCount_T"[Alive T: %d]"iTnum)

                
0255=0.54;
                
set_hudmessage(RGBXY__TASK_LOOP_TIME+0.01_,  _1)

                
ShowSyncHudMsg(idg_SyncTeamCount_CT"[Alive CT: %d]"iCTnum)
                if(
g_Hostie)
                {
                    
2550=0.462;
                    
set_hudmessage(RGBXY__TASK_LOOP_TIME+0.01_,  _1)
                    new 
iHostage,  Is_Hostage_aliveiHostie_count
                    
while ((iHostage find_ent(iHostage szEnt)) > 0)
                    {
                        
Is_Hostage_alive pev(iHostagepev_health)
                        if(
Is_Hostage_alive)
                            
iHostie_count++
                    }
                    
ShowSyncHudMsg(idg_SyncTeamCount_H"[Hostages: %d]"iHostie_count-g_rescue)
                }
            }
        }
state OFF
    
}state OFF

__________________

Last edited by DJEarthQuake; 05-02-2023 at 16:37. Reason: URL
DJEarthQuake is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 05-06-2023 , 22:24   Re: [REQ] Hud Msg for alive players
Reply With Quote #20

Quote:
Originally Posted by MAJESTIC_SZ View Post
Thank you for your answer!
I don't really know how to code, i can edit somethings only...
Where do i edit that? Here?
PHP Code:
set_task(0.5"GetPlayer"TASK_GETPLAYER__"b"
to:
PHP Code:
set_task(0.5"GetPlayers"TASK_GETPLAYERS__"ae"
?

Another thing i noticed is the hud info is not permanently shown on screen. It fades away and then comes back, this happens randomly, but since the purpose is to help alive players, it should be permanent.
this is the one i am using with dhud:
HTML Code:
/* Sublime AMXX Editor v2.2 */

#pragma semicolon 1

#include <amxmodx>

#define PLUGIN  "Show Players"
#define VERSION "1.0"
#define AUTHOR  "NapoleoN#"

#define MSGID 81045

#if !defined MAX_PLAYERS
    const MAX_PLAYERS = 32;
#endif

enum _:ePlayerInfo
{
    iTotalPlayers,
    iCtPlayers,
    iCtAlive,
    iTerPlayers,
    iTerAlive
};

new iInfo[ePlayerInfo];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
}

public client_putinserver(id)
{
    iInfo[iTotalPlayers]++;

    if(!task_exists(MSGID))
    {
        set_task(10.0, "displayMessage", MSGID);
    }
}


#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    iInfo[iTotalPlayers]--;

    if(iInfo[iTotalPlayers] == 0 && task_exists(MSGID))
    {
        remove_task(MSGID);
    }
}

public displayMessage()
{
    if(task_exists(MSGID))
    {
        iInfo[iTerPlayers] = GetPlayersTeamNum(CS_TEAM_T, false);

        iInfo[iTerAlive] = GetPlayersTeamNum(CS_TEAM_T, true);

        iInfo[iCtPlayers] = GetPlayersTeamNum(CS_TEAM_CT, false);

        iInfo[iCtAlive] = GetPlayersTeamNum(CS_TEAM_CT, true);

        set_hudmessage(255, 100, 0, -1.0, 0.0, 0, 0.0, 1.1, 0.1, 0.2, -1);
        show_dhudmessage(0, "T: %i/%i | CT: %i/%i", iInfo[iTerAlive], iInfo[iTerPlayers], iInfo[iCtAlive], iInfo[iCtPlayers]);

        set_task(1.0, "displayMessage", MSGID);
    }
}

stock GetPlayersTeamNum(CsTeams:Team, bool:alive)
{
    new iPlayers[MAX_PLAYERS], iNum;
    get_players(iPlayers, iNum, alive ? "ae" : "e", Team == CS_TEAM_CT ? "CT" : "TERRORIST");
    return iNum;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Last edited by Ark_Procession; 05-06-2023 at 22:24.
Ark_Procession is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode