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

command limiter.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LambStar
Member
Join Date: Aug 2012
Location: UAE
Old 09-03-2012 , 15:50   command limiter.
Reply With Quote #1

Hey guys,

Can any one tell me why ain't i able to compile this ?

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < sqlvault_ex >

#define MAX_COMMAND_SIZE      64

#define MAX_PLAYERS           32

enum _:CommandData
{
    
Command_iMaxUses,
    
Command_iMaxTime
};

new Array:
g_aCommands;
new 
g_iNumCommands;

new 
Trie:g_tCommandToIndex;

// g_aPlayerUsage[ iPlayer ] = Array( iCommandIndex => aCommandUsage )
//     aCommandUsage = Array( time, time, ... )

new Array:g_aPlayerUsageMAX_PLAYERS ];

new 
g_szSteamIDMAX_PLAYERS ][ 35 ];

new 
g_pCvarFlag;

new 
SQLVault:g_hVault;

public 
plugin_init( )
{
    
register_plugin"Command Limiter silver""0.0.1""Exolent" );
    
    
g_pCvarFlag register_cvar"command_limiter_silver""s" );
    
    
g_aCommands ArrayCreateCommandData );
    
g_tCommandToIndex TrieCreate( );
    
    new 
iMaxPlayers get_maxplayers( );
    
    for( new 
iPlayer 1iPlayer <= iMaxPlayersiPlayer++ )
    {
        
g_aPlayerUsageiPlayer ] = ArrayCreate( );
    }
    
    
g_hVault sqlv_open_local"command_limiter_silver"false );
    
    if( !
sqlv_init_exg_hVault ) )
    {
        
set_fail_state"Error opening SQLVault" );
    }
    
    
sqlv_connectg_hVault );
    
    
LoadCommandsiMaxPlayers );
}

public 
plugin_end( )
{
    
sqlv_closeg_hVault );
}

public 
client_authorizediPlayer )
{
    
get_user_authidiPlayerg_szSteamIDiPlayer ], charsmaxg_szSteamID[ ] ) );
    
    
LoadPlayerUsageiPlayer );
}

public 
client_disconnectiPlayer )
{
    for( new 
iCommandIndex 0iCommandIndex g_iNumCommandsiCommandIndex++ )
    {
        
ArrayClearArrayGetCellg_aPlayerUsageiPlayer ], iCommandIndex ) );
    }
}

public 
client_commandiPlayer )
{
    if( 
accessiPlayerGetFlag( ) ) )
    {
        static 
szCommandMAX_COMMAND_SIZE ];
        
read_argv0szCommandcharsmaxszCommand ) );
        
strtolowerszCommand );
        
        new 
iCommandIndex;
        
        if( 
TrieGetCellg_tCommandToIndexszCommandiCommandIndex ) )
        {
            static 
eCommandDataCommandData ];
            
ArrayGetArrayg_aCommandsiCommandIndexeCommandData );
            
            new Array:
aUsageTimes ArrayGetCellg_aPlayerUsageiPlayer ], iCommandIndex );
            
            new 
iTotalUsage ArraySizeaUsageTimes );
            
            new 
iUnixTime get_systime( );
            
            new 
bool:bUpdate;
            
            while( 
iTotalUsage && ( iUnixTime eCommandDataCommand_iMaxTime ] ) >= ArrayGetCellaUsageTimes) )
            {
                
ArrayDeleteItemaUsageTimes);
                
                
iTotalUsage--;
                
                
bUpdate true;
            }
            
            if( 
iTotalUsage eCommandDataCommand_iMaxUses ] )
            {
                
ArrayPushCellaUsageTimesiUnixTime );
                
                
SavePlayerUsageiPlayerszCommandaUsageTimes );
            }
            else
            {
                if( 
bUpdate )
                {
                    
SavePlayerUsageiPlayerszCommandaUsageTimes );
                }
                
                return 
PLUGIN_HANDLED;
            }
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

LoadCommandsiMaxPlayers )
{
    new 
szFile64 ];
    
get_configsdirszFilecharsmaxszFile ) );
    
addszFilecharsmaxszFile ), "/command_limiter_silver.ini" );
    
    new 
pFile fopenszFile"rt" );
    
    if( 
pFile )
    {
        new 
szLine128 ];
        
        new 
szCommandMAX_COMMAND_SIZE ];
        new 
szMaxUses12 ];
        new 
szMaxTime12 ];
        
        new 
eCommandDataCommandData ];
        
        new 
iPlayer;
        
        while( !
feofpFile ) )
        {
            
fgetspFileszLinecharsmaxszLine ) );
            
trimszLine );
            
            if( !
szLine] || szLine] == ';' || szLine] == '/' && szLine] == '/' )
            {
                continue;
            }
            
            
parseszLineszCommandcharsmaxszCommand ), szMaxUsescharsmaxszMaxUses ), szMaxTimecharsmaxszMaxTime ) );
            
            
strtolowerszCommand );
            
            if( 
TrieKeyExistsg_tCommandToIndexszCommand ) )
            {
                continue;
            }
            
            
eCommandDataCommand_iMaxUses ] = str_to_numszMaxUses );
            
