Raised This Month: $51 Target: $400
 12% 

Connections Counter


Post New Thread Reply   
 
Thread Tools Display Modes
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-13-2010 , 12:21   Re: Connections Counter
Reply With Quote #11

Bugsy - can you post the code please? I don't know how to use enums
lazarev is offline
Melisko
Senior Member
Join Date: Feb 2010
Old 03-13-2010 , 13:39   Re: Connections Counter
Reply With Quote #12

Can U make it compatibile with Admin Chat Colors??? I have 2 chats. Also can u disable AllChat??? Dead players can see chat of live players and live players of dead , and also , disable that (Admin) , I want there normal rank

And maybe creat /top for players with most connets and playtime

BUG!!!! say_team IS NOT WORKING

Last edited by Melisko; 03-13-2010 at 14:09. Reason: top , bug
Melisko is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-13-2010 , 14:46   Re: Connections Counter
Reply With Quote #13

Edit: New version posted. Please report any bugs\requests.

Changelog:
v0.5
  • Option to use nVault or SQL (#define USE_SQL)
v0.4
  • Now using SQL
  • Fixed bug where numbers were wrong (connections,playtime) or 'invalid number' error.
v0.3
  • Fixed bug where if a user changed his name his chat msgs would show only his name when he first connected.
  • Tested Say\TeamSay and both work correctly; if you are dead, only dead people see your messages. If alive, everyone can see your messages. TeamSay rules apply for if you are alive or dead.
  • Added cvar for all chat (cat_allchat, default 0\disabled)
  • Comment: Tested plugin with 8 connections including multiple mapchanges and each time the plugin reported correct number of connections and play-time.
Code:
* You currently have 8 connections. [Status: Newbie]
* You have played on this server for: 30 minutes, 42 seconds
v0.2
  • PlayTime and\or connections being lost when value reaches 256.
  • Alive players now cannot see dead players chat.
  • Removed get_user_time() in client_disconnect().
PHP Code:
#define USE_SQL

#include < amxmodx >
#include < cstrike >

#if defined USE_SQL
#include < sqlx >
#else
#include < nvault >
#endif

const MAX_PLAYERS 32;

new const 
Version[] = "0.5";
new const 
DataFileName[] = "PlayerData";

enum ConnectionStatus
{
    
Newbie,
    
SemiPro,
    
Pro,
    
Veteran
}

new const 
StatusDescriptionConnectionStatus ][] = 
{
    
"Newbie",
    
"Semi-Pro",
    
"Pro",
    
"Veteran"
};

enum StatusLevelRange
{
    
Floor,
    
Ceiling
}
new const 
StatusLevelsConnectionStatus ][ StatusLevelRange ] = 
{
    { 
100 },    
    { 
101 500 },    
    { 
501 750 },    
    { 
751 99999 }
};

new const 
TeamsCsTeams ][] = 
{
    
"(Unassigned)",
    
"(Terrorist)"
    
"(Counter-Terrorist)",
    
"(Spectator)"
};

enum PlayerData
{
    
Name33 ],
    
AuthID35 ],
    
Connections,
    
Status,
    
PlayTime,
    
LeaveMsg33 ]
}

new 
g_PDataMAX_PLAYERS ][ PlayerData ];
new 
g_iConnectTimeMAX_PLAYERS ];
new 
bool:g_bIsBotMAX_PLAYERS ];

#if defined USE_SQL
#define CREATE_DB    "CREATE TABLE IF NOT EXISTS database ( key VARCHAR(128) NOT NULL, data VARCHAR(255) NOT NULL, timestamp INT(11) NOT NULL, PRIMARY KEY (key))"
#define SEARCH_DB    "SELECT data,timestamp FROM database WHERE key='%s' LIMIT 1"
#define INSERT_DB    "REPLACE INTO database (key,data,timestamp) VALUES ('%s','%s',%d)"
new Handle:g_iSQLTuple;
new 
g_szDBQueryCache1024 ];
#else
new g_iVault;
#endif

new g_iMsgSayText;
new 
g_iMaxPlayers;
new 
g_pAllChat;

public 
plugin_init( )
{
    
register_plugin"Connections and Time" Version "bugsy" );
    
    
register_clcmd"say" "HookSay" );
    
register_clcmd"say_team" "HookSay_Team" );

    
g_pAllChat register_cvar"cat_allchat" "0" );
    
    
g_iMsgSayText get_user_msgid"SayText" );
    
