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

maximally players in team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
layka_LUBII
Senior Member
Join Date: Jul 2012
Old 03-01-2016 , 11:55   maximally players in team
Reply With Quote #1

Hallo, could you help me please? I need to set up that plugin. I need that in CT team can be maximally 7 players. Thanks you very much.

Code:
#include <amxmodx>
#include <cstrike>

#define PLUGIN "JailBreak Team Limiter"
#define VERSION "1.0"
#define AUTHOR "Risontek"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /ct","ct_prechod")
}
public ct_prechod(id)
{
    new ct = 0
    new te = 0
    for(new i = 1; i <= 32;i++)
    {
        if(get_user_team(i) == 1)
        {
            te++
        }
        if(get_user_team(i) == 2)
        {
            ct++
        }
    }
    if(ct == 0)
    {
        cs_set_user_team(id,CS_TEAM_CT)
        client_print(id,print_chat,"You are CT")
        return PLUGIN_HANDLED
    }
    if(ct == te)
    {
        client_print(id,print_chat,"CT is FULL")
        return PLUGIN_HANDLED
    }
    te /= 3
    if(te > ct)
    {
        cs_set_user_team(id,CS_TEAM_CT)
        client_print(id,print_chat,"You are CT")
    }
    else
    {
        client_print(id,print_chat,"CT is FULL")
    }
    return PLUGIN_HANDLED
}
layka_LUBII is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 03-01-2016 , 19:25   Re: maximally players in team
Reply With Quote #2

I think this will work
PHP Code:
#include <amxmodx>
#include <cstrike>

new ct 0
new bool:userCT

public plugin_init()
{
    
register_clcmd("say /ct""setCT")
}

public 
setCT(id)
{
    if(!
is_user_bot(id) || !is_user_hltv(id) || !is_user_connected(id))
        return 
PLUGIN_HANDLED;
    
    
userCT false;
    
    for(new 
1<= 32;i++)
    {
        if(
get_user_team(id) == 2)
        {
            if(
ct <= 7)
                
userCT true
            
break;
        }
        if(
get_user_team(i) == 2)
        {
            if(
ct >> 7)
            {
                
cs_set_user_team(idCS_TEAM_T)
                break;
            }
            
ct++
            
        }
    }
    return 
PLUGIN_HANDLED
}

public 
client_disconnect(id)
{
    if(
userCT)
    {
        
ct--;
    }

__________________

Last edited by Artifact; 03-01-2016 at 21:01.
Artifact is offline
layka_LUBII
Senior Member
Join Date: Jul 2012
Old 03-02-2016 , 10:31   Re: maximally players in team
Reply With Quote #3

excuse me, but it is not working. I tryed it on server with bots, even after using of /ct there were no change... nothing happend
layka_LUBII is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 03-02-2016 , 11:20   Re: maximally players in team
Reply With Quote #4

PHP Code:
if(!is_user_bot(id) || !is_user_hltv(id) || !is_user_connected(id)) 

PHP Code:
if(!is_user_hltv(id) || !is_user_connected(id)) 
__________________
Artifact is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 03-02-2016 , 11:47   Re: maximally players in team
Reply With Quote #5

Quote:
PHP Code:
public client_disconnect(id)
{
    if(
userCT)
    {
        
ct--;
    }

are you sure about this?

Last edited by EpicMonkey; 03-02-2016 at 11:51.
EpicMonkey is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 03-02-2016 , 14:06   Re: maximally players in team
Reply With Quote #6

Quote:
Originally Posted by EpicMonkey View Post
are you sure about this?
No, but i dont know can I use get_user_team when player is already disconnected if you think about bool, but other yes
__________________

Last edited by Artifact; 03-02-2016 at 14:07.
Artifact is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 03-02-2016 , 15:02   Re: maximally players in team
Reply With Quote #7

What i'm saying is what if a terrorist disconnects?
EpicMonkey is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 03-02-2016 , 15:38   Re: maximally players in team
Reply With Quote #8

ct is userCT
t is !userCT
right?
__________________
Artifact is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-02-2016 , 21:58   Re: maximally players in team
Reply With Quote #9

@OP: why reinvent the wheel? I'm sure there's a team balancer out there that can give you what you want.

@Artifact
Explain these highlighted lines. I'm assuming you didn't test this first as there are things wrong. You should know what you are doing if you are going to try to help people.
Code:
public setCT(id) {
    if(!is_user_bot(id) || !is_user_hltv(id) || !is_user_connected(id))
        return PLUGIN_HANDLED;
        userCT = false;         for(new i = 1; i <= 32;i++)     {         if(get_user_team(id) == 2)         {             if(ct <= 7)                 userCT = true             break;         }         if(get_user_team(i) == 2)         {
            if(ct >> 7)
            {                 cs_set_user_team(id, CS_TEAM_T)                 break;             }             ct++                     }     }     return PLUGIN_HANDLED }
__________________

Last edited by Bugsy; 03-02-2016 at 22:15.
Bugsy is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 03-03-2016 , 07:34   Re: maximally players in team
Reply With Quote #10

Quote:
Originally Posted by bugsy
Explain these highlighted lines
Explane is that I am an idiot. I see my code and i'm apologize

Last edited by Artifact; 03-03-2016 at 07:34.
Artifact 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 06:26.


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