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

Player Slot Manager v0.0.4


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Server Management       
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 09-11-2010 , 20:52   Player Slot Manager v0.0.4
Reply With Quote #1

Player Slot Manager v0.0.4
Status: Working | Bug Testing

Description:
Allows you to specify an amount of allowed players for each team (excluding spectator or unassigned)


Cvars:
psm_ctslots <amount> - How many players allowed to be a CT <default: 16>

psm_tslots <amount> - How many players allowed to be a T <default: 16>

psm_version <version> - I suggest you not edit this, this is just so you know what version of the plugin you have.


History:
Version 0.0.4 (9/11/2010): Huge update to block team change if slots are maxed.
Version 0.0.3 (9/11/2010): Message on spawn fix (thanks wrecked_)
Version 0.0.2 (9/11/2010): Removed Engine include
Version 0.0.1 (9/11/2010): Released

Trinkets:
HUD message displayed bottom left at all times




Special Thanks:
PHP Code:
/* Special Thanks */
// Exolent[jNr] - For the suggestion that I create a global variable to hold players team.
// Wrecked_ - For explaining shit/bug fix/retrieve arguments example
// Drekes - Team change event hook
// Fysiks - Suggesting I hook jointeam and retrieve arguments 

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

#define PLUGIN    "Player Slots Manager"
#define AUTHOR    "Shadow"
#define VERSION    "0.0.4"

new maxslots_ctmaxslots_t;
new 
ctcounttcountucountscount;

new 
Team[33]
enum
{
    
UNASSIGNED,
    
CT,
    
T,
    
SPECTATOR
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
//hamsandwich
    
RegisterHamHam_Spawn"player""player_spawn")
    
    
//thanks to drekes for the event :)
    
register_event"TeamInfo""join_team""a")
    
    
//thanks to fysik/wrecked for hook func and retrieving arguments
    
register_clcmd"jointeam""cmdJoinTeam" )
    
    
//cvars
    
register_cvar"psm_version"VERSION )
    
maxslots_ct register_cvar"psm_ctslots""16" )
    
maxslots_t register_cvar"psm_tslots""16" )
    
    
set_task1.0"show_hud", .flags="b" )
}

public 
client_putinserver(id)
{
    
Team[id] = UNASSIGNED
}

public 
client_disconnect(id)
{
    switch( 
cs_get_user_team(id) )
    {
        case 
CS_TEAM_T:
        {
            
tcount++
        }
        
        case 
CS_TEAM_CT:
        {
            
ctcount++
        }
        
        case 
CS_TEAM_UNASSIGNED:
        {
            
ucount++
        }
            
        case 
CS_TEAM_SPECTATOR:
        {
            
scount++
        }
    }
}

public 
show_hud(id)
{
    
set_hudmessage(2552552550.010.9200.02.00.10.2, -1);
    
show_hudmessage0"CT: %d | T: %d | Spec: %d | Unassigned: %d"ctcounttcountscountucount );
}

public 
player_spawn(id)
{
    new 
iPlayers[32], iNumplr;
    
get_playersiPlayersiNum )
    
    
ctcount 0;
    
tcount 0;
    
ucount 0;
    
scount 0;
    
    for( new 
0iNumi++ )
    {
        
plr iPlayers[i]
        
        switch( 
cs_get_user_team(plr) )
        {
            case 
CS_TEAM_T:
            {
                
tcount++
            }
            
            case 
CS_TEAM_CT:
            {
                
ctcount++
            }
            
            case 
CS_TEAM_UNASSIGNED:
            {
                
ucount++
            }
            
            case 
CS_TEAM_SPECTATOR:
            {
                
scount++
            }
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
cmdJoinTeamid )
{
    new 
teamstr[2]
    
read_argv1teamstr)
    
    new 
teamnum str_to_numteamstr )
    
    if( 
teamnum == )
    {
        if( 
tcount get_pcvar_nummaxslots_t ) )
        {
            
client_printidprint_chat"[Slots] The maximum players allowed on T is %d, sorry!"get_pcvar_nummaxslots_ct ) )
            
            return 
PLUGIN_HANDLED;
        } else {
            switch( 
Team[id] )
            {
                case 
UNASSIGNED:
                {
                    
ucount--
                }
                
                case 
T:
                {
                    
tcount--
                }
                
                case 
CT:
                {
                    
ctcount--
                }
                
                case 
SPECTATOR:
                {
                    
scount--
                }
            }
            
            new 
szName[32];
            
get_user_nameidszName32 )
            
            
tcount++
            new 
slotsleft get_pcvar_nummaxslots_t ) - tcount
            
            
if( Team[id] != )
            {
                
client_print0print_chat"[Slots] %s joined the Terrorists! Slots left: %d"szNameslotsleft )
            }
            
            
Team[id] = T
            
            
return PLUGIN_CONTINUE;
        }
    }
    
    if( 
teamnum == )
    {
        if( 
ctcount get_pcvar_nummaxslots_ct ) )
        {
            
client_printidprint_chat"[Slots] The maximum players allowed on CT is %d, sorry!"get_pcvar_nummaxslots_ct ) )
            
            return 
PLUGIN_HANDLED;
        } else {
            switch( 
Team[id] )
            {
                case 
UNASSIGNED:
                {
                    
ucount--
                }
                
                case 
T:
                {
                    
tcount--
                }
                
                case 
CT:
                {
                    
ctcount--
                }
                
                case 
SPECTATOR:
                {
                    
scount--
                }
            }
            
            new 
szName[32];
            
get_user_nameidszName32 )
            
            
ctcount++
            new 
