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

Connections Counter


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 03-12-2010 , 04:46   Connections Counter
Reply With Quote #1

Here is my idea if someone know how to do it make it here

Count player connections and store in database.
If user have 100 connections => newbie
If user have 500 connections => semi-pro
If user have 750 connections => pro
If user have 1000 connections => veteran
-------------------------------------------------
Chat => [Veteran]Nickname
Scoretab => [Veteran]Nickname
Connect => Nickname is veterean in this server
-------------------------------------------------
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
Old 03-12-2010, 05:11
lazarev
This message has been deleted by lazarev. Reason: plugin was updated.
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 03-12-2010 , 05:16   Re: Connections Counter
Reply With Quote #2

Hey thank you
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
Old 03-12-2010, 05:35
lazarev
This message has been deleted by lazarev. Reason: update in next post.
Old 03-12-2010, 06:11
SpILL
This message has been deleted by SpILL. Reason: Needless comment.
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-12-2010 , 06:39   Re: Connections Counter
Reply With Quote #3

[EDIT] - 0.0.6: Added [Admin] tag
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < nvault >

new const VERSION[] = "0.0.6";
new const 
PREFIX[] = "[CC] ";

new 
Connects33 ];
new 
szConnectStatus33 ][ ];

new 
g_iMsgSayText;
new 
g_vSaveFile;

new 
iPlayers33 ][ 32 ];
new 
iNum33 ];

public 
plugin_init()
{
    
register_plugin"Connections Counter"VERSION"Juice" );
    
    
register_cvar"connects_count"VERSIONFCVAR_SERVER FCVAR_SPONLY ); 
    
    
register_clcmd"say""HookSay" );
    
register_clcmd"say_team""HookSay_Team" );
    
    
g_iMsgSayText get_user_msgid"SayText" );
    
    
g_vSaveFile nvault_open"ConnectCount" );
}

public 
client_putinserverid )
{
    if( !
is_user_botid ) )
    {
        if( 
task_existsid ) )
        {
            
remove_taskid );
        }
        
        
LoadDataid );
        ++
Connectsid ];
        
        if ( 
is_user_adminid ) )
        {
            
szConnectStatusid ] = "Admin";
        }
        else 
        {
            if( 
Connectsid ] <= 100 
            {
                
szConnectStatusid ] = "Newbie";
            }
            else if( 
100 Connectsid ] <= 500 )
            {
                
szConnectStatusid ] = "Semi-Pro";
            }
            else if( 
500 Connectsid ] <= 750 )
            {
                
szConnectStatusid ] = "Pro";
            }
            else if( 
Connectsid ] > 750 
            {
                
szConnectStatusid ] = "Veteran";
            }
        }
        
set_task2.0"PrintZ0r"id ); 
    }
}

public 
PrintZ0rid )
{
    new 
szName33 ];
    new 
szMessage256 ];
    
get_user_nameidszName32 );
    
formatszMessage255"^x04%s^x03%s have joined with^x04 %i^x03 Connections. [^x04Status: %s^x03]"PREFIXszNameConnectsid ], szConnectStatusid ] );
    Print( 
01szMessage )
}

public 
client_disconnectid 
{  
    if( !
is_user_botid ) )
    {
        
SaveDataid );
        if( 
task_existsid ) )
        {
            
remove_taskid );
        }
    }
}  

public 
SaveDataid 

    new 
szAuthID35 ];
    new 
vaultkey33 ], vaultdata13 ]; 
    
    
get_user_authididszAuthID34 );
    
    
formatvaultkey32"%s"szAuthID );
    
formatvaultdata12," %i "Connectsid ] ); 

    
nvault_setg_vSaveFilevaultkeyvaultdata ); 
    
    return 
PLUGIN_CONTINUE
}  

public 
LoadDataid 

    new 
szAuthID35 ]; 
    new 
vaultkey33 ], vaultdata13 ];
    new 
ConnectCount33 ];
    
    
get_user_authididszAuthID34 ); 
    
    
formatvaultkey32"%s"szAuthID ); 
    
formatvaultdata12," %i "Connectsid ] ); 
    
    
nvault_getg_vSaveFilevaultkeyvaultdata255 ); 
    
    
parsevaultdataConnectCount32); 
    
    
Connectsid ] = str_to_numConnectCount ); 
    
    return 
PLUGIN_CONTINUE
}  

public 
HookSayid )
{
    new 
szMessage192 ];
    
read_argsszMessage191 );
    
remove_quotesszMessage );
    
    new 
szName33 ];
    
