Raised This Month: $ Target: $400
 0% 

Limit CT team only for 2 players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tramp
Senior Member
Join Date: Aug 2005
Old 03-25-2008 , 08:23   Limit CT team only for 2 players
Reply With Quote #1

PHP Code:
/* Mod Template generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>


#define PLUGIN    "New Plugin"
#define VERSION    "1.0"
#define AUTHOR    "Unknown"

/* Initialization */

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("chooseteam""chooseteam");
    
// Register commands, cvars and forwards here
}

public 
client_putinserver(id)
{
    
set_task(0.1"selectteam"id);

    return 
PLUGIN_CONTINUE;
}

public 
selectteam(id)
{
    
client_cmd(id"chooseteam");
}

public 
chooseteam(id)
{

    new 
ts[32];
    new 
cts[32];
    new 
tnum;
    new 
ctnum;


    
// Get teams
    
get_players(tstnum"e""TERRORIST");
    
get_players(ctsctnum"e""CT");
    
    
//select T
    
if (ctnum >= 2)
    {
        
engclient_cmd(id"menuselect""1");
        
engclient_cmd(id"menuselect""5");
        
client_cmd(id"slot1");
    }
    
//select CT
    
else if (ctnum 2)
    {
        
engclient_cmd(id"menuselect""2");
        
engclient_cmd(id"menuselect""5");
        
client_cmd(id"slot1");
    }

    return 
PLUGIN_HANDLED;

And i have problem in 80% it is working good.
But sometimes, i dont know why person is transfered to CT but there are 2 people. o_o

Or maybe it could be write better? In all forum is how to block team totally, but theres no information how to limit team for 2 persons only :d

And my code should work, but not always :/

Maybe thats problem with ID when client is putted in server?
sometimes it is loosing ?
__________________
STER-Gaming.pl - The Best Multigaming Club, CS 1.6, CS:S, ET, COD 2 more and more ! Check forum forum.ster-gaming.pl

amxmodx - Polish support about amxx.
Tramp is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 03-25-2008 , 08:39   Re: Limit CT team only for 2 players
Reply With Quote #2

Make sure these cvars are set:
Code:
mp_autoteambalance 0
mp_limitteams 0
Sputnik53 is offline
Tramp
Senior Member
Join Date: Aug 2005
Old 03-25-2008 , 08:50   Re: Limit CT team only for 2 players
Reply With Quote #3

Hmmm it is to 0 and 0.

:/

Might it be due to when this "cs_set_user_team" is use a lot?
That script think there is only 1 person in CT when second was transfered by cs_set_user_team?

So new ctnum; is getting fake numbers?
__________________
STER-Gaming.pl - The Best Multigaming Club, CS 1.6, CS:S, ET, COD 2 more and more ! Check forum forum.ster-gaming.pl

amxmodx - Polish support about amxx.

Last edited by Tramp; 03-25-2008 at 08:59.
Tramp is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 03-26-2008 , 02:57   Re: Limit CT team only for 2 players
Reply With Quote #4

Quote:
Originally Posted by Tramp View Post
Might it be due to when this "cs_set_user_team" is use a lot?
That script think there is only 1 person in CT when second was transfered by cs_set_user_team?

So new ctnum; is getting fake numbers?
Well I doubt it but you can try looping the players.

PHP Code:
    new players[32], numtnumctnum
    get_players
(playersnum)
    for (new 
inum; ++i) {
        if(
cs_get_user_team(players[id]) == CS_TEAM_CT) {
            
ctnum ctnum+1
        
} else if(cs_get_user_team(players[id]) == CS_TEAM_T {
            
tnum tnum+1
        
}
    } 

Last edited by Sputnik53; 03-26-2008 at 04:32. Reason: fixed little flaw
Sputnik53 is offline
Redshift187
Junior Member
Join Date: Mar 2008
Old 03-26-2008 , 20:23   Re: Limit CT team only for 2 players
Reply With Quote #5

You don't need to know the number of terrorists. The following allows you to do without get_players completely (it's unsupported). Also, you need to start at 1 and end at 32 because id 0 is not the first player id. It will take less memory too, since you don't have 2 arrays of 32.

Try:

PHP Code:
for (new 133i++)
{
    if (
is_user_connected(i))
    {
        if (
cs_get_user_team(i) == CS_TEAM_CT)
        {
            
ctnum++
        }
    }

Redshift187 is offline
Tramp
Senior Member
Join Date: Aug 2005
Old 03-27-2008 , 08:35   Re: Limit CT team only for 2 players
Reply With Quote #6

Quote:
Originally Posted by Redshift187 View Post
You don't need to know the number of terrorists. The following allows you to do without get_players completely (it's unsupported). Also, you need to start at 1 and end at 32 because id 0 is not the first player id. It will take less memory too, since you don't have 2 arrays of 32.

Try:

PHP Code:
for (new 133i++)
{
    if (
is_user_connected(i))
    {
        if (
cs_get_user_team(i) == CS_TEAM_CT)
        {
            
ctnum++
        }
    }

but hyh.

It is checking from 1 to 32 what team, player has and next increasing ctnum by 1 if the players is in CT. So how can i use it to block CT team for 2 persons?

So i need to add

PHP Code:
if (ctnum == 2)
{
        
engclient_cmd(i"menuselect""1");
        
engclient_cmd(i"menuselect""5");
        
client_cmd(i"slot1"); 

Something like this?
__________________
STER-Gaming.pl - The Best Multigaming Club, CS 1.6, CS:S, ET, COD 2 more and more ! Check forum forum.ster-gaming.pl

amxmodx - Polish support about amxx.
Tramp is offline
Redshift187
Junior Member
Join Date: Mar 2008
Old 03-27-2008 , 09:57   Re: Limit CT team only for 2 players
Reply With Quote #7

Your original code for that portion looked right. I'm not sure about the actual code for choosing the team, but the checks were fine. For efficiency, you don't need both:
PHP Code:
if (ctnum >= 2
and
PHP Code:
else if (ctnum 2
just use an else for the second statement.
Redshift187 is offline
Tramp
Senior Member
Join Date: Aug 2005
Old 03-27-2008 , 11:13   Re: Limit CT team only for 2 players
Reply With Quote #8

But i can use this

PHP Code:
for (new 133i++)
{
    if (
is_user_connected(i))
    {
        if (
cs_get_user_team(i) == CS_TEAM_CT)
        {
            
ctnum++
        }
    }

instead of

PHP Code:
    // Get teams
    
get_players(ctsctnum"e""CT"); 
To get ctnum?
If get_players is not supported function.

Right?

Hmm i will test it

EDIT 2

What is wrong?

PHP Code:
/* Mod Template generated by Pawn Studio */

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


#define PLUGIN    "New Plugin"
#define VERSION    "1.0"
#define AUTHOR    "Unknown"

/* Initialization */

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("chooseteam""chooseteam");
    
// Register commands, cvars and forwards here
}

public 
client_putinserver(id)
{
    
set_task(0.1"selectteam"id);

    return 
PLUGIN_CONTINUE;
}

public 
selectteam(id)
{
    
client_cmd(id"chooseteam");
}

public 
chooseteam(id)
{
    new 
ctnum;

    for (new 
i=133i++)
    {
        if (
is_user_connected(i))
        {
            if (
cs_get_user_team(i) == CS_TEAM_CT)
            {
                
ctnum++
            }
        }
    }  


    
    
//select T
    
if (ctnum >= 2)
    {
        
engclient_cmd(id"menuselect""1");
        
engclient_cmd(id"menuselect""5");
        
client_cmd(id"slot1");
    }
    
//select CT
    
else if (ctnum 2)
    {
        
engclient_cmd(id"menuselect""2");
        
engclient_cmd(id"menuselect""5");
        
client_cmd(id"slot1");
    }

    return 
PLUGIN_HANDLED;

Code:
// D:\amxmodx-1.8.0-base\addons\amxmodx\scripting\tim.sma(36) : warning 217: loose indentation
// D:\amxmodx-1.8.0-base\addons\amxmodx\scripting\tim.sma(52) : warning 217: loose indentation
__________________
STER-Gaming.pl - The Best Multigaming Club, CS 1.6, CS:S, ET, COD 2 more and more ! Check forum forum.ster-gaming.pl

amxmodx - Polish support about amxx.

Last edited by Tramp; 03-27-2008 at 11:48.
Tramp is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 03-27-2008 , 13:24   Re: Limit CT team only for 2 players
Reply With Quote #9

Code:
/* Mod Template generated by Pawn Studio */
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
 
#define PLUGIN    "New Plugin"
#define VERSION    "1.0"
#define AUTHOR    "Unknown"
 
/* Initialization */
 
new g_iMaxPlayers;
 
public plugin_init()
{
 register_plugin(PLUGIN, VERSION, AUTHOR)
 register_clcmd("chooseteam", "chooseteam");
 // Register commands, cvars and forwards here
 
 g_iMaxPlayers = get_maxplayers();
}
 
public client_putinserver(id)
{
 set_task(0.1, "selectteam", id);
 
 return PLUGIN_CONTINUE;
}
 
public selectteam(id)
{
 client_cmd(id, "chooseteam");
}
 
public chooseteam(id)
{
 new ctnum;
 
 for(new i = 1 ; i <= g_iMaxPlayers ; i++)
 {
  if(is_user_connected(i))
  {
   if(cs_get_user_team(i) == CS_TEAM_CT)
    ctnum++;
  }
 }
 //select T
 if (ctnum >= 2)
 {
  engclient_cmd(id, "menuselect", "1");
  engclient_cmd(id, "menuselect", "5");
  client_cmd(id, "slot1");
 }
 //select CT
 else if(ctnum < 2)
 {
  engclient_cmd(id, "menuselect", "2");
  engclient_cmd(id, "menuselect", "5");
  client_cmd(id, "slot1");
 }
 return PLUGIN_HANDLED;
}
If this don't works then is somehting from engclient_cmd()...
__________________
Still...lovin' . Connor noob! Hello
Alka 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 21:08.


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