Raised This Month: $32 Target: $400
 8% 

Help checking for bots in this plugin (alive players hud)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 12-20-2020 , 19:14   Help checking for bots in this plugin (alive players hud)
Reply With Quote #1

Hello

This is a code from @napoleon_be.

can anyone help me adding bot support? currently it only check for alive humans players at least ingame.

Also make it possible to show a DHUD message instead.

i'm using condition zero bots.


The code:

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

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

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


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    set_task(0.5, "ShowPlayers")
}

public ShowPlayers() {
    new players[32], inum, tplayers, ctplayers, talive, ctalive
    get_players(players, inum)
    
    for(new i; i < inum; i++) {
        switch(cs_get_user_team(players[i])) {
            case CS_TEAM_CT: {
                ctplayers++
                if(is_user_alive(players[i]))
	      
		
		{
                    ctalive++
		    
                }
            }
            
            case CS_TEAM_T: {
                tplayers++
                
                if(is_user_alive(players[i])) {
                    talive++
                }
            }
        }
        set_hudmessage(random(255), random(255), random(255), -1.0, 0.0, 0, 0.0, 2.0, 0.1, 0.2, -1)
        show_hudmessage(players[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i", talive, tplayers, ctalive, ctplayers)
    }
    set_task(1.0, "ShowPlayers")
}  
Thanks people.
Ark_Procession is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-21-2020 , 15:24   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #2

Where did u get this code from? And i can't see the problem why it's not showing the bots for you. This also might need to be rewritten though as this is not how it should be done by using get_players().

EDIT: In the meantime, i rewrote this code, but it's untested though.

PHP 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(PLUGINVERSIONAUTHOR);
}

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] == && task_exists(MSGID))
    {
        
remove_task(MSGID);
    }
}

public 
displayMessage()
{
    if(
task_exists(MSGID))
    {
        new 
iPlayers[MAX_PLAYERS], iNum;

        
get_players(iPlayersiNum"e""TERRORIST");
        
iInfo[iTerPlayers] = iNum;

        
get_players(iPlayersiNum"ae""TERRORIST");
        
iInfo[iTerAlive] = iNum;

        
get_players(iPlayersiNum"e""CT");
        
iInfo[iCtPlayers] = iNum;

        
get_players(iPlayersiNum"ae""CT");
        
iInfo[iCtAlive] = iNum;

        
get_players(iPlayersiNum);

        for(new 
iiNumi++)
        {
            
set_hudmessage(random(255), random(255), random(255), -1.00.000.01.10.10.2, -1);
            
show_hudmessage(iPlayers[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i",
                              
iInfo[iTerAlive], iInfo[iTerPlayers],
                              
iInfo[iCtAlive], iInfo[iCtPlayers]);
        }
        
set_task(1.0"displayMessage"MSGID);
    }

__________________

Last edited by Napoleon_be; 12-21-2020 at 16:00.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 12-21-2020 , 22:21   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
Where did u get this code from? And i can't see the problem why it's not showing the bots for you. This also might need to be rewritten though as this is not how it should be done by using get_players().

EDIT: In the meantime, i rewrote this code, but it's untested though. [/php]
I saw the code in some post i can't remember now, but you wrote it as far as i remember.

will test it! thanks

Last edited by Ark_Procession; 12-22-2020 at 11:44.
Ark_Procession is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 12-21-2020 , 22:37   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #4

It works perfectly! thanks
Ark_Procession is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-22-2020 , 13:18   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #5

Quote:
Originally Posted by Ark_Procession View Post
It works perfectly! thanks
Lol i'm actually surprised by that.

Just one thing, if anyone has a suggestion on how to get rid of those multiple get_players() calls, please lmk. It's kind of ugly this way.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-22-2020 , 13:41   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
Lol i'm actually surprised by that.

Just one thing, if anyone has a suggestion on how to get rid of those multiple get_players() calls, please lmk. It's kind of ugly this way.
Not tested.

PHP Code:
stock GetPlayersTeamNum(CsTeams:Teambool:alive)
{
    new 
iPlayers[MAX_PLAYERS ], iNum;
    
get_players(iPlayersiNumalive "ae" "e"Team == CS_TEAM_CT "CT" "TERRORIST");
    return 
iNum;

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(random(255), random(255), random(255), -1.0, 0.0, 0, 0.0, 1.1, 0.1, 0.2, -1);
        show_hudmessage(0, "Terrorists: %i/%i | Counter-Terrorists: %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;
}
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 12-22-2020 at 14:23.
iceeedr is offline
Send a message via Skype™ to iceeedr
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-22-2020 , 15:43   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #7

thanks @ iceeedr, should work by the looks of it, thanks for the optimization.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 12-22-2020 , 16:23   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #8

Quote:
Originally Posted by iceeedr View Post
Not tested.

PHP Code:
stock GetPlayersTeamNum(CsTeams:Teambool:alive)
{
    new 
iPlayers[MAX_PLAYERS ], iNum;
    
get_players(iPlayersiNumalive "ae" "e"Team == CS_TEAM_CT "CT" "TERRORIST");
    return 
iNum;

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(random(255), random(255), random(255), -1.0, 0.0, 0, 0.0, 1.1, 0.1, 0.2, -1);
        show_hudmessage(0, "Terrorists: %i/%i | Counter-Terrorists: %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;
}
Hi, appreciate the extra help! two wonderful modders! thanks to both.

you forgot to add

HTML Code:
#include <cstrike>
for CS_TEAM_T/CT.

adding it compiles perfectly, without it throws 5 errors.

also works perfectly
Ark_Procession is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-22-2020 , 17:52   Re: Help checking for bots in this plugin (alive players hud)
Reply With Quote #9

You're right, I compiled on amxx 1.10 and it didn't show any warn or error so I didn't even notice the lack of the include, how strange!
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Reply


Thread Tools
Display Modes

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 07:04.


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