AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Free VIP code. (https://forums.alliedmods.net/showthread.php?t=303072)

Str4x3D1x 11-21-2017 09:30

Free VIP code.
 
What's up with this? It does give flag i want, but not on time i want: (should be 21:00 at night 'till 09:00 morning). U guys know what's the problem? Here's code:

Code:

public Spawn(id)
{
        new hour
        time(hour)
       
        if(9 <= hour < 21)
        {
                HappyHour[id] = true
                if(get_user_flags(id) & ADMIN_USER && HappyHour[id])
                {
                        remove_user_flags(id, ADMIN_USER)
                        set_user_flags(id, ADMIN_LEVEL_C)
                       
                        set_hudmessage(0, 255, 0, -1.0, -1.0, 1, 6.0, 12.0, 0.5, 2.0)
                        show_hudmessage(id, "Happy Hour is ON! Enjoy free VIP :)")
                }
                       
                else if(get_user_flags(id) & ADMIN_KICK)
                {
                        set_user_flags(id, ADMIN_LEVEL_C)
                               
                        set_hudmessage(0, 255, 0, -1.0, -1.0, 1, 6.0, 12.0, 0.5, 2.0)
                        show_hudmessage(id, "Happy Hour is ON! Enjoy free VIP :)")
                               
                        AdminHappyHour[id] = true
                }
        }

        if(21 <= hour || hour < 9)
        {
                if(HappyHour[id])
                {
                        if(get_user_flags(id) & ADMIN_LEVEL_C)
                        {
                                remove_user_flags(id, ADMIN_LEVEL_C)
                                set_user_flags(id, ADMIN_USER)
                               
                                set_hudmessage(0, 255, 0, -1.0, -1.0, 1, 6.0, 12.0, 0.5, 2.0)
                                show_hudmessage(id, "Happy Hour is OFF! :)")
                        }
                        else if(get_user_flags(id) & ADMIN_KICK && get_user_flags(id) & ADMIN_LEVEL_C && AdminHappyHour[id])
                        {
                                remove_user_flags(id, ADMIN_LEVEL_C)
                               
                                set_hudmessage(0, 255, 0, -1.0, -1.0, 1, 6.0, 12.0, 0.5, 2.0)
                                show_hudmessage(id, "Happy Hour is OFF! :)")
                        }
                        HappyHour[id] = false
                }
        }
}


Napoleon_be 11-21-2017 10:09

Re: Free VIP code.
 
Who wrote this? I'm not sure if these parts are correct...

Code:
if(9 <= hour < 21)

Code:
if(21 <= hour || hour < 9)

Also, this could be optimized a lot.

Str4x3D1x 11-21-2017 14:21

Re: Free VIP code.
 
I don't know coding, can anyone fix this for me please?

Napoleon_be 11-21-2017 16:57

Re: Free VIP code.
 
I'll just wait till someone else wanna give his opinion about this.

edon1337 11-21-2017 16:59

Re: Free VIP code.
 
1 Attachment(s)
Credits to OciXCrom for his IsVipHour bool stock.
PHP Code:

#include < amxmodx >
#include < engine >
#include < hamsandwich >

#define VIP_FLAG ADMIN_LEVEL_H

new g_iCvars];

new 
bool:g_bFreeVipTime;

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

    
register_event"HLTV""OnNewRound""a""1=0""2=0" );
    
    
g_iCvars] = register_cvar"free_vip_on""1" );
    
g_iCvars] = register_cvar"free_vip_start_time""22" );
    
g_iCvars] = register_cvar"free_vip_end_time""10" );
}

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

public 
client_PostThinkid )
{
    if( 
g_bFreeVipTime )
    {
        
set_user_flagsidVIP_FLAG );
    }
}

public 
OnNewRound( )
{
    if( ! 
get_pcvar_numg_iCvars] ) )
    return 
PLUGIN_CONTINUE;

    if( 
IsVipHourget_pcvar_numg_iCvars] ), get_pcvar_numg_iCvars] ) ) )
    
g_bFreeVipTime true;
    
    else
    
g_bFreeVipTime false;
    
    return 
PLUGIN_CONTINUE;
}

public 
native_is_free_vip_timeiPluginiParams )
{
    return 
g_bFreeVipTime;
}

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



TheWhitesmith 11-21-2017 17:11

Re: Free VIP code.
 
hmmmmm, switch these 2 lines:
PHP Code:

if(<= hour 21

&
PHP Code:

if(21 <= hour || hour 9


TheWhitesmith 11-21-2017 17:12

Re: Free VIP code.
 
And next time please post in Scripting Help, this is not where to ask for such help

Str4x3D1x 11-22-2017 12:21

Re: Free VIP code.
 
Quote:

Originally Posted by Napoleon_be (Post 2561907)
Who wrote this?

I did. Why?

Quote:

Originally Posted by edon1337 (Post 2562048)
Credits to OciXCrom for his IsVipHour bool stock.
PHP Code:

#include < amxmodx >
#include < engine >
#include < hamsandwich >

#define VIP_FLAG ADMIN_LEVEL_H

new g_iCvars];

new 
bool:g_bFreeVipTime;

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

    
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""22" );
    
g_iCvars] = register_cvar"free_vip_end_time""10" );
}

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