eCommandDataCommand_iMaxTime ] = str_to_numszMaxTime );
            
            
ArrayPushArrayg_aCommandseCommandData );
            
            
TrieSetCellg_tCommandToIndexszCommandg_iNumCommands );
            
            for( 
iPlayer 1iPlayer <= iMaxPlayersiPlayer++ )
            {
                
ArrayPushCellg_aPlayerUsageiPlayer ], ArrayCreate( ) );
            }
            
            
g_iNumCommands++;
        }
        
        
fclosepFile );
    }
}

GetFlag( )
{
    new 
szFlags];
    
get_pcvar_stringg_pCvarFlagszFlagscharsmaxszFlags ) );
    
    return 
read_flagsszFlags );
}

LoadPlayerUsageiPlayer )
{
    new 
szWhere64 ];
    
formatexszWherecharsmaxszWhere ), "`key1` = '%s'"g_szSteamIDiPlayer ] );
    
    new Array:
aVaultData;
    new 
iNumEntries sqlv_read_all_exg_hVaultaVaultDataszWhere"`key2` ASC" );
    
    new 
eVaultDataSQLVaultEntryEx ];
    
    new 
iCommandIndex;
    new 
eCommandDataCommandData ];
    
    new Array:
aUsageTimes;
    new 
iNumTimes;
    
    new 
iStartiPos;
    new 
szTime12 ], iTime;
    
    new 
iUnixTime get_systime( );
    
    for( new 
0iNumEntriesi++ )
    {
        
ArrayGetArrayaVaultDataieVaultData );
        
        if( 
TrieGetCellg_tCommandToIndexeVaultDataSQLVEx_Key2 ], iCommandIndex ) )
        {
            
ArrayGetArrayg_aCommandsiCommandIndexeCommandData );
            
            
aUsageTimes ArrayGetCellg_aPlayerUsageiPlayer ], iCommandIndex );
            
iNumTimes 0;
            
            
iStart 0;
            
            while( 
iNumTimes eCommandDataCommand_iMaxUses ] && ( iPos containeVaultDataSQLVEx_Data ][ iStart ], ";" ) ) > )
            {
                
copyszTimemincharsmaxszTime ), iPos ), eVaultDataSQLVEx_Data ][ iStart ] );
                
                
iTime str_to_numszTime );
                
                if( ( 
iUnixTime eCommandDataCommand_iMaxTime ] ) >= iTime )
                {
                    if( 
iNumTimes++ )
                    {
                        
ArrayInsertCellBeforeaUsageTimes0iTime );
                    }
                    else
                    {
                        
ArrayPushCellaUsageTimesiTime );
                    }
                }
            }
        }
    }
}

SavePlayerUsageiPlayerszCommand[ ], Array:aUsageTimes )
{
    new 
szTimes256 ], iLen;
    
    for( new 
ArraySizeaUsageTimes ) - 1>= 0i-- )
    {
        
iLen += formatexszTimesiLen ], charsmaxszTimes ) - iLen"%d;"ArrayGetCellaUsageTimes) );
    }
    
    
sqlv_set_data_exg_hVaultg_szSteamIDiPlayer ], szCommandszTimes );

This error comes when i compile :
Quote:
/tmp/text0TLAnl.sma(3) : fatal error 100: cannot read from file: "sqlvault_ex"
Please compile it or tell me how to do

Thanks.

Last edited by LambStar; 09-03-2012 at 15:53.
LambStar is offline
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 09-03-2012 , 16:26   Re: command limiter.
Reply With Quote #2

You don't have sqlvault_ex.inc in your includes folder. It's required to compile this plugin.
gogicaa is offline
LambStar
Member
Join Date: Aug 2012
Location: UAE
Old 09-04-2012 , 04:45   Re: command limiter.
Reply With Quote #3

okay i tried that way but now its like ,

Quote:
Could not locate output file C:\Documents and settings\vipul\desktop\Compiled\command_limit er_flags.amx (compile failed)
So now what should i do ?
LambStar is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 09-04-2012 , 04:56   Re: command limiter.
Reply With Quote #4

Quote:
Originally Posted by LambStar View Post
okay i tried that way but now its like ,



So now what should i do ?
You need to put the sma file in a folder with amxxpc.exe / compliter.exe
__________________
simanovich is offline
LambStar
Member
Join Date: Aug 2012
Location: UAE
Old 09-04-2012 , 06:15   Re: command limiter.
Reply With Quote #5

okay i did that way but , this comes but it dint compile



I did this way


Last edited by LambStar; 09-04-2012 at 06:20.
LambStar is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 09-04-2012 , 07:51   Re: command limiter.
Reply With Quote #6

I think you need put all compliters dlls
__________________
simanovich is offline
LambStar
Member
Join Date: Aug 2012
Location: UAE
Old 09-04-2012 , 10:58   Re: command limiter.
Reply With Quote #7

what ? i dint understand
LambStar is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 09-04-2012 , 10:59   Re: command limiter.
Reply With Quote #8

You are missing the compiler files. Redownload AMXX and copy all of the scripting folder over
__________________
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:17.


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