get_user_nameidszName32 );
    
    if ( 
szMessage[0] == '@' || szMessage[0] == '/' || szMessage[0] == '!' || equal (szMessage"") )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if ( 
is_user_aliveid ) )
    {
        
formatszMessage255"^x04[%s]^x03 %s^x01 :  %s"szConnectStatusid ], szNameszMessage );
        Print(
0idszMessage)
    }
    else if ( 
cs_get_user_teamid ) != CS_TEAM_SPECTATOR )
    {
        
formatszMessage255"^x04[%s]^x01 *DEAD*^x03 %s^x01 :  %s"szConnectStatusid ], szNameszMessage );
        Print(
0idszMessage)
    }
    else 
    {
        
formatszMessage255"^x04[%s]^x01 *SPEC*^x03 %s^x01 :  %s"szConnectStatusid ], szNameszMessage );
        Print(
0idszMessage)
    }
    return 
PLUGIN_HANDLED;
}

public 
HookSay_Teamid )
{
    new 
szMessage192 ];
    
read_argsszMessage191 );
    
remove_quotesszMessage );
    
    new 
szName33 ], szTeam33 ];
    
get_user_nameidszName32 );
        
    new 
CsTeams:userteam cs_get_user_teamid );
        
    if ( 
szMessage[0] == '@' || szMessage[0] == '/' || szMessage[0] == '!' || equalszMessage"" ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if ( 
userteam == CS_TEAM_T )
    {
        
get_playersiPlayersid ], iNumid ], _"TERRORIST" );
        
szTeam "(Terrorist)";
    }
    else if ( 
userteam == CS_TEAM_CT )
    {
        
get_playersiPlayersid ], iNumid ], _"CT" );
        
szTeam "(Counter-Terrorists)";
    }
    else
    {
        
get_playersiPlayersid ], iNumid ], _"SPECTATOR" );
        
szTeam "(Spectator)";
    }
    for ( new 
0iNumid ]; ++)
    {
        new 
iPlayersid ][ ];
        if( 
cs_get_user_team) != userteam )
        {
            return 
PLUGIN_HANDLED;
        }
        
        if ( 
is_user_aliveid ) )
        {
            
formatszMessage255"^x04[%s]^x01 %s^x03 %s^x01 :  %s"szConnectStatusid ], szTeamszNameszMessage );
            Print( 
iidszMessage )
        }
        else if (!
is_user_alive(id) && userteam != CS_TEAM_SPECTATOR)
        {
            
formatszMessage255"^x04[%s]^x01 *DEAD* %s^x03 %s^x01 :  %s"szConnectStatusid ], szTeamszNameszMessage );
            Print( 
iidszMessage )
        }
        else
        {
            
formatszMessage255"^x04[%s]^x01 %s^x03 %s^x01 :  %s"szConnectStatusid ], szTeamszNameszMessage );
            Print( 
iidszMessage )
        }
    }
    return 
PLUGIN_HANDLED;
}

Print( 
idcoloridszMessage[], any:... )
{
    
message_beginid MSG_ONE_UNRELIABLE MSG_BROADCASTg_iMsgSayText_id );
    
write_bytecolorid );
    
write_stringszMessage );
    
message_end( );

servers running this plugin lol

Last edited by lazarev; 03-12-2010 at 06:57.
lazarev is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 03-12-2010 , 12:38   Re: Connections Counter
Reply With Quote #4

very good thanks again !
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-12-2010 , 12:59   Re: Connections Counter
Reply With Quote #5

np, any suggestions?
lazarev is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 03-12-2010 , 13:48   Re: Connections Counter
Reply With Quote #6

Maybe you can combine with this plugin http://forums.alliedmods.net/showthread.php?p=878874
If user have 100 connections => Veteran to can choose join/leaver messages ;]
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-12-2010 , 14:38   Re: Connections Counter
Reply With Quote #7

[EDIT] This version Saves leave message:
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < nvault >

new const VERSION[] = "0.0.8";
new const 
PREFIX[] = "[CC] ";

new 
Connects33 ];
new 
szConnectStatus33 ][ ];

new 
g_iMsgSayText;
new 
g_vSaveFile;

new 
iPlayers33 ][ 32 ];
new 
iNum33 ];

new 
g_szLeaveMessage33 ][ 64 ];

new 
bool:g_bVeteran33 ];

public 
plugin_init()
{
    
register_plugin"Advanced Connections Counter"VERSION"Juice" );
    
    
register_cvar"connects_count"VERSIONFCVAR_SERVER FCVAR_SPONLY ); 
    
    
register_clcmd"say""HookSay" );
    
register_clcmd"say_team""HookSay_Team" );
    
    
g_iMsgSayText get_user_msgid"SayText" );
    
    
g_vSaveFile nvault_open"ConnectCount" );
}

public 
client_putinserverid )
{
    if( !
is_user_botid ) )
    {
        if( 
task_existsid ) )
        {
            
remove_taskid );
        }
        
        
LoadDataid );
        ++
Connectsid ];
        
        if ( 
is_user_adminid ) )
        {
            
szConnectStatusid ] = "Admin";
            
