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

Solved Add Happy Hour some Flags etc Please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 08-07-2019 , 13:07   Add Happy Hour some Flags etc Please
Reply With Quote #1

Hello, can anyone add multiple Flags? I have Users who registered with Flag W. But i know there is nothing about flag W. SO i want add them w+y

This Users have an Register Tag. Can anyone add that Users with flag Z and Users with Flag wy got Free VIP in this Time ? After expired Happy Hour they should get here original Flags back. It would be cool.

The VIP FLags should be Admin_level_h (T)

#define ADMIN_ADMIN (1<<24) /* flag "y" */
#define ADMIN_USER (1<<24) /* flag "z" */

And the VIP TIME should be avaible from 15 O Clock to 22 O Clock

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

#define VIP_FLAG ADMIN_LEVEL_H

#define DEFAULT_FLAG ADMIN_USER

#define HUD_POSITION_X		-1.0
#define HUD_POSITION_Y		0.0

#define HUD_COLOR_RED		0
#define HUD_COLOR_GREEN		200
#define HUD_COLOR_BLUE		0

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", "10" );
	g_iCvars[ 2 ] = register_cvar( "free_vip_end_time", "23" );
	
	set_task(1.0, "show_hud", _, .flags = "b");
}

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

public client_PostThink( id )
{
	if(!is_user_alive(id) || is_user_bot(id))
		return;
	
	set_user_flags( id, g_bFreeVipTime ? VIP_FLAG : DEFAULT_FLAG );
}

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

	new g_iCondition = IsVipHour( get_pcvar_num( g_iCvars[ 1 ] ), get_pcvar_num( g_iCvars[ 2 ] ) );

	g_bFreeVipTime = g_iCondition ? true : false;
	
	new szPlayers[ 32 ], iNum, iTempID;
	get_players( szPlayers, iNum );
		
	for( new i; i < iNum; i++ )
	{
		iTempID = szPlayers[ i ];
			
		if(!is_user_bot( iTempID ))
			set_user_flags( iTempID, g_bFreeVipTime ? VIP_FLAG : DEFAULT_FLAG);
	}
	
	return PLUGIN_CONTINUE;
}

public show_hud()
{
	if(!g_bFreeVipTime)
		return;
	
	set_hudmessage(HUD_COLOR_RED, HUD_COLOR_GREEN, HUD_COLOR_BLUE, HUD_POSITION_X, HUD_POSITION_Y, 0, 6.0, 1.1);
	show_hudmessage(0, "Happy Hour > Free VIP Start: %dh^n\Happy Hour > Free VIP End: %dh", get_pcvar_num(g_iCvars[ 1 ]), get_pcvar_num(g_iCvars[ 2 ]));
}

public fw_HamSpawnPost( id )
{
	if(!is_user_alive(id) || is_user_bot(id))
		return;
	
	set_user_flags( id, g_bFreeVipTime ? VIP_FLAG : DEFAULT_FLAG);
}

public native_is_free_vip_time( iPlugin, iParams )
{
	return bool: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; 08-10-2019 at 17:38.
Godofwar is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-07-2019 , 15:39   Re: Add Happy Hour some Flags etc Please
Reply With Quote #2

Code:
#define FLAGS "wy" new BIT = read_flags(FLAGS); set_user_flags(index, BIT)
Also you should change this
Code:
public client_PostThink( id ) {     if(!is_user_alive(id) || is_user_bot(id))         return;         set_user_flags( id, g_bFreeVipTime ? VIP_FLAG : DEFAULT_FLAG ); }
__________________

Last edited by Relaxing; 08-07-2019 at 15:42.
Relaxing is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-07-2019 , 18:34   Re: Add Happy Hour some Flags etc Please
Reply With Quote #3

@Relaxing is posthikg really needed for this?
register_message( get_user_msgid( "ScoreAttrib" ), "msg" ); is less time called for example
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 08-07-2019 at 18:35.
JocAnis is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 08-08-2019 , 14:15   Re: Add Happy Hour some Flags etc Please
Reply With Quote #4

@relaxing.

i am using an admin tag system where i added in this tag flag W for [Registered User] ... ignore this.

i need only that users who have flag Z and Users who have flag Y that they get in vip time the flag T .

i will change the flag W to Y ...
Godofwar is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-08-2019 , 14:43   Re: Add Happy Hour some Flags etc Please
Reply With Quote #5

Quote:
Originally Posted by JocAnis View Post
@Relaxing is posthikg really needed for this?
register_message( get_user_msgid( "ScoreAttrib" ), "msg" ); is less time called for example
Just call the checks on putingserver.
Quote:
Originally Posted by Godofwar View Post
@relaxing.

i am using an admin tag system where i added in this tag flag W for [Registered User] ... ignore this.

i need only that users who have flag Z and Users who have flag Y that they get in vip time the flag T .

i will change the flag W to Y ...
http://amxmodx.org/api/amxmisc/has_flag
Code:
// in this case if (!is_user_admin(id) || has_flag(id, "y")){     set_user_flags(id, ADMIN_LEVEL_H); }
__________________

Last edited by Relaxing; 08-08-2019 at 14:45.
Relaxing is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 08-08-2019 , 15:02   Re: Add Happy Hour some Flags etc Please
Reply With Quote #6

yes but what is with flag Z ?
Godofwar is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-08-2019 , 15:43   Re: Add Happy Hour some Flags etc Please
Reply With Quote #7

Quote:
Originally Posted by Godofwar View Post
yes but what is with flag Z ?
Have you tested it?
__________________
Relaxing is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 08-09-2019 , 13:03   Re: Add Happy Hour some Flags etc Please
Reply With Quote #8

i dont know where i add set_user_flags(index, BIT) ...

// in this case
if (!is_user_admin(id) || has_flag(id, "y")){
set_user_flags(id, ADMIN_LEVEL_H);
}

Wtf xD could u maybe make it for me ? then i can try to learn it.

Last edited by Godofwar; 08-09-2019 at 13:08.
Godofwar is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-09-2019 , 13:42   Re: Add Happy Hour some Flags etc Please
Reply With Quote #9

Remove PreThink completely, Ham_Spawn should do the job, or if you can't wait for everyone to spawn, just set a task in plugin_init.
__________________
edon1337 is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 08-09-2019 , 14:10   Re: Add Happy Hour some Flags etc Please
Reply With Quote #10

edon.... u got help from me about translations.. can u edit the sma and send it here? x.x
Godofwar 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 22:27.


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