AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Server Players (https://forums.alliedmods.net/showthread.php?t=334008)

feren02 08-23-2021 00:23

Server Players
 
Hi good day!

Hope everyone is coping during the pandemic times.

I was wondering if this would matter:

***I run latest YapB in my server and I want to add and kick bots every X***

1. (could be every certain rounds - e.g. every 7th, 15th, 28th round)
2. (could be every X server running time - e.g. every 7 mins or every 15 mins.)
3. (can be modified how many bots are kicked and how many bots are added during X)

Is this possible?

Tried doing these:

PHP Code:

#include <amxmodx>
#include <cstrike>

#define PLUGIN  "addkick"
#define VERSION "1.0"
#define AUTHOR  "nobody"

#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
{
    if( 
get_user_teamid ) == )
        
iInfoiCtPlayers ]--
    else if( 
get_user_teamid ) == )
        
iInfoiTerPlayers ]--

    if(
iInfoiCtPlayers ] + iInfoiTerPlayers ] == )
    {
        
remove_task(MSGID);
        
server_cmd("yb kick");
    }


-- in the 1st script above, my trial goal is to kick a bot when ct / t players are equivalent to 8 players combined. However nothing happens. What can be the problem?


------------------------------------------------------------


PHP Code:

#include < amxmodx >
#include < cstrike >
#include < fakemeta >

#define PLUGIN  "AddKick"
#define VERSION "1.0"
#define AUTHOR  "nobody"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
New_Roundid 

    static 
iRoundCount 
    
++iRoundCount 
     
    
if(iRoundCount == 2)        // Restart on the 2nd round 
    

        
//iRoundCount = 0 
        
server_cmd("yb kick")
        
server_cmd("yb kick")
        
server_cmd("yb kick")
    } 



public 
New_Round2id 

    static 
iRoundCount 
    
++iRoundCount 
     
    
if(iRoundCount == 15)        // Restart on the 15th round 
    

        
iRoundCount 
        server_cmd
("yb add 4 1 5")
    } 


public 
New_Round3id 

    static 
iRoundCount 
    
++iRoundCount 
     
    
if(iRoundCount == 18)        // Restart on the 18th round 
    

        
iRoundCount 
        server_cmd
("yb add 4 1 5")
        
server_cmd("yb add 4 1 5")
        
server_cmd("yb add 4 1 5")
    } 


public 
New_Round4id 

    static 
iRoundCount 
    
++iRoundCount 
     
    
if(iRoundCount == 21)        // Restart on the 21st round 
    

        
iRoundCount 
        server_cmd
("yb kick")
        
server_cmd("yb kick")
    } 


public 
New_Round5id 

    static 
iRoundCount 
    
++iRoundCount 
     
    
if(iRoundCount == 24)        // Restart on the 24th round 
    

        
iRoundCount 
        server_cmd
("yb kick")
    } 


-- in the 2nd script I am doing, it aims to add or kick bots during X rounds, which is more easier. But still nothing happens in-game. What do I lack?



LOOKING FORWARD! Thank you! :)

Napoleon_be 08-23-2021 04:03

Re: Server Players
 
Perhaps u wanna share the original code of the first plugin you're using? It looks like a code i wrote a while ago, but shit's missing. You're never increasing iCtPlayers & iTerPlayers, so their value will always be 0.

feren02 08-23-2021 20:56

Re: Server Players
 
Quote:

Originally Posted by Napoleon_be (Post 2755937)
Perhaps u wanna share the original code of the first plugin you're using? It looks like a code i wrote a while ago, but shit's missing. You're never increasing iCtPlayers & iTerPlayers, so their value will always be 0.

Hi sure, this is the script I used which was posted in the SCRIPTING HELP section. Thanks! Can you help me? And also on the script I posted per x ROUNDS to add or kick bots? Looking forward.


PHP Code:

#include <amxmodx>
#include <cstrike>

#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
{
    if( 
get_user_teamid ) == )
        
iInfoiCtPlayers ]--
    else if( 
get_user_teamid ) == )
        
iInfoiTerPlayers ]--

    if(
iInfoiCtPlayers ] + iInfoiTerPlayers ] == )
    {
        
remove_task(MSGID);
        
server_cmd("restart");
    }
}

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(25515550, -1.00.000.01.10.10.23);            
            
