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

Free VIP code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Str4x3D1x
Member
Join Date: Feb 2014
Old 11-21-2017 , 09:30   Free VIP code.
Reply With Quote #1

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
		}
	}
}
__________________
First you learn to read. Then you read to learn.
Str4x3D1x is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-21-2017 , 10:09   Re: Free VIP code.
Reply With Quote #2

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.
__________________

Last edited by Napoleon_be; 11-21-2017 at 10:10.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Str4x3D1x
Member
Join Date: Feb 2014
Old 11-21-2017 , 14:21   Re: Free VIP code.
Reply With Quote #3

I don't know coding, can anyone fix this for me please?
__________________
First you learn to read. Then you read to learn.
Str4x3D1x is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-21-2017 , 16:57   Re: Free VIP code.
Reply With Quote #4

I'll just wait till someone else wanna give his opinion about this.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-21-2017 , 16:59   Re: Free VIP code.
Reply With Quote #5

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 ) )

Attached Files
File Type: inc free_vip.inc (111 Bytes, 977 views)
__________________

Last edited by edon1337; 06-27-2018 at 11:35.
edon1337 is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-21-2017 , 17:11   Re: Free VIP code.
Reply With Quote #6

hmmmmm, switch these 2 lines:
PHP Code:
if(<= hour 21
&
PHP Code:
if(21 <= hour || hour 9
TheWhitesmith is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-21-2017 , 17:12   Re: Free VIP code.
Reply With Quote #7

And next time please post in Scripting Help, this is not where to ask for such help
TheWhitesmith is offline
Str4x3D1x
Member
Join Date: Feb 2014
Old 11-22-2017 , 12:21   Re: Free VIP code.
Reply With Quote #8

Quote:
Originally Posted by Napoleon_be View Post
Who wrote this?
I did. Why?

Quote:
Originally Posted by edon1337 View Post
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
        
}
    }

__________________
First you learn to read. Then you read to learn.
Str4x3D1x is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-22-2017 , 13:53   Re: Free VIP code.
Reply With Quote #9

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)
TheWhitesmith is offline
Str4x3D1x
Member
Join Date: Feb 2014
Old 11-22-2017 , 13:54   Re: Free VIP code.
Reply With Quote #10

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.
__________________
First you learn to read. Then you read to learn.

Last edited by Str4x3D1x; 11-22-2017 at 14:08.
Str4x3D1x 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 23:16.


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