Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- #include < fakemeta >
- #define PLUGIN "Unlimited Team Changes"
- #define VERSION "1.3"
- #define AUTHOR "HamletEagle"
- #define BITS 1<<8
- #define ADMIN_ACCES ADMIN_KICK
- const m_bHasChangeTeamThisRound = 125
- const XO_PLAYER = 5
- enum _: eCvarsData
- {
- cvar_OnlyAdmins,
- cvar_Enable
- }
- new g_iCvars[ eCvarsData ]
- new g_iCachedCvars[ eCvarsData ]
- new _pfnClientCommand
- public plugin_init( )
- {
- register_plugin
- (
- .plugin_name = PLUGIN,
- .version = VERSION,
- .author = AUTHOR
- )
- g_iCvars[ cvar_OnlyAdmins ] = register_cvar( "only_admins_can_use", "0" )
- /*
- 0 - all players
- 1 - only admins with specified flag
- */
- g_iCvars[ cvar_Enable ] = register_cvar( "plugin_enabled", "1" )
- /*
- 0 - plugin disabled
- 1 - plugin enabled
- */
- _pfnClientCommand = register_forward( FM_ClientCommand, "pfnClientCommand", false )
- register_event( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
- register_clcmd( "chooseteam", "ClientCommand_ChTeam" )
- register_clcmd( "jointeam" , "ClientCommand_ChTeam" )
- }
- public plugin_cfg( )
- {
- UTIL_CacheCvars( )
- }
- public pfnClientCommand( id )
- {
- //We need to catch the exact moment, so the cached cvar is not reliable here
- if( get_pcvar_num( g_iCvars[ cvar_Enable ] ) == 0 )
- {
- log_amx( "Plugin paused by cvar" )
- unregister_forward( FM_ClientCommand, _pfnClientCommand, false )
- pause( "a" )
- }
- }
- public Event_NewRound( )
- {
- UTIL_CacheCvars( )
- }
- public ClientCommand_ChTeam( id )
- {
- switch( g_iCachedCvars[ cvar_OnlyAdmins ] )
- {
- case 0 :
- {
- set_pdata_int( id, m_bHasChangeTeamThisRound , get_pdata_int( id, m_bHasChangeTeamThisRound, XO_PLAYER ) & ~BITS, XO_PLAYER )
- }
- case 1 :
- {
- if( get_user_flags( id ) & ADMIN_ACCES )
- {
- set_pdata_int( id, m_bHasChangeTeamThisRound , get_pdata_int( id, m_bHasChangeTeamThisRound, XO_PLAYER ) & ~BITS, XO_PLAYER )
- }
- }
- default:
- {
- return 0
- }
- }
- return 0
- }
- UTIL_CacheCvars( )
- {
- for( new i; i < sizeof g_iCvars; i++ )
- {
- g_iCachedCvars[ i ] = get_pcvar_num( g_iCvars[ i ] )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement