|
发表于 2013-6-4 23:38:58
|
显示全部楼层
|阅读模式
来自 中国–上海–上海–浦东新区
- #include <amxmodx>
- #include <fakemeta>
- #define PLUGIN_NAME "Connnection Protection"
- #define PLUGIN_VERSION "0.1"
- #define fClearTrieTime 12.4
- #define iConnectionBanCount 6
- new Trie:ghTrie;
- public plugin_init( )
- {
- register_plugin( PLUGIN_NAME , PLUGIN_VERSION , "LittleKu-Lv" );
-
- register_cvar( "amx_cfp_version" , PLUGIN_VERSION , FCVAR_SPONLY | FCVAR_SERVER );
-
- register_forward( FM_ClientConnect , "fwClientConnectPost" , true );
-
- ghTrie = TrieCreate();
- }
- public fwClientConnectPost( id , const szName[] , const szAddress[] , const szRejectReason[ 128 ] )
- {
- if ( pev( id , pev_flags ) & FL_FAKECLIENT )
- {
- return FMRES_IGNORED;
- }
-
- if ( szAddress[ 0 ] == 0 )
- {
- return FMRES_IGNORED;
- }
-
- static iConnectionCount;
- static params[ 32 ];
-
- if ( !TrieGetCell( ghTrie , szAddress , iConnectionCount ) )
- {
- copy( params , 31 , szAddress );
- set_task( fClearTrieTime , "ClearValueFromTrie" , 0 , params , 32 );
-
- TrieSetCell( ghTrie , szAddress, 0 );
- return FMRES_IGNORED;
- }
-
- if ( iConnectionCount == iConnectionBanCount )
- {
- static iUserId;
- iUserId = get_user_userid( id );
- server_cmd( "kick #%d;addip 0 %s;writeip" , iUserId , szAddress );
- return FMRES_IGNORED;
- }
-
- TrieSetCell( ghTrie , szAddress , ( iConnectionCount + 1 ) );
- return FMRES_IGNORED;
- }
- public ClearValueFromTrie( params[] )
- {
- static szAddress[ 32 ];
-
- copy( szAddress, 31, params );
-
- TrieDeleteKey( ghTrie , szAddress );
-
- return PLUGIN_CONTINUE;
- }
- public plugin_end()
- {
- TrieClear( ghTrie );
- }
复制代码 温馨提示:返回后,您可点击恢复数据,恢复您刚刚编辑的内容! |
|