g_iMaxPlayers get_maxplayers();
}

public 
plugin_cfg()
{
    
#if defined USE_SQL
    
new szHost64 ], szUser32 ], szPassword32 ];

    
get_cvar_string"amx_sql_host" szHost 64 );
    
get_cvar_string"amx_sql_user" szUser 32 );
    
get_cvar_string"amx_sql_pass" szPassword 32 );
    
    
SQL_SetAffinity"mysql" );
    
g_iSQLTuple SQL_MakeDbTupleszHost szUser szPassword DataFileName );
    
    
formatexg_szDBQueryCache 1023 CREATE_DB );
    
SQL_ThreadQueryg_iSQLTuple "DefaultHandle" g_szDBQueryCache );
    
#else
    
g_iVault nvault_openDataFileName );
    
#endif
}

public 
plugin_end()
{
    
#if defined USE_SQL
    
SQL_FreeHandleg_iSQLTuple );
    
#else
    
nvault_closeg_iVault );
    
#endif
}

public 
client_putinserverid )
{
    
g_bIsBotid ] = bool:!!is_user_botid );
    
    if ( 
g_bIsBotid ] )
        return 
PLUGIN_CONTINUE;

    
get_user_authidid g_PDataid ][ AuthID ] , charsmaxg_PData[][ AuthID ] ) );
    
    
#if defined USE_SQL
    
new iData];
    
iData] = id;
    
formatexg_szDBQueryCache 255 SEARCH_DB g_PDataid ][ AuthID ] );
    
SQL_ThreadQueryg_iSQLTuple "SearchHandle" g_szDBQueryCache iData sizeofiData ) );
    
#else
    
static szData128 ] , szConnections] , szStatus] , szPlayTime];
    if ( 
nvault_getg_iVault g_PDataid ][ AuthID ] , szData charsmaxszData ) ) )
    {
        
parseszData g_PDataid ][ Name ] , charsmaxg_PData[][ Name ] ) ,
                
g_PDataid ][ AuthID ] , charsmaxg_PData[][ AuthID ] ) ,
                
szConnections charsmaxszConnections ) ,
                
szStatus charsmaxszStatus ) ,
                
szPlayTime charsmaxszPlayTime ) ,
                
g_PDataid ][ LeaveMsg ] , charsmaxg_PData[][ LeaveMsg ] ) );
    
        
g_PDataid ][ Connections ] = str_to_numszConnections );
        
g_PDataid ][ PlayTime ] = str_to_numszPlayTime );
    }
    
    
g_PDataid ][ Connections ]++;
    
g_iConnectTimeid ] = get_systime();
    
    for ( new 
ConnectionStatus:Newbie Veteran i++ )
    {
        if ( 
StatusLevels][ Floor ] <= g_PDataid ][ Connections ] <= StatusLevels][ Ceiling ] )
        {
            
g_PDataid ][ Status ] = _:i;
            break;
        }
    }
    
    
get_user_nameid g_PDataid ][ Name ] , charsmaxg_PData[][ Name ] ) );
    
    
set_task6.0 "ShowJoinMsg" id );
    
#endif
    
    
return PLUGIN_CONTINUE;
}

public 
client_infochanged(id
{    
    static 
szNewName33 ];

    
get_user_infoid "name" szNewName 32 );
    
    if ( !
equalg_PDataid ][ Name ] , szNewName ) )
        
copyg_PDataid ][ Name ] , charsmaxg_PData[][ Name ] ) , szNewName );
}

public 
ShowJoinMsgid )
{
    static 
szMessage128 ];

    
formatexszMessage charsmaxszMessage ) , "^x04* ^x03%s has joined with^x04 %d^x03 connections. [^x04Status: %s^x03]" g_PDataid ][ Name ] , g_PDataid ][ Connections ] , StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] );
    Print( 
szMessage );
}

public 
client_disconnectid )
{
    static 
szMessage128 ];
    
    if ( 
g_bIsBotid ] )
        return 
PLUGIN_CONTINUE;
    
    
remove_taskid );
    
    
g_PDataid ][ PlayTime ] += ( get_systime() - g_iConnectTimeid ] );
    
    
formatexszMessage charsmaxszMessage ) , "^"%s^" ^"%s^" ^"%d^" ^"%d^" ^"%d^" ^"%s^"" g_PDataid ][ Name ] , 
                                       
