#include <amxmodx>
#include <amxmisc>
#include <jailbreak>
#include <cstrike>
#include <fun>
#include <engine>

#define PLUGIN	"[JB]Kantor"
#define AUTHOR	"Alelluja"
#define VERSION	"2.0"

native get_user_jbpack(id)
native set_user_jbpack(id, wartosc)

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("say /kantor", "kantor")
	register_clcmd("say_team /kantor", "kantor")
	
}

public kantor(id)
{
	new menu = menu_create("Wymiana:","Wymiana")
	new txt[32];
	formatex(txt,31,"\y$ \wna \yJB Packi")
	menu_additem(menu,txt);
	formatex(txt,31,"\yJB Packi \wna \y$")
	menu_additem(menu,txt);
	menu_setprop(menu, MPROP_EXITNAME, "Wyjdz");
	menu_display(id, menu);
	
}

public Wymiana(id,menu,item)
{
	switch(item)
	{
		case 0:
		{
			jb_kantor(id);
			menu_destroy(menu);
			return PLUGIN_CONTINUE;
		}
		case 1:
		{
			jb_kantor2(id);
			menu_destroy(menu);
			return PLUGIN_CONTINUE;
		}
		
	}
	return PLUGIN_CONTINUE;
}

public jb_kantor(id)
{
	new menu,formats[64];
	new money = cs_get_user_money(id)
	formatex(formats,charsmax(formats),"\wKantor wymiany $ na JB Packi ^n\wIlosc $: \r%d",money);
	menu = menu_create(formats,"handle_wymien");
	{
		menu_additem(menu,"\r5000$ \w- \r5 \wMonet ","0")
		menu_additem(menu,"\r10000$ \w- \r10 \wMonet ","1")
		menu_additem(menu,"\r16000$ \w- \r15 \wMonet ","2")
	}
	menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
	menu_setprop(menu,MPROP_NEXTNAME,"Dalej")
	menu_setprop(menu,MPROP_BACKNAME,"Wroc")
	menu_setprop(menu,MPROP_EXITNAME,"Wyjscie")
	menu_display(id,menu,0)
	return PLUGIN_HANDLED
}

public jb_kantor2(id)
{
	new menu,formats[64];
	formatex(formats,charsmax(formats),"\wKantor II wymiany JB Packow na $ ^n\wIlosc JB Packow: \r%i",get_user_jbpack(id));
	menu = menu_create(formats,"handle_wymien2");
	{
		menu_additem(menu,"\r5 \wJB Packow \r5000$ ","0")
		menu_additem(menu,"\r10 \wJB Packow \r10000$ ","1")
		menu_additem(menu,"\r15 \wJB Packow \r16000$ ","2")
	}
	menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
	menu_setprop(menu,MPROP_NEXTNAME,"Dalej")
	menu_setprop(menu,MPROP_BACKNAME,"Wroc")
	menu_setprop(menu,MPROP_EXITNAME,"Wyjscie")
	menu_display(id,menu,0)
	return PLUGIN_HANDLED
}

public handle_wymien(id, menu, item)
{
	switch(item)
	{
		case 0:
		{
			if(cs_get_user_money(id)>=5000)
			{
				cs_set_user_money(id, cs_get_user_money(id)-5000, 1);
				set_user_jbpack(id, get_user_jbpack(id)+5);
				client_print(id, print_chat, "Wymieniles 5000 Dolarow na 5 JB Packow.");
			}
			else
				client_print(id, print_chat, "Nie masz wystarczajacej ilosci kasy!");
			
		}
		case 1:
		{
			if(cs_get_user_money(id)>=8000)
			{
				cs_set_user_money(id, cs_get_user_money(id)-10000, 1);
				set_user_jbpack(id, get_user_jbpack(id)+10);
				client_print(id, print_chat, "Wymieniles 8000 Dolarow na 10 JB Packow.");
			}
			else
				client_print(id, print_chat, "Nie masz wystarczajacej ilosci kasy!");
			
		}
		case 2:
		{
			if(cs_get_user_money(id)>=16000)
			{
				cs_set_user_money(id, cs_get_user_money(id)-16000, 1);
				set_user_jbpack(id, get_user_jbpack(id)+25);
				client_print(id, print_chat, "Wymieniles 16000 Dolarow na 25 JB Packow.");
			}
			else
				client_print(id, print_chat, "Nie masz wystarczajacej ilosci kasy!");
			
		}
		
	}
	return PLUGIN_CONTINUE;
}

public handle_wymien2(id, menu, item)
{
	switch(item)
	{
		case 0:
		{
			if(get_user_jbpack(id)>=5)
			{
				set_user_jbpack(id, get_user_jbpack(id)-5);
				cs_set_user_money(id, cs_get_user_money(id)+5000, 1);
				client_print(id, print_chat, "Wymieniles 5 JB Packow na 5000 Dolarow");
			}
			else
				client_print(id, print_chat, "Nie masz wystarczajacej ilosci JB Packow!");
			
		}
		case 1:
		{
			if(get_user_jbpack(id)>=10)
			{
				set_user_jbpack(id, get_user_jbpack(id)-10);
				cs_set_user_money(id, cs_get_user_money(id)+10000, 1);
				client_print(id, print_chat, "Wymieniles 10 JB Packow na 10000 Dolarow");
			}
			else
				client_print(id, print_chat, "Nie masz wystarczajacej ilosci JB Packow!");
			
		}
		case 2:
		{
			if(get_user_jbpack(id)>=25)
			{
				set_user_jbpack(id, get_user_jbpack(id)-25);
				cs_set_user_money(id, cs_get_user_money(id)+16000, 1);
				client_print(id, print_chat, "Wymieniles 25 JB Packow na 16000 Dolarow");
			}
			else
				client_print(id, print_chat, "Nie masz wystarczajacej ilosci JB Packow!");
			
		}
		
	}
	return PLUGIN_CONTINUE;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/
