AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   command limiter. (https://forums.alliedmods.net/showthread.php?t=195111)

LambStar 09-03-2012 15:50

command limiter.
 
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.

gogicaa 09-03-2012 16:26

Re: command limiter.
 
You don't have sqlvault_ex.inc in your includes folder. It's required to compile this plugin.

LambStar 09-04-2012 04:45

Re: command limiter.
 
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 ?

simanovich 09-04-2012 04:56

Re: command limiter.
 
Quote:

Originally Posted by LambStar (Post 1790989)
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

LambStar 09-04-2012 06:15

Re: command limiter.
 
okay i did that way but , this comes but it dint compile

http://i46.tinypic.com/e6f5nb.jpg

I did this way

http://i48.tinypic.com/29pwyfm.jpg

simanovich 09-04-2012 07:51

Re: command limiter.
 
I think you need put all compliters dlls

LambStar 09-04-2012 10:58

Re: command limiter.
 
what ? i dint understand :(

YamiKaitou 09-04-2012 10:59

Re: command limiter.
 
You are missing the compiler files. Redownload AMXX and copy all of the scripting folder over


All times are GMT -4. The time now is 08:15.

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