//set_hudmessage(random(255), random(255), random(255), -1.0, 0.0, 0, 0.0, 1.1, 0.1, 0.2, -1);
            
show_hudmessage(iPlayers[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i",
                              
iInfo[iTerAlive], iInfo[iTerPlayers],
                              
iInfo[iCtAlive], iInfo[iCtPlayers]);
        }
        
set_task(1.1"displayMessage"MSGID);
    }



Napoleon_be 08-23-2021 21:49

Re: Server Players
 
It's actually really simple.

PHP Code:

#include <amxmodx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new const iPlayersReq 8;

new 
g_iTotalPlayers;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
client_putinserver(id)
{
    if(++
g_iTotalPlayers == iPlayersReq)
    {
        
server_cmd("yb kick");
    }


PHP Code:

#include <amxmodx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new g_iRoundNum;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_event("HLTV""newRound""a""1=0""2=0");
    
register_event("TextMsg""commenceRestart""a""2&#Game_C""2&#Game_w");
}

public 
newRound()
{
    switch(++
g_iRoundNum// g_iRoundNum is increased at this point.
    
{
        case 
2
        {
            for(new 
i2i++)
            {
                
server_cmd("yb kick");
                
log_amx("Bot # %i kicked."i);
            }
        }
        case 
15
        {
            
server_cmd("yb add 4 1 5");
            
server_cmd("sv_restart 1");

            
log_amx("Round %i."g_iRoundNum);

            
commenceRestart(); // g_iRoundNum is reset to 0, we're having a new round.

        
}
    }
}

public 
commenceRestart()
{
    
g_iRoundNum 0;
    
log_amx("Variable succesfuly reset.");



feren02 08-23-2021 22:26

Re: Server Players
 
Quote:

Originally Posted by Napoleon_be (Post 2756018)
It's actually really simple.

PHP Code:

#include <amxmodx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new const iPlayersReq 8;

new 
g_iTotalPlayers;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
client_putinserver(id)
{
    if(++
g_iTotalPlayers == iPlayersReq)
    {
        
server_cmd("yb kick");
    }


PHP Code:

#include <amxmodx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new g_iRoundNum;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_event("HLTV""newRound""a""1=0""2=0");
}

public 
newRound()
{
    switch(++
g_iRoundNum)
    {
        case 
2
        {
            for(new 
i2i++)
            {
                
server_cmd("yb kick");
            }
        }
        case 
15
        {
            
server_cmd("yb add 4 1 5");
            
server_cmd("sv_restart 1");
            
g_iRoundNum 0;
        }
    }




Let me try these. Will get back what happens soonest. Thank you for giving out our time.

Natsheh 08-24-2021 00:42

Re: Server Players
 
You should've reset the variable g_iRoundNum on game commencing and on round restart. ( g_iRoundNum = 0 )

feren02 08-24-2021 01:22

Re: Server Players
 
Quote:

Originally Posted by Natsheh (Post 2756031)
You should've reset the variable g_iRoundNum on game commencing and on round restart. ( g_iRoundNum = 0 )

What does this mean?

Natsheh 08-24-2021 01:30

Re: Server Players
 
Quote:

Originally Posted by feren02 (Post 2756034)
What does this mean?


PHP Code:

public plugin_init()
{
   
register_event("TextMsg""commence_restart_event""a""2=#Game_Commencing""2=#Game_will_restart_in");
}

public 
commence_restart_event()
{
   
g_iRoundNum 0;



feren02 08-24-2021 01:37

Re: Server Players
 
Quote:

Originally Posted by Natsheh (Post 2756035)
PHP Code:

public plugin_init()
{
   
register_event("TextMsg""commence_restart_event""a""2=#Game_Commencing""2=#Game_will_restart_in");
}

public 
commence_restart_event()
{
   
g_iRoundNum 0;



Yep meaning it will not add or kick when game commences?

feren02 08-24-2021 03:46

Re: Server Players
 
Quote:

Originally Posted by feren02 (Post 2756024)
Let me try these. Will get back what happens soonest. Thank you for giving out our time.

I initially tried the add and kick based on X Rounds. Nothing is happening in-game.

Compilation good. No errors in debug. It's just that nothing happens no bots are added.


All times are GMT -4. The time now is 02:17.

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