g_PDataid ][ AuthID ] , 
                                       
g_PDataid ][ Connections ] , 
                                       
g_PDataid ][ Status ] , 
                                       
g_PDataid ][ PlayTime ] , 
                                       
g_PDataid ][ LeaveMsg ] );
        
    
#if defined USE_SQL
    
formatexg_szDBQueryCache 511 INSERT_DB g_PDataid ][ AuthID ] , szMessage get_systime() );
    
SQL_ThreadQueryg_iSQLTuple "DefaultHandle" g_szDBQueryCache );
    
#else
    
nvault_setg_iVault g_PDataid ][ AuthID ] , szMessage );
    
#endif
    
    
if( ConnectionStatus:g_PDataid ][ Status ] == Veteran )
    {
        
formatexszMessage charsmaxszMessage ) , "^x04* ^x03Veteran: %s has left the server. [^x04Message: %s^x03]" g_PDataid ][ Name ] , g_PDataid ][ LeaveMsg ] );
        Print( 
szMessage );
    }
    
    
g_PDataid ][ Name ][ ] = EOS;
    
g_PDataid ][ AuthID ][ ] = EOS;
    
g_PDataid ][ Connections ] = 0;
    
g_PDataid ][ Status ] = 0;    
    
g_PDataid ][ PlayTime ] = 0;
    
g_PDataid ][ LeaveMsg ][ ] = EOS;
    
    
g_iConnectTimeid ] = 0;
    
    return 
PLUGIN_CONTINUE;
}

public 
HookSayid )
{
    static 
szMessage256 ] , szMsgSaid256 ];
    new 
bool:bIsAlive bool:bAllChat;
    
    
read_argsszMsgSaid charsmaxszMsgSaid ) );
    
remove_quotesszMsgSaid );
    
    
//   /leavemsg
    
if( ConnectionStatus:g_PDataid ][ Status ] == Veteran )
    {
        if( 
szMsgSaid] == '/' && szMsgSaid] == 'e' && szMsgSaid] == 'v' && szMsgSaid] == 'm' )
        {
            new 
Arg64 ];
            
strbreakszMsgSaid szMsgSaid 95 Arg 63 );
            
remove_quotesArg );
    
            if( !
Arg] )
            {
                if( 
g_PDataid ][ LeaveMsg ][ ]  )
                {
                    
client_printid print_chat "* Your current leave message is ^"%s^"" g_PDataid ][ LeaveMsg ] );
                }
                else
                {
                    
client_printid print_chat "* You haven't set a leave message yet. To do so, type /leavemsg ^"message^"." );
                }
            }
            else if( 
equaliArg "remove" ) )
            {
                
g_PDataid ][ LeaveMsg ][ ] = EOS;
                
client_printid print_chat "* Your leave message was removed." );
            }
            else
            {
                
copyg_PDataid ][ LeaveMsg ] , charsmaxg_PData[][ LeaveMsg ] ) , Arg );
                
client_printid print_chat "* Your leave message has been set to ^"%s^"" Arg );
            }
            return 
PLUGIN_HANDLED;
        }
    }
    
    
//   /playtime
    
if ( szMsgSaid] == '/' && szMsgSaid] == 'p' && szMsgSaid] == 'y' && szMsgSaid] == 'm' )
    {
        new 
iHours iDays iMinutes iCurTime;
        static 
szPlayTime128 ] , iPos;
        
        
formatexszMessage charsmaxszMessage) , "^x04*^x03 You currently have^x04 %d^x03 connections. [^x04Status: %s^x03]" g_PDataid ][ Connections ] , StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] );
        Print( 
id id szMessage );
        
        
iCurTime g_PDataid ][ PlayTime ] + ( get_systime() - g_iConnectTimeid ] );
        
iPos 0;
        
        if ( 
iCurTime >= 86400 )
        {
            
iDays iCurTime 86400;
            
iCurTime -= iDays 86400;
            
iPos formatexszPlayTime charsmaxszPlayTime ) , "%d days, " iDays );
        }
        if ( 
iCurTime >= 3600 )
        {
            
iHours iCurTime 3600;
            
iCurTime -= iHours 3600;
            
iPos += formatexszPlayTimeiPos ] , charsmaxszPlayTime ) - iPos "%d hour%s, " iHours iHours "s" "" );
        }
        if ( 
iCurTime >= 60 )
        {
            
iMinutes iCurTime 60;
            
iCurTime -= iMinutes 60;
            
iPos += formatexszPlayTimeiPos ] , charsmaxszPlayTime ) - iPos "%d minute%s, " iMinutes iMinutes "s" "" );
        }
        if ( 
iCurTime )
        {
            
iPos += formatexszPlayTimeiPos ] , charsmaxszPlayTime ) - iPos "%d second%s, " iCurTime iCurTime "s" "" );
        }
        
        