g_bVeteranid ] = true;
        }
        else 
        {
            if( 
Connectsid ] <= 100 
            {
                
szConnectStatusid ] = "Newbie";
            }
            else if( 
100 Connectsid ] <= 500 )
            {
                
szConnectStatusid ] = "Semi-Pro";
            }
            else if( 
500 Connectsid ] <= 750 )
            {
                
szConnectStatusid ] = "Pro";
            }
            else if( 
Connectsid ] > 750 
            {
                
szConnectStatusid ] = "Veteran";
                
g_bVeteranid ] = true;
            }
        }
        
set_task2.0"PrintZ0r"id ); 
    }
}

public 
PrintZ0rid )
{
    new 
szName33 ], szMessage128 ];
    
get_user_nameidszName32 );
    
formatszMessage127"^x04%s^x03%s have joined with^x04 %i^x03 Connections. [^x04Status: %s^x03]"PREFIXszNameConnectsid ], szConnectStatusid ] );
    Print( 
01szMessage )
}

public 
client_disconnectid 
{  
    if( !
is_user_botid ) )
    {
        new 
szName33 ], szMessage128 ];
        
get_user_nameidszName32 );
        
SaveDataid );
        
        if( 
g_bVeteranid ] )
        {
            
formatszMessage127"^x04%s^x03Veteran: %s has left the server. [^x04Message: %s^x03]"PREFIXszNameg_szLeaveMessageid ] );
            Print( 
01szMessage )
            
g_bVeteranid ] = false;
        }
        else 
        {
            
g_szLeaveMessageid ] = " ";
        }
        if( 
task_existsid ) )
        {
            
remove_taskid );
        }
    }
}  

public 
SaveDataid 

    new 
szAuthID20 ];
    new 
vaultkey20 ], vaultdata128 ]; 
    
    
get_user_authididszAuthID19 );
    
    
formatvaultkey19"%s"szAuthID );
    
formatvaultdata127" %i %s "Connectsid ], g_szLeaveMessageid ] ); 

    
nvault_setg_vSaveFilevaultkeyvaultdata ); 
    
    return 
PLUGIN_CONTINUE
}  

public 
LoadDataid 

    new 
szAuthID20 ]; 
    new 
vaultkey20 ], vaultdata128 ];
    new 
ConnectCount33 ];
    new 
LeaveMsg64 ];
    
    
get_user_authididszAuthID19 ); 
    
    
formatvaultkey19"%s"szAuthID ); 
    
formatvaultdata127" %i %s "Connectsid ], g_szLeaveMessageid ] ); 
    
    
nvault_getg_vSaveFilevaultkeyvaultdata127 ); 
    
    
parsevaultdataConnectCount32LeaveMsg63 ); 
    
    
Connectsid ] = str_to_numConnectCount ); 
    
g_szLeaveMessageid ] = LeaveMsg;
    
    return 
PLUGIN_CONTINUE
}  

public 
HookSayid )
{
    new 
szMessage257 ];
    
read_argsszMessage256 );
    
remove_quotesszMessage );
    
    new 
szName33 ];
    
get_user_nameidszName32 );
    
    if( 
g_bVeteranid ] )
    {
        if( 
szMessage] == '/' && szMessage] == 'e' && szMessage] == 'v' && szMessage] == 'm' )
        {
            new 
Arg64 ];
            
strbreakszMessageszMessage95Arg63 );
            
remove_quotesArg );
        
            if( !
Arg] )
            {
                if( 
g_szLeaveMessageid ][ ] )
                {
                    
client_printidprint_chat"%sYour current leave message is ^"%s^""PREFIXg_szLeaveMessageid ] );
                }
                else
                {
                    
client_printidprint_chat"%sYou haven't set a leave message yet. To do so, type /leavemsg ^"message^"."PREFIX );
                }
            }
        
            else if( 
equaliArg"remove" ) )
            {
                
g_szLeaveMessageid ] = "No Message Set";
                
client_printidprint_chat"%sYour leave message was removed."PREFIX )
            }
            else
            {
                
copyg_szLeaveMessageid ], 63Arg )
                
client_printidprint_chat"%sYour leave message has been set to ^"%s^""PREFIXArg );
            }
            return 
PLUGIN_CONTINUE;
        }
    }
    
    if ( 
szMessage[0] == '@' || szMessage[0] == '/' || szMessage[0] == '!' || equal (szMessage"") )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if ( 
is_user_aliveid ) )
    {
        
formatszMessage255"^x04[%s]^x03 %s^x01 :  %s"szConnectStatusid ], szNameszMessage );
        Print(
0idszMessage)
    }
    else if ( 
cs_get_user_teamid ) != CS_TEAM_SPECTATOR )
    {
        
formatszMessage255"^x04[%s]^x01 *DEAD*^x03 %s^x01 :  %s"szConnectStatusid ], szNameszMessage );
        Print(
0idszMessage)
    }
    else 
    {
        
formatszMessage255"^x04[%s]^x01 *SPEC*^x03 %s^x01 :  %s"szConnectStatusid ], szNameszMessage );
        Print(
0idszMessage)
    }
    return 
