Raised This Month: $32 Target: $400
 8% 

Hours is not saved


Post New Thread Reply   
 
Thread Tools Display Modes
smiley92
Senior Member
Join Date: Jun 2011
Location: Romania
Old 11-24-2013 , 01:47   Re: Plugin don't work
Reply With Quote #11

Quote:
Originally Posted by fysiks View Post
I just tried to read it but I'm having trouble since it's not really in comprehensible English.
Sorry for my bad English, but I don't use translate because not translate good.Is very simple what I want, just can't explain detailed.

Plugin is bugged to saved hours, minutes that is idea.Him don't function good because hours is problem here.
smiley92 is offline
Old 11-25-2013, 10:02
smiley92
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
smiley92
Senior Member
Join Date: Jun 2011
Location: Romania
Old 02-27-2015 , 14:51   Re: Hours is not saved
Reply With Quote #12

UP!?

That plugin from topic, don`t save warns when day is finish..that is problem with him.I want to be saved hours played, and if some admins don`t have hours what I`m put on cvar, (eg. 3 hours) to receive 1 warn but that when day is finish (after 24h).

Last edited by smiley92; 02-27-2015 at 14:55.
smiley92 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-01-2015 , 15:35   Re: Hours is not saved
Reply With Quote #13

I re-wrote this for you, will post when done.
__________________

Last edited by Bugsy; 03-01-2015 at 20:57.
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-02-2015 , 19:30   Re: Hours is not saved
Reply With Quote #14

I have not thoroughly tested this so let me know if you have any issues. You have to use the nvault_util include file I attached below because it has a new function I had to create that doesn't exist yet in the include file in the nvault utility thread.

Every aw_checkwarnsevery days, the plugin will:
  • Check all players warns and remove any that are greater than aw_warnexpiredays days old.
  • Check players play time and if it is less than their required time, it will issue a warn. When a warn is issued, their play time is reset to 0 because a new cycle is starting.
  • If warns are >= aw_maxwarns, their admin power is removed.
Each admins required play time (required hours per aw_checkwarnsevery cycle) must be set in admini.ini in the configs folder in the below format.
Code:
"STEAM_0:0:11111" "7"
"STEAM_0:0:22222" "7"
"STEAM_0:0:33333" "14"
To calculate the value for the config file, do aw_checkwarnsevery * desired number of hours per day. In the above example, the first 2 would be 1 hour per day, the third would be 2 hours per day if you have aw_checkwarnsevery set to 7.

If you set aw_maxwarns greater than 10, you must increase the MAX_WARNS value in the source and recompile. If you forget to update the code, you will see this error on map change: "Plugin cannot handle ad_maxwarns greater than X. Must increase MAX_WARNS in plugin source."

Update: Player will be shown the below message if they have any warns on record:
Code:
* You currently have 2 warns. You must play at least 2 hours per day or 14 hours per 7 day(s).
PHP Code:

#include <amxmodx>
#include <nvault_util>

new const Version[] = "0.3";

const 
AW_ADMIN_FLAG ADMIN_KICK;
const 
HOUR_SECONDS 3600;
const 
DAY_SECONDS 86400;
const 
MAX_WARNS 10;
const 
TASK_DELAYMSG 0x1234;

new const 
g_szFileName[] = "/admini.ini";
new const 
g_szVaultName[] = "adminwarning";

enum _:AdminData
{
    
ad_ConnectTime,
    
ad_TimePlayed,
    
ad_NumWarns,
    
ad_Warns]
};

new 
g_Vault g_pWarns g_pCheckWarnsEvery g_pWarnExpireDays g_Admins;
new 
g_szAuthIDMAX_PLAYERS ][ 34 ] , g_adDataMAX_PLAYERS ][ AdminData ];
new 
g_szConfigFile128 ] , g_szUsersFile128 ];

#define IsAdmin(%1)    ( g_Admins & ( 1 << ( %1 & 31 ) ) )

public plugin_init() 
{
    
register_plugin"Admin Warn" Version "bugsy" );
    
    
copyg_szConfigFileget_configsdirg_szConfigFile charsmaxg_szConfigFile ) ) ] , charsmaxg_szConfigFile ) , g_szFileName );
    
copyg_szUsersFileget_configsdirg_szUsersFile charsmaxg_szUsersFile ) ) ] , charsmaxg_szUsersFile ) , "/users.ini" );
    
    
g_pWarns register_cvar"aw_maxwarns" "5" );
    
g_pCheckWarnsEvery register_cvar"aw_checkwarnsevery" "7" );
    
g_pWarnExpireDays register_cvar"aw_warnexpiredays" "30" );
}

public 
plugin_cfg()
{
    new 
iDay iMaxWarns iWarnExpireDays iSysTime iPos bool:bRecordUpdated adDataAdminData ] , iVault iCount iTS szKey34 ] , szDay];
    
    if ( 
get_pcvar_numg_pWarns ) > MAX_WARNS )
        
set_fail_state"Plugin cannot handle ad_maxwarns greater than %d. Must increase MAX_WARNS in plugin source." MAX_WARNS ); 
        
    
dateiDay );
    
    if ( ( 
iDay get_pcvar_numg_pCheckWarnsEvery ) ) == )
    {
        
iMaxWarns get_pcvar_numg_pWarns );
        
iWarnExpireDays get_pcvar_numg_pWarnExpireDays );
        
iSysTime get_systime();
        
        
g_Vault nvault_openg_szVaultName );
        
        if ( 
nvault_getg_Vault "LastCheck" ) != iDay )
        {    
            
iVault nvault_util_openg_szVaultName );
            
iCount nvault_util_countiVault );
            
            
//Loop through all records in vault
            
for ( new iCount i++ )
            {
                
bRecordUpdated false;
                
iPos nvault_util_read_arrayiVault iPos szKey charsmaxszKey ) , adData sizeofadData ) , iTS );
    
                
//Check all existing warns and remove any that have expired.
                
for ( new iMaxWarns p++ )
                {
                    if ( 
adDataad_Warns ][ ] && ( adDataad_Warns ][ ] < ( iSysTime - ( iWarnExpireDays DAY_SECONDS ) ) ) )
                    {
                        
adDataad_Warns ][ ] = 0;
                        
adDataad_NumWarns ]--;
                        
bRecordUpdated true;
                    }
                }
                
                
//Check if player has played enough hours
                
if ( ( adDataad_TimePlayed ] / HOUR_SECONDS ) < GetRequiredTimeszKey ) )
                {
                    
//Not enough hours, issue warn.
                    // If this warn puts him over limit, remove admin.
                    
if ( ++adDataad_NumWarns ] >= iMaxWarns )
                    {
                        
RemoveAdminszKey );
                        
nvault_removeg_Vault szKey );
                        
bRecordUpdated false;
                    }
                    else
                    {
                        
//Add a warn and reset play time
                        
for ( new iMaxWarns p++ )
                        {
                            if ( 
adDataad_Warns ][ ] == 
                            {
                                
adDataad_Warns ][ ] = iSysTime;
                                
adDataad_TimePlayed ] = 0;
                                
bRecordUpdated true;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    
//Player played enough for the cycle. Reset play time.
                    
adDataad_TimePlayed ] = 0;
                    
bRecordUpdated true;
                }
                
                if ( 
bRecordUpdated )    
                    
nvault_set_arrayg_Vault szKey adData sizeofadData ) );
            }
            
nvault_util_closeiVault );
            
num_to_striDay szDay charsmaxszDay ) );
            
nvault_setg_Vault "LastCheck" szDay );
        }
        
nvault_closeg_Vault );
    }
    
    
g_Vault nvault_openg_szVaultName );
}

public 
plugin_end() 
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    
g_Admins |= ( get_user_flagsid ) & AW_ADMIN_FLAG ) ? ( << ( id 31 ) ) : 0;

    if ( 
IsAdminid ) )
    {
        
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) );
        
nvault_get_arrayg_Vault g_szAuthIDid ] , g_adDataid ] , sizeofg_adData[] ) );

        
g_adDataid ][ ad_ConnectTime ] = get_systime();
        
        if ( 
g_adDataid ][ ad_NumWarns ] )
        {
            
set_task7.0 "DelayMsg" id TASK_DELAYMSG g_adDataid ] , sizeofg_adData[] ) );
        }
    }
}

public 
client_disconnectid )
{
    if ( 
IsAdminid ) )
    {
        
g_adDataid ][ ad_TimePlayed ] = g_adDataid ][ ad_TimePlayed ] + ( get_systime() - g_adDataid ][ ad_ConnectTime ] );
        
nvault_set_arrayg_Vault g_szAuthIDid ] , g_adDataid ] , sizeofg_adData[] ) );
    }
}

public 
DelayMsg( const adData[] , iTaskID )
{
    
iTaskID -= TASK_DELAYMSG;
    
    new 
iRequiredTime GetRequiredTimeg_szAuthIDiTaskID ] );

    
client_printiTaskID print_chat "* You currently have %d warns. You must play at least %d hours per day or %d hours per %d day(s)." 
            
adDataad_NumWarns ] , iRequiredTime get_pcvar_numg_pCheckWarnsEvery ) , iRequiredTime get_pcvar_numg_pCheckWarnsEvery ) );

}

public 
GetRequiredTime( const szAuthID[] )
{
    new 
szData42 ] , szParseAuthID34 ] , szParseHours] , iFile iRequiredTime;
    
    if( !( 
iFile fopeng_szConfigFile "r" ) ) )
        return 
0;
    
    while( !
feofiFile ) )
    {
        
fgetsiFile szData charsmaxszData ) );
    
        if( 
szData] == ';' || szData] == '!' || ( szData] == '/' && szData] == '/' ) )
            continue;
    
        
parseszData szParseAuthID charsmaxszParseAuthID ) , szParseHours charsmaxszParseHours ) );

        if ( 
equaliszParseAuthID szAuthID ) ) 
        {
            
iRequiredTime str_to_numszParseHours );
            break;
        }
    }
    
    
fcloseiFile );
    
    return 
iRequiredTime;
}

public 
RemoveAdmin( const szAuthID[] )
{
    new 
szData155 ] , szParseAuthID34 ], szParsePassword32 ], szParseFlags32 ], szParseRFlags32 ], iFile iLine;
    
    if( !( 
iFile fopeng_szUsersFile "r" ) ) )
        return 
0;

    while( !
feofiFile  ) )
    {
        
fgetsiFile szData] , charsmaxszData[] ) - );
        
        
iLine++;
        
        if( 
szData] == ';' || szData] == '!' || ( szData] == '/' && szData] == '/' ) )
            continue;
        
        
parseszData] , szParseAuthID charsmaxszParseAuthID ) , szParsePassword charsmaxszParsePassword ) , szParseFlags charsmaxszParseFlags ) , szParseRFlags charsmaxszParseRFlags ) );
        
        if( 
equaliszParseAuthID szAuthID ) )
        {
            
szData] = ';'
            
formatexszData] , charsmaxszData ) - " ^"%s^" ^"%s^" ^"%s^" ^"%s^""szParseAuthID szParsePassword szParseFlags szParseRFlags );
            
            
write_fileg_szUsersFile szData iLine );
            break;
        }
    }
    
    
fcloseiFile  );
    
    return 
1;

Attached Files
File Type: inc nvault_util.inc (7.2 KB, 85 views)
__________________

Last edited by Bugsy; 07-25-2015 at 00:56.
Bugsy is offline
smiley92
Senior Member
Join Date: Jun 2011
Location: Romania
Old 03-05-2015 , 02:33   Re: Hours is not saved
Reply With Quote #15

Thanks, bugsy.

How many hours a day should do? 5 hours maybe?
Can make a cvar for that?I don`t see in plugin something about that and ask.
smiley92 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-05-2015 , 07:18   Re: Hours is not saved
Reply With Quote #16