szPlayTimeiPos ] = EOS;
        
        
formatexszMessage charsmaxszMessage ) , "^x04*^x03 You have played on this server for:^x04 %s"szPlayTime );
        Print( 
id id szMessage );
        
        return 
PLUGIN_HANDLED;
    }

    
bIsAlive bool:!!is_user_aliveid );
    
bAllChat bool:!!get_pcvar_numg_pAllChat );
    
    if ( 
bIsAlive )
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , g_PDataid ][ Name ] , szMsgSaid );
    else 
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x01 %s^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , ( cs_get_user_teamid ) != CS_TEAM_SPECTATOR ) ? "*DEAD*" "*SPEC*" g_PDataid ][ Name ] , szMsgSaid );

    for ( new 
iPlayer iPlayer <= g_iMaxPlayers iPlayer++ )
        if ( 
is_user_connectediPlayer ) &&
            ( 
bAllChat || ( bIsAlive || ( !bIsAlive && !is_user_aliveiPlayer ) ) ) ) )
                Print( 
iPlayer id szMessage );
            
    return 
PLUGIN_HANDLED;
}

public 
HookSay_Teamid )
{
    static 
szMessage256 ] , szMsgSaid256 ];
    new 
CsTeams:iTeam bool:bIsAlive bool:bAllChat;
    
    
read_argsszMsgSaid charsmaxszMsgSaid ) );
    
remove_quotesszMsgSaid );

    
iTeam cs_get_user_teamid );
    
bIsAlive bool:!!is_user_aliveid );
    
bAllChat bool:!!get_pcvar_numg_pAllChat );
    
    if ( 
bIsAlive || ( iTeam == CS_TEAM_SPECTATOR ) )
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x01 %s^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , TeamsiTeam ] , g_PDataid ][ Name ] , szMsgSaid );
    else 
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x01 *DEAD* %s^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , TeamsiTeam ], g_PDataid ][ Name ] , szMsgSaid );

    for ( new 
iPlayer iPlayer <= g_iMaxPlayers iPlayer++ )
        if ( ( 
is_user_connectediPlayer ) && ( cs_get_user_teamiPlayer ) == iTeam ) ) &&
            ( 
bAllChat || ( bIsAlive || ( !bIsAlive && !is_user_aliveiPlayer ) ) ) ) )
                Print( 
iPlayer id szMessage );
        
    return 
PLUGIN_HANDLED;
}

Print( 
id colorid szMessage[] )
{
    
message_beginid MSG_ONE_UNRELIABLE MSG_BROADCAST g_iMsgSayText , {0,0,0} , id );
    
write_bytecolorid );
    
write_stringszMessage );
    
message_end();
}

#if defined USE_SQL
public SearchHandleFailState Handle:Query Error[] , Errcode Data[] , DataSize )
{
    if ( 
FailState == TQUERY_CONNECT_FAILED )
        return 
set_fail_state"Could not connect to SQL database." );
        
    else if ( 
FailState == TQUERY_QUERY_FAILED )
        return 
set_fail_state"SQL Query failed." );

    if ( 
Errcode )
        return 
log_amx"SQL Error on query: %s" Error );

    static 
szData128 ] , szConnections] , szStatus] , szPlayTime];
    new 
id Data];
    
    if ( 
SQL_MoreResultsQuery ) )
    {
        
SQL_ReadResultQuery szData charsmaxszData ) );
        
        
parseszData g_PDataid ][ Name ] , charsmaxg_PData[][ Name ] ) ,
                
g_PDataid ][ AuthID ] , charsmaxg_PData[][ AuthID ] ) ,
                
szConnections charsmaxszConnections ) ,
                
szStatus charsmaxszStatus ) ,
                
szPlayTime charsmaxszPlayTime ) ,
                
g_PDataid ][ LeaveMsg ] , charsmaxg_PData[][ LeaveMsg ] ) );
    
        
g_PDataid ][ Connections ] = str_to_numszConnections );
        
