Raised This Month: $ Target: $400
 0% 

[REQ] Hud Msg for alive players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 03-17-2011 , 18:43   [REQ] Hud Msg for alive players
Reply With Quote #1

Can anyone make or show me a plugin that shows the amount of:

Terrorists:
Counter-Terrorists:

in a (any color) hud message at the top center of the screen..

Only alive players so if a t dies and there was Terrorists: 8 it would be Terrorists: 7
__________________
Ayyylmao
malec321 is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 03-18-2011 , 05:19   Re: [REQ] Hud Msg for alive players
Reply With Quote #2

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_SyncTeamCount
new g_iMaxPlayers

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

public 
client_putinserver(id)
{
    
ClearBits(g_bitAliveid)
}

public 
client_disconnect(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
                    
            
}
        }
    }
    
set_hudmessage(255500, -1.00.04__2.0_,  _1)
    
ShowSyncHudMsg(0g_SyncTeamCount"[Alive T: %d] - [Alive CT: %d]"iPlayerTrroNumiPlayerCtNum)

__________________

Last edited by vato loco [GE-S]; 03-18-2011 at 05:49.
vato loco [GE-S] is offline
nikolov
Senior Member
Join Date: Feb 2011
Old 03-18-2011 , 08:01   Re: [REQ] Hud Msg for alive players
Reply With Quote #3

Quote:
Originally Posted by vato loco [GE-S] View Post
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_SyncTeamCount
new g_iMaxPlayers

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

public 
client_putinserver(id)
{
    
ClearBits(g_bitAliveid)
}

public 
client_disconnect(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
                    
            
}
        }
    }
    
set_hudmessage(255500, -1.00.04__2.0_,  _1)
    
ShowSyncHudMsg(0g_SyncTeamCount"[Alive T: %d] - [Alive CT: %d]"iPlayerTrroNumiPlayerCtNum)

It works, but can you add 2 hud messages :
1. T - with red color in left
2. CT - with blue color in right

and only alive players can see it this...
nikolov is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 03-18-2011 , 10:06   Re: [REQ] Hud Msg for alive players
Reply With Quote #4

here T Red Ct Blue and only alive player see the msg
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_disconnect(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"[Alive T: %d]"255000.451iPlayerTrroNum)
            
ShowCustomSync(idg_SyncTeam2"[Alive CT: %d]"002550.552iPlayerCtNum)
        }
    }
}

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

__________________

Last edited by vato loco [GE-S]; 03-18-2011 at 10:33.
vato loco [GE-S] is offline
nikolov
Senior Member
Join Date: Feb 2011
Old 03-18-2011 , 11:10   Re: [REQ] Hud Msg for alive players
Reply With Quote #5

Quote:
Originally Posted by vato loco [GE-S] View Post
here T Red Ct Blue and only alive player see the msg
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_disconnect(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"[Alive T: %d]"255000.451iPlayerTrroNum)
            
ShowCustomSync(idg_SyncTeam2"[Alive CT: %d]"002550.552iPlayerCtNum)
        }
    }
}

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


Works great, but can you tell me - How do I edit where to find (hud's)
I want T - Left / Centered and CT - Right / Centered
nikolov is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 03-18-2011 , 11:19   Re: [REQ] Hud Msg for alive players
Reply With Quote #6

http://www.amxmodx.org/funcwiki.php?go=func&id=28
__________________
vato loco [GE-S] is offline
Old 04-29-2023, 12:52
MAJESTIC_SZ
This message has been deleted by MAJESTIC_SZ. Reason: solved
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 #8

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 #9

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
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 #10

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 10:22.


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