Raised This Month: $68 Target: $400
 17% 

Plugin Event VIP FREE [UPDATE - V4.0]


Post New Thread Reply   
 
Thread Tools Display Modes
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-31-2019 , 11:11   Re: Plugin Event VIP FREE [UPDATE - V4.0]
Reply With Quote #11

Better way

PHP Code:
#include < amxmodx >
#include < amxmisc > 
#include < engine >
#include < hamsandwich >

#define MAX_PLAYERS         32
#define VIP_FLAG            ADMIN_LEVEL_H
#define PLUGIN_VERSION      "1.2"

new g_iCvars];

new 
bool:g_bFreeVipTimebool:g_bAlreadyVipMAX_PLAYERS ];

new 
g_iCacheFlagsMAX_PLAYERS ];

const 
g_iFlagsBitsum = ( VIP_FLAG // you can add multiple flags ( VIP_FLAG | FLAG_1 | FLAG_2 )

public plugin_init( )
{
    
register_plugin"Free VIP"PLUGIN_VERSION"DoNii" );

    
register_cvar"free_vip_version"PLUGIN_VERSIONFCVAR_SERVER FCVAR_SPONLY FCVAR_UNLOGGED )
    
    
register_event"HLTV""OnNewRound""a""1=0""2=0" );

    
RegisterHamHam_Spawn"player""fw_HamSpawnPost");
    
    
g_iCvars] = register_cvar"free_vip_on""1" );
    
g_iCvars] = register_cvar"free_vip_start_time""15" );
    
g_iCvars] = register_cvar"free_vip_end_time""22" );
}

public 
plugin_natives( )
{
    
register_library"free_vip" );
    
register_native"is_free_vip_time""native_is_free_vip_time" );
}

public 
native_is_free_vip_timeiPluginiParams )
{
    return 
g_bFreeVipTime;
}

public 
client_putinserverid )
{
    
g_bAlreadyVipid ] = ( get_user_flagsid ) & VIP_FLAG ) ? true false;
}

public 
client_disconnectid )
{
    
ResetFlagsToDefaultid );
    
    
g_bAlreadyVipid ] = false;
    
g_iCacheFlagsid ] = 0;
}

public 
OnNewRound( )
{
    if( ! 
get_pcvar_numg_iCvars] ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    
g_bFreeVipTime IsVipHourget_pcvar_numg_iCvars] ), get_pcvar_numg_iCvars] ) );
    
    return 
PLUGIN_CONTINUE;
}

public 
fw_HamSpawnPostid )
{
    if( ! 
is_user_aliveid ) || is_user_botid ) || ! get_pcvar_numg_iCvars] ) )
    return 
HAM_IGNORED;
    
    if( 
g_bFreeVipTime )
    {
        if( 
get_user_flagsid ) & ADMIN_USER && ! g_bAlreadyVipid ] )
        {
            
g_iCacheFlagsid ] = get_user_flagsid ); // cache his flags
            
SetVipFlagid );
        }
    }
    
    else
    {
        if( ! 
g_bAlreadyVipid ] && ( get_user_flagsid ) & VIP_FLAG ) )
        {
            
ResetFlagsBackid ); // time expired so should the flag
        
}
    }    
    return 
HAM_IGNORED;
}

ResetFlagsToDefaultid )
{
    
remove_user_flagsid )
    
set_user_flagsidADMIN_USER );
}

ResetFlagsBackid )
{
    
remove_user_flagsid );    
    
set_user_flagsidg_iCacheFlagsid ] );
}

SetVipFlagid )
{
    if( 
get_user_flagsid ) & ADMIN_USER )
    {
        
remove_user_flagsidADMIN_USER );
    }
    
set_user_flagsidg_iFlagsBitsum );
}

bool:IsVipHouriStartiEnd )
{
    new 
iHourtimeiHour );
    return 
bool:( iStart iEnd ? ( iStart <= iHour iEnd ) : ( iStart <= iHour || iHour iEnd ) )

__________________

Last edited by edon1337; 09-02-2019 at 14:01.
edon1337 is offline
Send a message via Skype™ to edon1337
Reply


Thread Tools
Display Modes

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:11.


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