g_PDataid ][ PlayTime ] = str_to_numszPlayTime );
    }
    
    
g_PDataid ][ Connections ]++;
    
g_iConnectTimeid ] = get_systime();
    
    for ( new 
ConnectionStatus:Newbie Veteran i++ )
    {
        if ( 
StatusLevels][ Floor ] <= g_PDataid ][ Connections ] <= StatusLevels][ Ceiling ] )
        {
            
g_PDataid ][ Status ] = _:i;
            break;
        }
    }
    
    
get_user_nameid g_PDataid ][ Name ] , charsmaxg_PData[][ Name ] ) );
    
    
set_task6.0 "ShowJoinMsg" id );

    return 
PLUGIN_CONTINUE;
}

public 
DefaultHandleFailState Handle:Query Error[] , Errcode Data[] , DataSize )
{
    if ( 
FailState == TQUERY_CONNECT_FAILED )
        return 
set_fail_state"Could not connect to SQL database." );
    else if ( 
FailState == TQUERY_QUERY_FAILED )
        return 
set_fail_state"SQL Query failed." );

    if ( 
Errcode )
        return 
log_amx"SQL Error on query: %s" Error );
    
    
    return 
PLUGIN_CONTINUE;
}
#endif 
__________________

Last edited by Bugsy; 03-21-2010 at 16:48.
Bugsy is offline
kanatzu
Veteran Member
Join Date: Oct 2007
Location: Sweden
Old 03-13-2010 , 15:34   Re: Connections Counter
Reply With Quote #14

Nice one.

Make a complete verision!
__________________




Quote:
Originally Posted by wrecked_ View Post
Stop saying words before I sodomize you with a cucumber.
kanatzu is offline
Send a message via MSN to kanatzu
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-13-2010 , 15:59   Re: Connections Counter
Reply With Quote #15

Thank you, Bugsy
lazarev is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-13-2010 , 16:33   Re: Connections Counter
Reply With Quote #16

Quote:
Originally Posted by Bugsy View Post
PHP Code:
new g_PData33 ][ PlayerData ];

get_user_nameid g_PDataid ][ Name ] , charsmaxg_PData[] ) );
get_user_authidid g_PDataid ][ AuthID ] , charsmaxg_PData[] ) ); 
You should use `charsmax(PlayerData:AuthID)', or something like that (don't know if it's possible). Using `charsmax(g_PData[])' will return the number of elements in the enum.

EDIT: Just tested and `charsmax(g_PData[][AuthID])' works, `charsmax(g_PData[])' returns the whole enum size.

Last edited by Seta00; 03-13-2010 at 16:41.
Seta00 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-13-2010 , 16:47   Re: Connections Counter
Reply With Quote #17

Oops my mistake, thx m8
__________________

Last edited by Bugsy; 03-13-2010 at 16:56.
Bugsy is offline
Melisko
Senior Member
Join Date: Feb 2010
Old 03-13-2010 , 16:48   Re: Connections Counter
Reply With Quote #18

Quote:
Originally Posted by Bugsy View Post
Let me know if you have any problems.

Added chat command "/playtime" to display time spent on server. It will also display current connections and connections 'rank.'

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

const MAX_PLAYERS 32;

new const 
Version[] = "0.1";
new const 
VaultName[] = "ConnectData";

enum ConnectionStatus
{
    
Newbie,
    
SemiPro,
    
Pro,
    
Veteran
}
new const 
StatusDescriptionConnectionStatus ][] = 
{
    
"Newbie",
    
"Semi-Pro",
    
"Pro",
    
"Veteran"
};

enum StatusLevelRange
{
    
Floor,
    
Ceiling
}
new const 
StatusLevelsConnectionStatus ][ StatusLevelRange ] = 
{
    { 
100 },    
    { 
101 500 },    
    { 
501 750 },    
    { 
751 99999 }
};

new const 
TeamsCsTeams ][] = 
{
    
"(Unassigned)",
    
"(Terrorist)"
    
"(Counter-Terrorist)",
    
"(Spectator)"
};

enum PlayerData
{
    
Name33 ],
    
AuthID35 ],
    
Connections,
    
Status,
    
PlayTime,
    
LeaveMsg128 ]
}

new 
g_PDataMAX_PLAYERS ][ PlayerData ];
new 
bool:g_bIsBotMAX_PLAYERS ];