5 sounds like a lot to me. Based on your description it sounded like there was a chance that different players would have different required play times since it was going in a config file next to the individual persons name/steamid. This can definitely go into a cvar, and I recommend doing so.
__________________

Last edited by Bugsy; 03-05-2015 at 07:29.
Bugsy is offline
smiley92
Senior Member
Join Date: Jun 2011
Location: Romania
Old 03-05-2015 , 08:18   Re: Hours is not saved
Reply With Quote #17

An admin can have 5 warns in 1 mounth, when he receive remove?

Last edited by smiley92; 03-05-2015 at 09:38.
smiley92 is offline
smiley92
Senior Member
Join Date: Jun 2011
Location: Romania
Old 03-06-2015 , 13:42   Re: Hours is not saved
Reply With Quote #18

* BUMP *
smiley92 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-06-2015 , 16:51   Re: Hours is not saved
Reply With Quote #19

That will take more work, I'll get to it when I have time. Please do not bump threads until 14 days have passed.
__________________

Last edited by Bugsy; 03-06-2015 at 16:52.
Bugsy is offline
smiley92
Senior Member
Join Date: Jun 2011
Location: Romania
Old 05-05-2015 , 16:45   Re: Hours is not saved
Reply With Quote #20

Something new?
smiley92 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 15:37.


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