Raised This Month: $51 Target: $400
 12% 

VIP EVENT Add Dhud permanent Happy Hour


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 04-10-2018 , 05:32   VIP EVENT Add Dhud permanent Happy Hour
Reply With Quote #1

Hello, can anyone add to this sma a permanent dhud message? at the top in the middle. In green color like: Free VIP Happy Hour from 23 to 10 it would be cool. THX

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

#define VIP_FLAG ADMIN_LEVEL_H

new g_iCvars[ 3 ];

new bool:g_bFreeVipTime;

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

    register_event( "HLTV", "OnNewRound", "a", "1=0", "2=0" );

    RegisterHam( Ham_Spawn, "player", "fw_HamSpawnPost", 1 );
    
    g_iCvars[ 0 ] = register_cvar( "free_vip_on", "1" );
    g_iCvars[ 1 ] = register_cvar( "free_vip_start_time", "22" );
    g_iCvars[ 2 ] = 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", 0 );
}

public client_PostThink( id )
{
    if( g_bFreeVipTime )
    {
        set_user_flags( id, VIP_FLAG );
    }
}

public OnNewRound( )
{
    if( ! get_pcvar_num( g_iCvars[ 0 ] ) )
    return PLUGIN_CONTINUE;

    if( IsVipHour( get_pcvar_num( g_iCvars[ 1 ] ), get_pcvar_num( g_iCvars[ 2 ] ) ) )
    g_bFreeVipTime = true;
    
    else
    g_bFreeVipTime = false;
    
    if( g_bFreeVipTime )
    {
        new szPlayers[ 32 ], iNum;
        get_players( szPlayers, iNum );

        static iTempID;
        
        for( new i; i < iNum; i++ )
        {
            iTempID = szPlayers[ i ];
            
            set_user_flags( iTempID, VIP_FLAG );
        }
    }
    return PLUGIN_CONTINUE;
}

public fw_HamSpawnPost( id )
{
    if( ! get_pcvar_num( g_iCvars[ 0 ] ) )
    return HAM_IGNORED;
    
    if( g_bFreeVipTime )
    {
        set_user_flags( id, VIP_FLAG );
    }
    return HAM_IGNORED;
}

public native_is_free_vip_time( iPlugin, iParams )
{
    return g_bFreeVipTime;
}

bool:IsVipHour( iStart, iEnd )
{
    new iHour; time( iHour );
    return bool:( iStart < iEnd ? ( iStart <= iHour < iEnd ) : ( iStart <= iHour || iHour < iEnd ) )
}

Last edited by Godofwar; 04-13-2018 at 03:04.
Godofwar is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-10-2018 , 05:38   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #2

If the code works then you can just edit the cvars.
__________________
Relaxing is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 04-10-2018 , 05:41   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #3

The code is working but it dont show a hud event msg.. there is no cvar about this :/

Last edited by Godofwar; 04-10-2018 at 05:43.
Godofwar is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-10-2018 , 07:04   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #4

When do you want it do be displayed?
__________________

Last edited by Relaxing; 04-10-2018 at 07:05.
Relaxing is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 04-10-2018 , 07:14   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #5

permanent , only in VIP Free Event Time when possible.
Godofwar is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-10-2018 , 08:03   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #6

Code:
// You can use id but I did it for an event // which doesn't return a specific id of da player. // In case switch to set_task(0.1, "task_hud", id+2242) // followed by public task_hud(id) & id -= 2242 // Call this when it reaches the Free VIP start time set_task(0.1, "task_hud", 2242) public task_hud(2242){     new iPlayers[32], iPlayersNum;     get_players(iPlayers, iPlayersNum, "ach")     for (new i = 0; i < iPlayersNum; i++){         new id = iPlayers[i]         set_dhudmessage(0, 255, 0, -1.0, 0.0, _, _, 10.0)         show_dhudmessage(id, "Free VIP")         set_task(10.0, "task_hud", 2242)     } } // Call this when it reaches the Free VIP end time remove_task(2242)
It all was done via mobile. No help-back guarantee.
__________________
Relaxing is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 04-10-2018 , 09:13   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #7

thx but i am to damn to add this in the sma, i get errors everywhere there xD
Godofwar is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-10-2018 , 12:12   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #8

Why is my name in the title? o_O
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 04-10-2018 , 12:25   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #9

its an Plugin from you https://forums.alliedmods.net/showpo...48&postcount=5
Godofwar is offline
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 04-10-2018 , 12:29   Re: VIP EVENT Add Dhud permanent Happy Hour Oxicrom
Reply With Quote #10

@OciXCrom because you are pro ;_;
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
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 05:02.


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