new 
g_iVault;
new 
g_iMsgSayText;

const 
g_MaxNumber 0x7FFFFFF;
const 
g_DummyChar '0';
new 
szLoadSaveBuffer[ (sizeofg_PData[] ) * 4) + ];

public 
plugin_init( )
{
    
register_plugin"Connections and Time" Version "bugsy" );
    
    
register_clcmd"say" "HookSay" );
    
register_clcmd"say_team" "HookSay_Team" );
    
    
g_iMsgSayText get_user_msgid"SayText" );

    
g_iVault nvault_openVaultName );
}

public 
plugin_end()
{
    
nvault_closeg_iVault );
}

public 
client_putinserverid )
{
    
g_bIsBotid ] = bool:!!is_user_botid );
    
    if ( 
g_bIsBotid ] )
        return 
PLUGIN_CONTINUE;
        
    
get_user_authidid g_PDataid ][ AuthID ] , charsmaxg_PData[] ) );
    
    if ( 
nvault_getg_iVault g_PDataid ][ AuthID ] , szLoadSaveBuffer charsmaxszLoadSaveBuffer ) ) )
        
LoadArrayszLoadSaveBuffer charsmaxszLoadSaveBuffer ) , g_PDataid ][ PlayerData:] );

    
/*server_print( "%s %s %d %d %d %s" , g_PData[ id ][ Name ] , 
                    g_PData[ id ][ AuthID ] , 
                    g_PData[ id ][ Connections ] , 
                    g_PData[ id ][ Status ] ,
                    g_PData[ id ][ PlayTime ] ,
                    g_PData[ id ][ LeaveMsg ] );*/
                    
    
get_user_nameid g_PDataid ][ Name ] , charsmaxg_PData[] ) );
    
g_PDataid ][ Connections ]++;
    
    for ( new 
ConnectionStatus:Newbie Veteran i++ )
    {
        if ( 
StatusLevels][ Floor ] <= g_PDataid ][ Connections ] <= StatusLevels][ Ceiling ] )
        {
            
g_PDataid ][ Status ] = _:i;
            break;
        }
    }
    
    
set_task7.0 "ShowJoinMsg" id );
    
    return 
PLUGIN_CONTINUE;
}

public 
ShowJoinMsgid )
{
    static 
szMessage128 ];

    
formatexszMessage charsmaxszMessage) , "^x04* ^x03%s has joined with^x04 %d^x03 connections. [^x04Status: %s^x03]" g_PDataid ][ Name ] , g_PDataid ][ Connections ], StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] );
    Print( 
szMessage );
}

public 
client_disconnectid )
{
    if ( 
g_bIsBotid ] )
        return 
PLUGIN_CONTINUE;
        
    static 
szMessage128 ];
    
    
remove_taskid );
    
    
g_PDataid ][ PlayTime ] += get_user_timeid );
    
    
SaveArrayg_PDataid ][ PlayerData:] , sizeofg_PData[] ) , szLoadSaveBuffer );
    
    
nvault_setg_iVault g_PDataid ][ AuthID ] , szLoadSaveBuffer );
    
    if( 
ConnectionStatus:g_PDataid ][ Status ] == Veteran )
    {
        
formatexszMessage charsmaxszMessage ) , "^x04* ^x03Veteran: %s has left the server. [^x04Message: %s^x03]" g_PDataid ][ Name ] , g_PDataid ][ LeaveMsg ] );
        Print( 
szMessage );
    }
    
    
g_PDataid ][ Name ][ ] = EOS;
    
g_PDataid ][ AuthID ][ ] = EOS;
    
g_PDataid ][ Connections ] = 0;
    
g_PDataid ][ Status ] = 0;    
    
g_PDataid ][ PlayTime ] = 0;
    
g_PDataid ][ LeaveMsg ][ ] = EOS;
    
    return 
PLUGIN_CONTINUE;
}

public 
HookSayid )
{
    static 
szMessage256 ] , szMsgSaid256 ];
    
read_argsszMsgSaid charsmaxszMsgSaid ) );
    
remove_quotesszMsgSaid );
    
    
//   /leavemsg
    
if( ConnectionStatus:g_PDataid ][ Status ] == Veteran )
    {
        if( 
szMsgSaid] == '/' && szMsgSaid] == 'e' && szMsgSaid] == 'v' && szMsgSaid] == 'm' )
        {
            new 
Arg64 ];
            