slotsleft get_pcvar_nummaxslots_ct ) - ctcount
            
            
if( Team[id] != CT )
            {
                
client_print0print_chat"[Slots] %s joined the Counter-Terrorists! Slots left: %d"szNameslotsleft )
            }
            
            
Team[id] = CT
            
return PLUGIN_CONTINUE;
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
join_team()
{    
    new 
id read_data(1)
    static 
user_team[32]
    
    
read_data2user_team31 )    
    
    if( !
is_user_connected(id) )
    {
        return 
PLUGIN_CONTINUE
    
}
    
    switch( 
user_team[0] )
    {
        case 
'C':
        {
            if( 
ctcount get_pcvar_nummaxslots_ct ) )
            {
                
client_printidprint_chat"[Slots] The maximum players allowed on CT is %d, sorry!"get_pcvar_nummaxslots_ct ) )
                
                return 
PLUGIN_HANDLED;
            } else {
                switch( 
Team[id] )
                {
                    case 
UNASSIGNED:
                    {
                        
ucount--
                    }
                    
                    case 
T:
                    {
                        
tcount--
                    }
                    
                    case 
CT:
                    {
                        
ctcount--
                    }
                    
                    case 
SPECTATOR:
                    {
                        
scount--
                    }
                }
                
                new 
szName[32];
                
get_user_nameidszName32 )
                
                
ctcount++
                new 
slotsleft get_pcvar_nummaxslots_ct ) - ctcount
                
                
if( Team[id] != CT )
                {
                    
client_print0print_chat"[Slots] %s joined the Counter-Terrorists! Slots left: %d"szNameslotsleft )
                }
                
                
Team[id] = CT
            
}
        }
        case 
'S':
        {
            switch( 
Team[id] )
            {
                case 
UNASSIGNED:
                {
                    
ucount--
                }
                
                case 
T:
                {
                    
tcount--
                }
                
                case 
CT:
                {
                    
ctcount--
                }
                
                case 
SPECTATOR:
                {
                    
scount--
                }
            }
            
            new 
szName[32];
            
get_user_nameidszName32 )
            
            
scount++
            
Team[id] = SPECTATOR;
            
            
client_print0print_chat"[Slots] %s is now spectating the game!"szName )
        }
    }
    
    return 
PLUGIN_HANDLED;


Bug Fixed! Below:
Displays this message not only when the player joins a team, but every time they spawn:




If you have any suggestions, please post them!
Attached Files
File Type: sma Get Plugin or Get Source (playerslotmanager.sma - 760 views - 5.4 KB)
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 09-16-2010 at 06:47.
GXLZPGX is offline
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 09-11-2010 , 21:37   Re: Player Slot Manager v0.0.2
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?p=1052023 ?
__________________
"There is no knowledge, that is not power"
fezh is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 09-11-2010 , 21:49   Re: Player Slot Manager v0.0.2
Reply With Quote #3

Quote:
Originally Posted by GXLZPGX View Post
Bugs Known (Unable To Fix):
Displays this message not only when the player joins a team, but every time they spawn:



If you have any suggestions on how to fix this/block this, please post your suggestion.
Compare your Team[] variable and the team they are joining. If they are the same, don't print the message.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 09-11-2010 , 22:02   Re: Player Slot Manager v0.0.2
Reply With Quote #4

Quote:
Originally Posted by fezh View Post
I just looked at that plugin. The problem I see with that, is the cvar:

Code:
team_limits 5 3
Can be mixed up. The first number is for T's, and the second is for CT's, but if they forget, and they think the first number is for CT's and the second is for T's, they might mess up the limits. Another thing is, my plugin displays a hud message (OH WHOOPY DOO A HUD MESSAGE YOUR PLUGIN IS AMAZING /sarcasm), the reason why the hud message is such a big deal, is it frees up a slot on the players keyboard for one more bind. They don't have to cover their screen with a team score board. My plugin also displays a message with the players name, what team he joined, and how many slots are left. These aren't huge differences, but I hope you understand where I'm coming from.

@wrecked_,

Added!
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 09-11-2010 at 22:05.
GXLZPGX is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 09-11-2010 , 22:16   Re: Player Slot Manager v0.0.3
Reply With Quote #5

What does it matter if it can be mixed up? It's already made, which means this is unoriginal and will probably never be approved.
__________________
Hi.
Kreation is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 09-11-2010 , 22:21   Re: Player Slot Manager v0.0.3
Reply With Quote #6

Quote:
Originally Posted by Kreation View Post
What does it matter if it can be mixed up? It's already made, which means this is unoriginal and will probably never be approved.
Someone's jealous.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-11-2010 , 23:46   Re: Player Slot Manager v0.0.4
Reply With Quote #7

Your code is very redundant and the idea was already made (coincidentally, it was me).
If you'd like to know how to improve your plugin, reply back or send a PM.

Also, don't put the code in the post.
The attachment is enough.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
tm.
Member
Join Date: Apr 2010
Old 09-12-2010 , 03:05   Re: Player Slot Manager v0.0.4
Reply With Quote #8

PHP Code:
new szName[32]; 
get_user_nameidszName32 
?
tm. is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 09-12-2010 , 21:53   Re: Player Slot Manager v0.0.4
Reply With Quote #9

Quote:
Originally Posted by tm. View Post
PHP Code:
new szName[32]; 
get_user_nameidszName32 
?
Are you saying there is something wrong with that? lol..
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 09-12-2010 , 21:59   Re: Player Slot Manager v0.0.4
Reply With Quote #10

Quote:
Originally Posted by GXLZPGX View Post
Are you saying there is something wrong with that? lol..
Yes. Below is better
PHP Code:
new szName[32]; 
get_user_nameidszName31 
__________________
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
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:25.


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