Raised This Month: $ Target: $400
 0% 

issuing a flag in the menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Joker2020
Junior Member
Join Date: Aug 2020
Old 08-27-2020 , 05:51   issuing a flag in the menu
Reply With Quote #1

Hi, I added another flag to the menu, but when I click 2, nothing comes out, namely the second flag

1) click menu define VIPFLAG ADMIN_RESERVATION
2) click menu VIPSFLAG ADMIN_LEVEL_B

Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <cstrike>
#include <engine>
#include <hamsandwich>
#include <fun>

#define NAME "Coins Shop"
#define VERSION	"0.1"
#define AUTHOR "Sokrat"

#define VIPFLAG ADMIN_RESERVATION							//flags VIP (ADMIN_...)
#define VIPSFLAG ADMIN_LEVEL_B

new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_0

new vip, vips
new take_vip[33], take_vips[33]

native get_user_coins(id)
native set_user_coins(id, iNum)

public plugin_init()
{
	register_plugin(NAME, VERSION, AUTHOR)

	register_menu("Menu 1", keys, "func_Coinshop") 
	register_clcmd("say /coins", "Coinshop")
	
	register_cvar("shop_vip", "50") 						//"VIP"
	register_cvar("shop_vips", "100") 						//"VIP Gold"
}

public client_putinserver(id) {
	take_vip[id] = 0
	take_vips[id] = 0
}

public client_disconnected(id) {
	take_vip[id] = 0
	take_vips[id] = 0
	
}

public Coinshop(id)
{
	vip = get_cvar_num("shop_vip")
	vip = get_cvar_num("shop_vips")
	

	static menu[650], iLen
	iLen = 0
	iLen = formatex(menu[iLen], charsmax(menu) - iLen, "\d[\yŠ\d] System Of Coins | Shop^n\d[\yŠ\d] Your coin: \y%i шт\d.^n^n", get_user_coins(id))

	if (get_user_coins(id) >= vip) 
	{	
		if (take_vip[id] == 0) 
		{
			iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1 \d| \wVIP \d[\y%i\d]^n", vip)
			keys |= MENU_KEY_1
		}
		else if (take_vip[id] == 1) 
		{
			iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1 \d| \dVIP \d[\d%i\d] [You have already purchased VIP]^n", vip)
		}
		else if (get_user_flags(id) & VIPFLAG) 
		{
			iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1 \d| \dVIP \d[\d%i\d] [You already have a VIP]^n", vip)
		}
	}
	else 
	{
		iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1 \d| \dVIP \d[\d%i\d]^n", vip)
		keys |= MENU_KEY_1
	}

	if (get_user_coins(id) >= vips) 
	{	
		if (take_vips[id] == 0) 
		{
			iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r2 \d| \wVIP Gold \d[\y%i\d]^n", vips)
			keys |= MENU_KEY_2
		}
		else if (take_vips[id] == 1) 
		{
			iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r2 \d| \dVIP Gold \d[\d%i\d] [You have already purchased VIP]^n", vips)
		}
		else if (get_user_flags(id) & VIPSFLAG) 
		{
			iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r2 \d| \dVIP Gold \d[\d%i\d] [You already have a VIP]^n", vips)
		}
	}
	else 
	{
		iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r2 \d| \dVIP Gold \d[\d%i\d]^n", vips)
		keys |= MENU_KEY_2
	}

	iLen += formatex(menu[iLen], charsmax(menu) - iLen, "^n\r0 \d| \wExit")
	keys |= MENU_KEY_0

	show_menu(id, keys, menu, -1, "Menu 1")
	return PLUGIN_HANDLED
}

public func_Coinshop(id, key)
{
	vip = get_cvar_num("shop_vip")
	vip = get_cvar_num("shop_vips")
	
	
	switch(key)
	{
		case 0: {
			if(get_user_coins(id) < vip && get_user_flags(id) & VIPFLAG) return PLUGIN_HANDLED
			else {
				set_user_coins(id, get_user_coins(id) - vip)
				take_vip[id] = 1
				screen_fade(id)
				set_user_flags(id, VIPFLAG)
				ColorChat(id, GREEN, "^1[^4shop^1] ^1you bought ^3VIP. coins left: ^4%i шт^1.", get_user_coins(id))
			}
		}
		case 1: {
			if(get_user_coins(id) < vips && get_user_flags(id) & VIPSFLAG) return PLUGIN_HANDLED
			else {
				set_user_coins(id, get_user_coins(id) - vips)
				take_vips[id] = 1
				screen_fade(id)
				set_user_flags(id, VIPSFLAG)
				ColorChat(id, GREEN, "^1[^4shop^1] ^1you bought ^3VIP Gold. coins left: ^4%i шт^1.", get_user_coins(id))
			}
		}
	}
	return PLUGIN_HANDLED
}

/*==========================================Скрин-Фейд при покупке==========================================*/
public screen_fade(id) {
	message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
	write_short(1<<10)
	write_short(1<<10)
	write_short(0x0000)
	write_byte(139)
	write_byte(0)
	write_byte(255)
	write_byte(50)
	message_end()
}

Last edited by Joker2020; 08-27-2020 at 05:52.
Joker2020 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-27-2020 , 22:09   Re: issuing a flag in the menu
Reply With Quote #2

That value of take_vip[id] and take_vips[id] only ever be 0 or 1. That means that the flag check will never happen (for either menu item). Also, you setting the flag in func_Coinshop() is redundant with the take_vip and take_vips arrays.

You probably need to explain better about what you are wanting this plugin to do because what you have doesn't make much sense.

P.S. You should change the variable names by more than just a single letter, when it's so similar it makes it harder to read the code.
__________________
fysiks is offline
Joker2020
Junior Member
Join Date: Aug 2020
Old 08-28-2020 , 03:31   Re: issuing a flag in the menu
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
That value of take_vip[id] and take_vips[id] only ever be 0 or 1. That means that the flag check will never happen (for either menu item). Also, you setting the flag in func_Coinshop() is redundant with the take_vip and take_vips arrays.

You probably need to explain better about what you are wanting this plugin to do because what you have doesn't make much sense.

P.S. You should change the variable names by more than just a single letter, when it's so similar it makes it harder to read the code.
I need that when you click on menu 1 - gave the player VIPFLAG ADMIN_RESERVATION
and when you click on menu 2-gave out VIPSFLAG ADMIN_LEVEL_B
Joker2020 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 13:49.


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