strbreakszMsgSaid szMsgSaid 95 Arg 63 );
            
remove_quotesArg );
    
            if( !
Arg] )
            {
                if( 
g_PDataid ][ LeaveMsg ][ ]  )
                {
                    
client_printidprint_chat"* Your current leave message is ^"%s^"" g_PDataid ][ LeaveMsg ] );
                }
                else
                {
                    
client_printidprint_chat"* You haven't set a leave message yet. To do so, type /leavemsg ^"message^"." );
                }
            }
            else if( 
equaliArg "remove" ) )
            {
                
g_PDataid ][ LeaveMsg ][ ] = EOS;
                
client_printidprint_chat"* Your leave message was removed." );
            }
            else
            {
                
copyg_PDataid ][ LeaveMsg ] , charsmaxg_PData[] ) , Arg );
                
client_printid print_chat "* Your leave message has been set to ^"%s^""Arg );
            }
            return 
PLUGIN_HANDLED;
        }
    }
    
    
//   /playtime
    
if ( szMsgSaid] == '/' && szMsgSaid] == 'p' && szMsgSaid] == 'y' && szMsgSaid] == 'm' )
    {
        new 
iHours iDays iMinutes iCurTime;
        static 
szPlayTime128 ] , iPos;
        
        
formatexszMessage charsmaxszMessage) , "^x04*^x03 You currently have^x04 %d^x03 connections. [^x04Status: %s^x03]" g_PDataid ][ Connections ] , StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] );
        Print( 
id id szMessage );
        
        
iCurTime g_PDataid ][ PlayTime ] + get_user_timeid );
        
iPos 0;
        
        if ( 
iCurTime >= 86400 )
        {
            
iDays iCurTime 86400;
            
iCurTime -= iDays 86400;
            
iPos formatexszPlayTime charsmaxszPlayTime ) , "%d days, " iDays );
        }
        if ( 
iCurTime >= 3600 )
        {
            
iHours iCurTime 3600;
            
iCurTime -= iHours 3600;
            
iPos += formatexszPlayTimeiPos ] , charsmaxszPlayTime ) - iPos "%d hour%s, " iHours iHours "s" "" );
        }
        if ( 
iCurTime >= 60 )
        {
            
iMinutes iCurTime 60;
            
iCurTime -= iMinutes 60;
            
iPos += formatexszPlayTimeiPos ] , charsmaxszPlayTime ) - iPos "%d minute%s, " iMinutes iMinutes "s" "" );
        }
        if ( 
iCurTime )
        {
            
iPos += formatexszPlayTimeiPos ] , charsmaxszPlayTime ) - iPos "%d second%s, " iCurTime iCurTime "s" "" );
        }
        
        
szPlayTimeiPos ] = EOS;
        
        
formatexszMessage charsmaxszMessage ) , "^x04*^x03 You have played on this server for:^x04 %s"szPlayTime );
        Print( 
id id szMessage );
        
        return 
PLUGIN_HANDLED;
    }
    
    if ( !
szMsgSaid] || szMsgSaid[0] == '@' || szMsgSaid[0] == '/' || szMsgSaid[0] == '!' )
        return 
PLUGIN_CONTINUE;
    
    if ( 
is_user_aliveid ) )
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , g_PDataid ][ Name ] , szMsgSaid );
    else 
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x01 %s^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , ( cs_get_user_teamid ) != CS_TEAM_SPECTATOR ) ? "*DEAD*" "*SPEC*" g_PDataid ][ Name ] , szMsgSaid );

    Print( 
id szMessage );
    
    return 
PLUGIN_HANDLED;
}

public 
HookSay_Teamid )
{
    static 
szMessage256 ] , szMsgSaid256 ];
    new 
CsTeams:iTeam;
    
    
read_argsszMsgSaid charsmaxszMsgSaid ) );
    
remove_quotesszMsgSaid );

    
iTeam cs_get_user_teamid );
    
    if ( !
szMsgSaid] || szMsgSaid[0] == '@' || szMsgSaid[0] == '/' || szMsgSaid[0] == '!' )
        return 
PLUGIN_CONTINUE;
    
    if ( 
is_user_aliveid ) || ( iTeam == CS_TEAM_SPECTATOR ) )
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x01 %s^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , TeamsiTeam ] , g_PDataid ][ Name ] , szMsgSaid );
    else 
        