public 
client_PostThinkid )
{
    if( 
g_bFreeVipTime )
    {
        
set_user_flagsidVIP_FLAG );
    }
}

public 
OnNewRound( )
{
    if( ! 
get_pcvar_numg_iCvars] ) )
    return 
PLUGIN_CONTINUE;

    if( 
IsVipHourget_pcvar_numg_iCvars] ), get_pcvar_numg_iCvars] ) ) )
    
g_bFreeVipTime true;
    
    else
    
g_bFreeVipTime false;
    
    if( 
g_bFreeVipTime )
    {
        new 
szPlayers32 ], iNum;
        
get_playersszPlayersiNum );

        static 
iTempID;
        
        for( new 
iiNumi++ )
        {
            
iTempID szPlayers];
            
            
set_user_flagsiTempIDVIP_FLAG );
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
fw_HamSpawnPostid )
{
    if( ! 
get_pcvar_numg_iCvars] ) )
    return 
HAM_IGNORED;
    
    if( 
g_bFreeVipTime )
    {
        
set_user_flagsidVIP_FLAG );
    }
    return 
HAM_IGNORED;
}

public 
native_is_free_vip_timeiPluginiParams )
{
    return 
g_bFreeVipTime;
}

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



Is this all really necessary ? This is (what i wrote at start of the thread) just a part of entire VIP plug-in i made. I mean i can try and fit your code, but again i'll need your include file...




Overall, i tried doing something over the code, still no use. Giving me ADMIN_LEVEL_C when it's not time for it.

PHP Code:

public Spawn(id)
{
    new 
hour
    time
(hour)
    
    if(
21 <= hour || hour 9)
    {
        
HappyHour[id] = true
        Ads
[id] = true

        
if(get_user_flags(id) & ADMIN_USER && HappyHour[id])
        {
            
remove_user_flags(idADMIN_USER)
            
set_user_flags(idADMIN_LEVEL_C)
            
            if(
Ads[id])
            {
                
set_hudmessage(02550, -1.0, -1.016.05.00.52.0)
                
show_hudmessage(id"Happy Hour is ON! Enjoy Free VIP :)")
            }
        }
        
        else if(
get_user_flags(id) & ADMIN_KICK)
        {
            if(
get_user_flags(id) & ADMIN_LEVEL_C)
            {
                return 
PLUGIN_CONTINUE
            
}
            else
            {
                
set_user_flags(idADMIN_LEVEL_C)
                
                if(
Ads[id])
                {
                    
set_hudmessage(02550, -1.0, -1.016.05.00.52.0)
                    
show_hudmessage(id"Happy Hour is ON! Enjoy Free VIP :)")
                }
                
                
AdminHappyHour[id] = true
            
}
        }
        
    }
    else
    {
        
AdminHappyHour[id] = false
        HappyHour
[id] = false

        
if(HappyHour[id])
        {
            if(
get_user_flags(id) & ADMIN_LEVEL_C)
            {
                
remove_user_flags(idADMIN_LEVEL_C)
                
                if(
Ads[id])
                {
                    
set_hudmessage(25500, -1.0, -1.016.05.00.52.0)
                    
show_hudmessage(id"Happy Hour is OFF! :)")
                }
            }
            
HappyHour[id] = false
        
}
        else if(
AdminHappyHour[id])
        {
            if(
get_user_flags(id) & ADMIN_LEVEL_C)
            {
                
remove_user_flags(idADMIN_LEVEL_C)
                
                if(
Ads[id])
                {
                    
set_hudmessage(25500, -1.0, -1.016.05.00.52.0)
                    
show_hudmessage(id"Happy Hour is OFF! :)")

                    
Ads[id] = false
                
}
            }
            
AdminHappyHour[id] = false
        
}
    }



TheWhitesmith 11-22-2017 13:53

Re: Free VIP code.
 
Check if your server time is the same as your local time. (Print hour and see if it's correct, if not fix it from the code)

Str4x3D1x 11-22-2017 13:54

Re: Free VIP code.
 
Hmm, and how do i see it? I can check my server's time by writing thetime.
You mean, nothing's wrong with the code above?

It shows time i want, no free VIP after 09:00 morning. Let's repeat:

Free VIP starts at 21:00PM (at night)
Free VIP ends at 09:00AM (morning)

And repeats, so 10:00 AM,11,12,13,14,15,16,17,18,19 and 20:00 AM shouldn't be free VIP.
I disabled default access z in amxx.cfg.


All times are GMT -4. The time now is 04:54.

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