Raised This Month: $ Target: $400
 0% 

Trying to make simple plugin to kick HLTV if server is full


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-05-2013 , 14:02   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #1

Quote:
Originally Posted by Backstabnoob View Post
What? You don't understand how get_players works. It returns a list of all players who pass a certain condition. Your "system" has A LOT MORE checks, useless calls (why would you even call a kick hltv client function when you can do it directly in the loop which checks for the hltv clients?) resulting in another loop, instead of caching get_maxplayers return value into a global variable you cache it three times, once for each function which is useless and results in more native calls.

get_players is ONE native call, your method uses 195 native calls assuming there's 32 players on the server and the hltv client is the last one.
he knows better than you ...
TheDS1337 is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-05-2013 , 14:19   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #2

Quote:
Originally Posted by DeagLe.Studio View Post
he knows better than you ...
Are you even serious? If you have nothing important to say then do yourself the favor and stop embarrassing yourself.
Backstabnoob is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 06-05-2013 , 15:40   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #3

Quote:
Originally Posted by Backstabnoob View Post
What? You don't understand how get_players works. It returns a list of all players who pass a certain condition. Your "system" has A LOT MORE checks
Aberrations.

PHP Code:
static cell AMX_NATIVE_CALL get_players(AMX *amxcell *params/* 4 param */
{
    
int iNum 0;
    
int ilen;
    
charsptemp get_amxstring(amxparams[3], 0ilen);
    
int flags UTIL_ReadFlags(sptemp);

    
cell *aPlayers get_amxaddr(amxparams[1]);
    
cell *iMax get_amxaddr(amxparams[2]);

    
int team 0;

    if (
flags 48)
    {
        
sptemp get_amxstring(amxparams[4], 0ilen);

        if (
flags 16)
        {
            if (
flags 64)
                
team g_teamsIds.findTeamId(sptemp);
            else
                
team g_teamsIds.findTeamIdCase(sptemp);
        }
    }

    for (
int i 1<= gpGlobals->maxClients; ++i)
    {
        
CPlayerpPlayer GET_PLAYER_POINTER_I(i);
        if (
pPlayer->ingame)
        {
            if (
pPlayer->IsAlive() ? (flags 2) : (flags 1))
                continue;
            if (
pPlayer->IsBot() ? (flags 4) : (flags 8))
                continue;
            if ((
flags 16) && (pPlayer->teamId != team))
                continue;
            if ((
flags 128) && (pPlayer->pEdict->v.flags FL_PROXY))
                continue;
            if (
flags 32)
            {
                if (
flags 64)
                {
                    if (
stristr(pPlayer->name.c_str(), sptemp) == NULL)
                        continue;
                }
                else if (
strstr(pPlayer->name.c_str(), sptemp) == NULL)
                    continue;
            }
            
aPlayers[iNum++] = i;
        }
    }

    *
iMax iNum;
    
    return 
1;

__________________

Last edited by claudiuhks; 06-05-2013 at 15:40.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-05-2013 , 16:09   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #4

Quote:
Originally Posted by claudiuhks View Post
Aberrations.

PHP Code:
static cell AMX_NATIVE_CALL get_players(AMX *amxcell *params/* 4 param */
{
    
int iNum 0;
    
int ilen;
    
charsptemp get_amxstring(amxparams[3], 0ilen);
    
int flags UTIL_ReadFlags(sptemp);

    
cell *aPlayers get_amxaddr(amxparams[1]);
    
cell *iMax get_amxaddr(amxparams[2]);

    
int team 0;

    if (
flags 48)
    {
        
sptemp get_amxstring(amxparams[4], 0ilen);

        if (
flags 16)
        {
            if (
flags 64)
                
team g_teamsIds.findTeamId(sptemp);
            else
                
team g_teamsIds.findTeamIdCase(sptemp);
        }
    }

    for (
int i 1<= gpGlobals->maxClients; ++i)
    {
        
CPlayerpPlayer GET_PLAYER_POINTER_I(i);
        if (
pPlayer->ingame)
        {
            if (
pPlayer->IsAlive() ? (flags 2) : (flags 1))
                continue;
            if (
pPlayer->IsBot() ? (flags 4) : (flags 8))
                continue;
            if ((
flags 16) && (pPlayer->teamId != team))
                continue;
            if ((
flags 128) && (pPlayer->pEdict->v.flags FL_PROXY))
                continue;
            if (
flags 32)
            {
                if (
flags 64)
                {
                    if (
stristr(pPlayer->name.c_str(), sptemp) == NULL)
                        continue;
                }
                else if (
strstr(pPlayer->name.c_str(), sptemp) == NULL)
                    continue;
            }
            
aPlayers[iNum++] = i;
        }
    }

    *
iMax iNum;
    
    return 
1;

i think he never saw AMXX Source codes
TheDS1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-05-2013 , 16:13   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #5

Quote:
Originally Posted by claudiuhks View Post
Aberrations.

PHP Code:
static cell AMX_NATIVE_CALL get_players(AMX *amxcell *params/* 4 param */
{
    
int iNum 0;
    
int ilen;
    
charsptemp get_amxstring(amxparams[3], 0ilen);
    
int flags UTIL_ReadFlags(sptemp);

    
cell *aPlayers get_amxaddr(amxparams[1]);
    
cell *iMax get_amxaddr(amxparams[2]);

    
int team 0;

    if (
flags 48)
    {
        
sptemp get_amxstring(amxparams[4], 0ilen);

        if (
flags 16)
        {
            if (
flags 64)
                
team g_teamsIds.findTeamId(sptemp);
            else
                
team g_teamsIds.findTeamIdCase(sptemp);
        }
    }

    for (
int i 1<= gpGlobals->maxClients; ++i)
    {
        
CPlayerpPlayer GET_PLAYER_POINTER_I(i);
        if (
pPlayer->ingame)
        {
            if (
pPlayer->IsAlive() ? (flags 2) : (flags 1))
                continue;
            if (
pPlayer->IsBot() ? (flags 4) : (flags 8))
                continue;
            if ((
flags 16) && (pPlayer->teamId != team))
                continue;
            if ((
flags 128) && (pPlayer->pEdict->v.flags FL_PROXY))
                continue;
            if (
flags 32)
            {
                if (
flags 64)
                {
                    if (
stristr(pPlayer->name.c_str(), sptemp) == NULL)
                        continue;
                }
                else if (
strstr(pPlayer->name.c_str(), sptemp) == NULL)
                    continue;
            }
            
aPlayers[iNum++] = i;
        }
    }

    *
iMax iNum;
    
    return 
1;

The efficiency of an AMX Mod X script is not the same as the efficiency of the same code in a module (if that is what you are hint at here).
__________________
fysiks is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-05-2013 , 16:10   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #6

Not sure if this will work, but you can give it a try. I don't have an HLTV server to test it with

PHP Code:
#include <amxmodx>

#define MAX_HLTV 2

new aHLTV[MAX_HLTV];
new 
iMaxPlayers;

public 
plugin_init()
{
    
iMaxPlayers get_maxplayers();
}

public 
client_connect(id)
{
    if (
is_user_hltv(id))
    {
        for (new 
0MAX_HLTVk++)
        {
            if (
aHLTV[k] == 0)
            {
                
aHLTV[k] = id;
                break;
            }
        }
    }
}

public 
client_putinserver(id)
{
    if (
get_playersnum(1) == iMaxPlayers)
    {
        
server_cmd("kick #%d ^"Bye Bye HLTV^""get_user_userid(aHLTV[0]));
        
SortIntegers(aHLTVsizeof(aHLTV), Sort_Descending);
    }

__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-05-2013 , 16:13   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #7

Can u explain me please why the size of Hltv 2 ?
TheDS1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-05-2013 , 16:14   Re: Trying to make simple plugin to kick HLTV if server is full
Reply With Quote #8

Quote:
Originally Posted by DeagLe.Studio View Post
Can u explain me please why the size of Hltv 2 ?
Read the OP.
__________________
fysiks 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 16:25.


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