formatexszMessage charsmaxszMessage ) , "^x04[%s]^x01 *DEAD* %s^x03 %s^x01 :  %s"StatusDescriptionConnectionStatus:g_PDataid ][ Status ] ] , TeamsiTeam ], g_PDataid ][ Name ] , szMsgSaid );

    for ( new 
iPlayer iPlayer <= MAX_PLAYERS iPlayer++ )
        if ( 
is_user_connectediPlayer ) && ( cs_get_user_teamiPlayer ) == iTeam ) )
            Print( 
iPlayer id szMessage );
        
    return 
PLUGIN_HANDLED;
}

Print( 
id colorid szMessage[] )
{
    
message_beginid MSG_ONE_UNRELIABLE MSG_BROADCASTg_iMsgSayText, {0,0,0} , id );
    
write_bytecolorid );
    
write_stringszMessage );
    
message_end();
}

SaveArray( const SourceArray[] , iSize DestString[] )
{
    new 
iPos = -SourceTmp];
    
    for ( new 
iSize i++ )
    {        
        if ( ( 
SourceArray] > g_MaxNumber ) || ( SourceArray] < -g_MaxNumber ) )
            return 
0;
                
        
SourceTmp] = SourceArray];
        
        ++
iPos;
        
        if ( 
SourceTmp] < )
        {
            
DestStringiPos ] = ( << );
            
SourceTmp] *= -1;
        }
        
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
        
DestStringiPos ] |=  SourceTmp};
        
DestString[ ++iPos ] = SourceTmp} ? SourceTmp} : g_DummyChar;
        
DestString[ ++iPos ] = SourceTmp} ? SourceTmp} : g_DummyChar;
        
DestString[ ++iPos ] = SourceTmp} ? SourceTmp} : g_DummyChar;
    }
    
    return 
1;
}

LoadArray( const SourceString[] , iLen DestArray[] )
{
    new 
iPos = -1;
    
    for ( new 
iLen += 
    { 
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceStringi     ] & ~0xF8;
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceString];
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceString]; 
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceString];
        
        
DestArray[ ( ) ] *= ( SourceString] & ( << ) ) ? -1;
    }
    
    return 
1


Sry... but can U make it without leavemesage???

And one more thing , now I can use Admin Chat Colors and This plugin and no double post?

Last edited by Melisko; 03-13-2010 at 16:49. Reason: chat
Melisko is offline
Melisko
Senior Member
Join Date: Feb 2010
Old 03-13-2010 , 17:49   Re: Connections Counter
Reply With Quote #19

Omg.... I tested it and problems are same!!! Why U cannot block deathchat and make green text for admins??? omg.... Also top15 for playtime will be good

Last edited by Melisko; 03-13-2010 at 17:52. Reason: top
Melisko is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-13-2010 , 17:55   Re: Connections Counter
Reply With Quote #20

Bugsy, would you mind explaining these parts?
PHP Code:
SaveArray( const SourceArray[] , iSize DestString[] )
{
    new 
iPos = -SourceTmp];
    
    for ( new 
iSize i++ )
    {        
        if ( ( 
SourceArray] > g_MaxNumber ) || ( SourceArray] < -g_MaxNumber ) )
            return 
0;
                
        
SourceTmp] = SourceArray];
        
        ++
iPos;
        
        if ( 
SourceTmp] < )
        {
            
DestStringiPos ] = ( << );
            
SourceTmp] *= -1;
        }
        
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
DestStringiPos ] |= SourceTmp} ? : ( << );
        
        
DestStringiPos ] |=  SourceTmp};
        
DestString[ ++iPos ] = SourceTmp} ? SourceTmp} : g_DummyChar;
        
DestString[ ++iPos ] = SourceTmp} ? SourceTmp} : g_DummyChar;
        
DestString[ ++iPos ] = SourceTmp} ? SourceTmp} : g_DummyChar;
    }
    
    return 
1;
}

LoadArray( const SourceString[] , iLen DestArray[] )
{
    new 
iPos = -1;
    
    for ( new 
iLen += 
    { 
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceStringi     ] & ~0xF8;
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceString];
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceString]; 
        
DestArray{ ++iPos } = ( SourceString] & ( << ) ) ? SourceString];
        
        
DestArray[ ( ) ] *= ( SourceString] & ( << ) ) ? -1;
    }
    
    return 
1

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 04:29.


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