PLUGIN_HANDLED;
}

public 
HookSay_Teamid )
{
    new 
szMessage257 ];
    
read_argsszMessage256 );
    
remove_quotesszMessage );
    
    new 
szName33 ], szTeam33 ];
    
get_user_nameidszName32 );
        
    new 
CsTeams:userteam cs_get_user_teamid );

    if ( 
szMessage[0] == '@' || szMessage[0] == '/' || szMessage[0] == '!' || equalszMessage"" ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if ( 
userteam == CS_TEAM_T )
    {
        
get_playersiPlayersid ], iNumid ], _"TERRORIST" );
        
szTeam "(Terrorist)";
    }
    else if ( 
userteam == CS_TEAM_CT )
    {
        
get_playersiPlayersid ], iNumid ], _"CT" );
        
szTeam "(Counter-Terrorists)";
    }
    else
    {
        
get_playersiPlayersid ], iNumid ], _"SPECTATOR" );
        
szTeam "(Spectator)";
    }
    for ( new 
0iNumid ]; ++)
    {
        new 
iPlayersid ][ ];
        if( 
cs_get_user_team) != userteam )
        {
            return 
PLUGIN_HANDLED;
        }
        
        if ( 
is_user_aliveid ) )
        {
            
formatszMessage255"^x04[%s]^x01 %s^x03 %s^x01 :  %s"szConnectStatusid ], szTeamszNameszMessage );
            Print( 
iidszMessage )
        }
        else if (!
is_user_alive(id) && userteam != CS_TEAM_SPECTATOR)
        {
            
formatszMessage255"^x04[%s]^x01 *DEAD* %s^x03 %s^x01 :  %s"szConnectStatusid ], szTeamszNameszMessage );
            Print( 
iidszMessage )
        }
        else
        {
            
formatszMessage255"^x04[%s]^x01 %s^x03 %s^x01 :  %s"szConnectStatusid ], szTeamszNameszMessage );
            Print( 
iidszMessage )
        }
    }
    return 
PLUGIN_HANDLED;
}

Print( 
idcoloridszMessage[], any:... )
{
    
message_beginid MSG_ONE_UNRELIABLE MSG_BROADCASTg_iMsgSayText_id );
    
write_bytecolorid );
    
write_stringszMessage );
    
message_end( );


Last edited by lazarev; 03-12-2010 at 15:14. Reason: update to 0.0.8
lazarev is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 03-12-2010 , 23:55   Re: Connections Counter
Reply With Quote #8

You are the best dude ever I own you one
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-13-2010 , 01:13   Re: Connections Counter
Reply With Quote #9

Just a few things you should correct:

1. You should not call any functions on a player at client_disconnect() because there are times when the player will already be gone when this is called. It is better to cache a players name and steam-id into global strings; this solves the disconnect problem and it also saves you numerous native calls. You may notice that you do not run into any errors while testing but your plugin will occasionally error when left running.

2. In SaveData() you are retrieving the users authid into szAuthID and then copying it to vaultkey for your nvault_set() call. Why not just use szAuthID as your key?

3. formatex() should be used instead of format().

4. In LoadData you are formatting vaultdata with the users data but then read data from vault into this string. This makes no sense because you format the string with data just to immediately over-write it with data read from vault.

5. You can call remove_task without calling task_exists.

6. iPlayers[] can be defined locally in HookSay_Team() since it is not used anywhere else in plugin.

7. Calling get_players() with a team name but without flag "e" which tells it you want to pass a team name. See http://www.amxmodx.org/funcwiki.php?go=func&id=174

8. nVault never closed. Add plugin_end() and call nvault_close().

There may be more but I'm tired.

Optional, but you can do something like this to make variables and code neater:
PHP Code:
enum StatusLevels
{
    
Newbie,
    
SemiPro,
    
Pro,
    
Veteran
}

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

new const 
iStatusLevels[][] = 
{
    { 
100 },
    { 
101 500 },
    { 
501 750 },
    { 
751 99999 }
}

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

new 
g_PData33 ][ PlayerData ];

get_user_nameid g_PDataid ][ Name ] , charsmaxg_PData[] ) );
get_user_authidid g_PDataid ][ AuthID ] , charsmaxg_PData[] ) ); 
__________________

Last edited by Bugsy; 03-13-2010 at 11:05.
Bugsy is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 03-13-2010 , 09:49   Re: Connections Counter
Reply With Quote #10

Maybe you can add playtime ?
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
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 14:54.


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