/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <colorchat>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <engine>
#include <fakemeta_util>
#include <nvault>
#include <naxe_jailbreak>

#define PLUGIN "JBPacki"
#define VERSION "1.0"
#define AUTHOR "Zero"

#define prefix "Sklep"

#define FL_WATERJUMP (1<<11) 
#define FL_ONGROUND (1<<9) 
#define	autobhopkeys (1<<0)|(1<<1) 

new pPcvarDBHost;
new pPcvarDBUser;
new pPcvarDBPassword;
new pPcvarDBBase;

new Handle:g_SqlTuple;
new g_Cache[512];
new bool:SQLenabled;
new bool:gIntermission;
new gTablesLoaded[33];
new gSaveKey[33][32];



new ilosc_jbpack[33];
new bool:bhop_enabled[33];
new bool:blokada


new jb_packi_nv
new msgtext;
public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	//--//--//--//--//--//--//--//--//--//--//--//--//--//--//
	pPcvarDBHost = register_cvar("db_host", "sql.pukawka.pl"); //ip bazy danych
	pPcvarDBUser = register_cvar("db_user", "736508"); //nazwa uzytkownika
	pPcvarDBPassword = register_cvar("db_pass", "o5jzDb8HvSDshcP"); //haslo do bazy danych
	pPcvarDBBase = register_cvar("db_database", "736508_sklep1"); //nazwa bazy danych
	//--//--//--//--//--//--//--//--//--//--//--//--//--//--//
	
	register_clcmd("say /sklep", "jb_sklep")
	register_clcmd("say_team /sklep", "jb_sklep")
	register_clcmd("say /shop", "jb_sklep")
	register_clcmd("say_team /shop", "jb_sklep")
	
	register_cvar("jb_maxjp", "30" );
	register_cvar("jb_tt", "1" );
	register_cvar("jb_ct", "2" );
	register_cvar("jb_hs", "1" );
	register_cvar("jb_czas", "0");
	register_cvar("jb_zapis", "1"); //1  - nvault, 2 - sql
	register_cvar("jb_hud", "1"); //0 - off, 1 - status, 2 - hud
	
	if(get_cvar_num("jb_zapis") == 2) { 
	jb_packi_nv = nvault_open("jb_packi")
	if(jb_packi_nv == INVALID_HANDLE)
		set_fail_state("Nie moge otworzyc pliku");
	}
	
	register_event("DeathMsg", "DeathMsg", "a")
	register_logevent("Koniec_Rundy", 2, "1=Round_End")
	register_logevent("Poczatek_Rundy", 2, "1=Round_Start")
	register_event("ResetHUD","HUD", "b");
	
	register_concmd("jb_packgive", "cmd_give", ADMIN_IMMUNITY, "<nazwa> <ilosc>");
	register_clcmd("typ_zapisu", "typ");
	register_clcmd("say /kantor", "kantor")
	register_clcmd("say_team /kantor", "kantor")
	
	msgtext = get_user_msgid("StatusText");
	
	register_forward(FM_PlayerPreThink, "forward_FM_PlayerPreThink", 0)
	
	set_task(0.8, "HUD",0,"",0,"b");
	
}

public HUD(id)  { 
	for (new id=0; id < 32; id++) {

	if (!is_user_connected(id))
		continue
		
	if(is_user_alive(id)){
		new HUD[128];
			
		format(HUD, 127,"Szlugi: %i",ilosc_jbpack[id]);
		if(get_cvar_num("jb_hud") == 1){
			message_begin(MSG_ONE, msgtext, {0,0,0}, id);
			write_byte(0);
			write_string(HUD); 
			message_end();
			return PLUGIN_CONTINUE;
		}
		else if(get_cvar_num("jb_hud") == 2)
		{
			set_hudmessage(0, 255, 0, 0.02, 0.63, 0, 0.01, 0.8, _, _, 3)
			show_hudmessage(id, "%s",HUD)
		}
	}
}
	return PLUGIN_CONTINUE;
}
/*public client_PreThink(id){
	if(!is_user_alive(id)){
		return PLUGIN_CONTINUE;
	}
	if(is_user_alive(id) && !is_user_bot(id) && get_cvar_num("jb_hud") > 0){
			HUD(id);
	}
	return PLUGIN_HANDLED;
}*/
public DeathMsg()
{
	new weaponname[20]
	new kid = read_data(1)
	new vid = read_data(2)
	new headshot = read_data(3)
	read_data(4,weaponname,31)
	
	if(kid == vid)
	{
	return PLUGIN_HANDLED	
	}
	if(get_user_team(kid) == 1)
	{
		new maxjp = get_cvar_num("jb_maxjp")
		if(ilosc_jbpack[kid]<maxjp)
		{
		if(get_user_team(vid) == 2)
		{
			new pack_ct = get_cvar_num("jb_ct")
			ilosc_jbpack[kid] += pack_ct
			ColorChat(kid, GREEN, "[%s] ^x01 Dostales ^x04+%i ^x01Szlugow", prefix, pack_ct);
		}
		else
		{
			new pack_tt = get_cvar_num("jb_tt")
			ilosc_jbpack[kid] += pack_tt
			ColorChat(kid, GREEN, "[%s] ^x01 Dostales ^x04+%i ^x01Szlugow", prefix, pack_tt);
		}
		if(headshot)
		{
			new pack_hs = get_cvar_num("jb_hs")
			ilosc_jbpack[kid] += pack_hs
			ColorChat(kid, GREEN, "[%s] ^x01 Dostales bonus za headshot ^x04+%i ^x01Szlugow", prefix, pack_hs);
		}
		}
		else
		{
			ColorChat(kid, GREEN, "[%s] ^x01 Ilosc maksymalna Szlugow osiagnieta!", prefix);	
			return PLUGIN_CONTINUE
		}
		ColorChat(kid, GREEN, "[%s] ^x01 Twoja ilosc Szlugow to: ^x04%i/%i", prefix, ilosc_jbpack[kid], maxjp);
		if(get_cvar_num("jb_zapis") == 1) { 
		sql_save(kid)
		}
		else
		{
		zapisz_jbpack(kid)
		}
	}
	return PLUGIN_CONTINUE
}


////----//////

public jb_sklep(id)
{	
	if(blokada == true){
		new czynny_sklep = get_cvar_num("jb_czas")
		ColorChat(id, GREEN, "[%s] Sklep jest czynny tylko %d sekund po rozpoczeciu rundy", prefix, czynny_sklep);
		return PLUGIN_HANDLED
	}

	new menu,formats[64];
	formatex(formats,charsmax(formats),"\wSklep JB^n\wIlosc Szlugow: \r%i\w^n\wKantor: \dWpisz \r/Kantor",ilosc_jbpack[id])
	menu = menu_create(formats,"handle_jb_sklep");
	if(get_user_team(id) == 1)
	{		
		menu_additem(menu,"\wKluczyk do Cel! \r[\w700 szlugow\r]","9")
		menu_additem(menu,"\wGranat dymny \r[\w30 szlugow\r]","0")
		menu_additem(menu,"\wGranat oslepiajacy \r[\w45 szlugow\r]","1")
		menu_additem(menu,"\wGranat wybuchajacy \r[\w60 szlugow\r]","2")
		menu_additem(menu,"\wKamizelka \r[\w50 szlugow\r]","3")
		menu_additem(menu,"\wAutoBH na jedna runde \r[\w140 szlugow\r]","4")
		menu_additem(menu,"\w+20 HP \r[\w60 szlugow\r]","5")
		menu_additem(menu,"\wCiche Chodzenie na jedna runde \r\r[\w60 szlugow\r]","6")
		menu_additem(menu,"\wFreeDay \r[\w300 szlugow\r]","5")
		menu_additem(menu,"\wUsun Budyniowca \r[\w350 szlugow\r]","8")
	}
	menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
	menu_setprop(menu,MPROP_EXITNAME,"Wyjscie")
	menu_setprop(menu,MPROP_NEXTNAME,"Dalej")
	menu_setprop(menu,MPROP_BACKNAME,"Wroc")
	menu_display(id,menu,0)
	return PLUGIN_HANDLED
}
public handle_jb_sklep(id, menu, item)
{
	switch(item)
	{
		case 0:
		{
			if(!sprawdz(id,30)) return PLUGIN_HANDLED;
			give_item(id, "weapon_smokegrenade");
			ColorChat(id, GREEN, "[%s] Kupiles granat dymny", prefix);
			
		}
		case 1:
		{
			if(!sprawdz(id,45)) return PLUGIN_HANDLED;
			give_item(id, "weapon_flashbang");
			ColorChat(id, GREEN, "[%s] Kupiles granat oslepiajacy", prefix);
			
		}
		case 2:
		{
			if(!sprawdz(id,60)) return PLUGIN_HANDLED;
			give_item(id, "weapon_hegrenade");
			ColorChat(id, GREEN, "[%s] Kupiles granat wybuchowy", prefix);
			
		}
		case 3:
		{
			if(!sprawdz(id,50)) return PLUGIN_HANDLED;
			give_item(id, "item_kevlar")
			give_item(id, "item_assaultsuit")
			ColorChat(id, GREEN, "[%s] Kupiles kamizelke", prefix);
		}
		/*case 4:
		{
			if(!sprawdz(id,40)) return PLUGIN_HANDLED;
			give_item(id, "weapon_glock18")
			
			new weapon_id = find_ent_by_owner(-1, "weapon_glock18", id);
			if(weapon_id)
			{
			cs_set_weapon_ammo(weapon_id, 4);
			}
			ColorChat(id, GREEN, "[%s] Kupiles glocka", prefix);
		}*/
		case 4:
		{
			if(!sprawdz(id,140)) return PLUGIN_HANDLED;
			bhop_enabled[id] = true
			ColorChat(id, GREEN, "[%s] Kupiles AutoBH na jedna runde", prefix);
		}
		case 5:
		{
			if(!sprawdz(id,60)) return PLUGIN_HANDLED;
			set_user_health(id, get_user_health(id) + 20)
			ColorChat(id, GREEN, "[%s] Kupiles +20hp", prefix);
		}
		case 6:
		{
			if(!sprawdz(id,60)) return PLUGIN_HANDLED;
			set_user_footsteps(id, 1)
			ColorChat(id, GREEN, "[%s] Kupiles ciche chodzenie na jedna runde", prefix);
		}
		case 7:
		{
			if(!sprawdz(id,300)) return PLUGIN_HANDLED;
			jail_set_free(id, true, false, true)
			ColorChat(id, GREEN, "[%s] Kupiles FreeDay'a na 1 runde!", prefix);
		}
		case 8:
		{
			if(!sprawdz(id,350)) return PLUGIN_HANDLED;
			jail_open_removewanted(id)
			ColorChat(id, GREEN, "[%s] Usunales budyniowca!", prefix);
		}
		case 9:
		{
			if(!sprawdz(id,750)) return PLUGIN_HANDLED;
			jail_open_cele()
			ColorChat(id, GREEN, "[%s] Wiezien posiadal klucz do cel! FreeDay!!", prefix);
		}
	}
	return PLUGIN_CONTINUE;
}
public sprawdz(id,jbpack){
	if (ilosc_jbpack[id] >= jbpack){
	ilosc_jbpack[id] -= jbpack
	return true;
	}
	if(!is_user_alive(id)){
		ColorChat(id, GREEN, "[%s] Nie zyjesz", prefix);
		return false;
	}
	if(ilosc_jbpack[id] < jbpack)
	{
		ColorChat(id, GREEN, "[%s] Nie masz tylu Szlugow, aby to kupic", prefix);
		return false;
	}
	return PLUGIN_CONTINUE;
}


public Poczatek_Rundy() {
	blokada = false
	new czynny_skle = get_cvar_float("jb_czas")

	set_task(czynny_skle, "Blokuj")
}
public Koniec_Rundy(){
	for(new i =1;i<33;i++){
	if(is_user_connected(i))
	{
	bhop_enabled[i] = false
	set_user_footsteps(i, 0)
	}
	}
}
public Blokuj(){
blokada = true	
}
public forward_FM_PlayerPreThink(id) 
{ 
	if(bhop_enabled[id] == true) 
	{ 
		entity_set_float(id, EV_FL_fuser2, 0.0) 
		
		if (entity_get_int(id, EV_INT_button) & 2) 
		{ 
			new flags = entity_get_int(id, EV_INT_flags) 
			
			if (flags & FL_WATERJUMP) 
				return PLUGIN_CONTINUE 
			if ( entity_get_int(id, EV_INT_waterlevel) >= 2 ) 
				return PLUGIN_CONTINUE 
			if ( !(flags & FL_ONGROUND) ) 
				return PLUGIN_CONTINUE 
			
			new Float:velocity[3] 
			entity_get_vector(id, EV_VEC_velocity, velocity) 
			velocity[2] += 250.0 
			entity_set_vector(id, EV_VEC_velocity, velocity) 
			
			entity_set_int(id, EV_INT_gaitsequence, 6) 
		} 
	} 
	return PLUGIN_CONTINUE 
}  
public cmd_give(id, level, cid)
{
	if(!cmd_access(id, level, cid, 3))
		return PLUGIN_CONTINUE;
	
	new arg[33];
	read_argv(1, arg, 32);
	new target = cmd_target(id, arg, CMDTARGET_ALLOW_SELF);
	
	if(!is_user_connected(target))
		return PLUGIN_CONTINUE;
	
	read_argv(2, arg, 32);
	new ilejb = str_to_num(arg);
	
	ilosc_jbpack[target] = ilosc_jbpack[target] + ilejb;
	
	return PLUGIN_CONTINUE;
}

public plugin_natives()
{
	register_native("get_user_jbpack","return_jbpack", 1)
	register_native("set_user_jbpack","set_jbpack", 1)
}

public return_jbpack(id)
{
        return ilosc_jbpack[id];
}
public set_jbpack(id, amount)
{
	ilosc_jbpack[id] = amount	
}


//////////////
public typ(id) {
	if(get_cvar_num("jb_zapis") == 1) { 
	client_print(id, print_console, "Uzywasz obecnie zapisu SQL")
	}
	else
	{
	client_print(id, print_console, "Uzywasz obecnie zapisu nVault")
	}
}

public zaladuj_jbpack(id)
{
	new name[48]
	get_user_name(id,name,47)
	new vaultkey[64],vaultdata[128]
	formatex(vaultkey,63,"%s-jbpack",name)
	
	if(nvault_get(jb_packi_nv,vaultkey,vaultdata,127)) {
		new jb_packii[16];
		parse(vaultdata, jb_packii, 15)
		
		ilosc_jbpack[id]=str_to_num(jb_packii)
	}
	
	return PLUGIN_CONTINUE
}  

public zapisz_jbpack(id) {	
	new name[48]
	get_user_name(id,name,47)
	new vaultkey[64],vaultdata[128]
	formatex(vaultkey,63,"%s-jbpack",name)
	formatex(vaultdata,127,"%d", ilosc_jbpack[id])
	nvault_set(jb_packi_nv,vaultkey,vaultdata)
	
	return PLUGIN_CONTINUE
}

public plugin_cfg(){
    SQLenabled = false;
    sql_init();
}
public plugin_end()
{
	if ( SQLenabled )
	{
		SQL_FreeHandle(g_SqlTuple);
	}
}
public Message_Intermission()
{
	gIntermission = true;
}
public client_putinserver(id){
	gTablesLoaded[id] = 0;
	if(get_cvar_num("jb_zapis") == 1) { 
	get_save_key(id);
	}
	else
	{
	zaladuj_jbpack(id);
	}
}
public client_disconnect(id)
{
	if(get_cvar_num("jb_zapis") == 1) { 
	sql_save(id)
	}
	else
	{
	zapisz_jbpack(id)
	}
}
public sql_init()
{
	new szHost[32], szUser[32], szPass[32], szDB[32];
	get_pcvar_string(pPcvarDBHost, szHost, 31);
	get_pcvar_string(pPcvarDBUser, szUser, 31);
	get_pcvar_string(pPcvarDBPassword, szPass, 31);
	get_pcvar_string(pPcvarDBBase, szDB, 31);
	
	g_SqlTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB);

	SQL_ThreadQuery(g_SqlTuple, "TableHandle", "CREATE TABLE IF NOT EXISTS jbpacki (nazwa_gracza VARCHAR(35), ilosc_jbpack INT(11), PRIMARY KEY (nazwa_gracza))");
}
public get_save_key(id)
{
	get_user_name(id, gSaveKey[id], charsmax(gSaveKey[]));
	sql_load(id);
}
public sql_load(id)
{
	new index[1];
	index[0] = id;

	new tempSaveKey[63];
	copy(tempSaveKey, charsmax(tempSaveKey), gSaveKey[id]);
	replace_all(tempSaveKey, charsmax(tempSaveKey), "'", "\'" );

	formatex(g_Cache, charsmax(g_Cache), "SELECT ilosc_jbpack FROM jbpacki WHERE nazwa_gracza='%s'", tempSaveKey);
	SQL_ThreadQuery(g_SqlTuple, "SelectHandle", g_Cache, index, 1);
}
public TableHandle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
	if ( FailState )
	{
		if ( FailState == TQUERY_CONNECT_FAILED )
		{
			log_amx("Table - Could not connect to SQL database.  [%d] %s", Errcode, Error);
		}
		else if ( FailState == TQUERY_QUERY_FAILED )
		{
			log_amx("Table Query failed. [%d] %s", Errcode, Error);
		}

		SQLenabled = false;

		return;
	}

	SQLenabled = true;
}

public QueryHandle(FailState, Handle:Query, Error[], Errcode,Data[], DataSize)
{
	if ( FailState )
	{
		if ( FailState == TQUERY_CONNECT_FAILED )
		{
			log_amx("Save - Could not connect to SQL database.  [%d] %s", Errcode, Error);
		}
		else if ( FailState == TQUERY_QUERY_FAILED )
		{
			log_amx("Save Query failed. [%d] %s", Errcode, Error);
		}

		return;
	}
}

public SelectHandle(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
	if ( FailState )
	{
		if ( FailState == TQUERY_CONNECT_FAILED )
		{
			log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error);
		}
		else if ( FailState == TQUERY_QUERY_FAILED )
		{
			log_amx("Load Query failed. [%d] %s", Errcode, Error);
		}

		return;
	}

	new id = Data[0];

	if ( !SQL_NumResults(Query) )
	{
		new tempSaveKey[63];
		copy(tempSaveKey, charsmax(tempSaveKey), gSaveKey[id]);
		replace_all(tempSaveKey, charsmax(tempSaveKey), "'", "\'" );

		formatex(g_Cache, charsmax(g_Cache), "INSERT INTO jbpacki VALUES('%s', '0')", tempSaveKey);
		SQL_ThreadQuery(g_SqlTuple, "QueryHandle", g_Cache);
	}
	else
	{
	ilosc_jbpack[id] = SQL_ReadResult(Query,SQL_FieldNameToNum(Query,"ilosc_jbpack"));
	}
	gTablesLoaded[id]++;
}

public sql_save(id)
{
	if ( gTablesLoaded[id] == 1 )
	{
		if ( gIntermission )
		{
			sql_save_nonthreaded(id);
			return;
		}
		new tempSaveKey[63];
		copy(tempSaveKey, charsmax(tempSaveKey), gSaveKey[id]);
		replace_all(tempSaveKey, charsmax(tempSaveKey), "'", "\'" );

		formatex(g_Cache, charsmax(g_Cache), "UPDATE jbpacki SET ilosc_jbpack=%i WHERE nazwa_gracza=^"%s^"", ilosc_jbpack[id], tempSaveKey);
		SQL_ThreadQuery(g_SqlTuple, "QueryHandle", g_Cache);
	}
}

sql_save_nonthreaded(id)
{
	new Errcode, Error[128], Handle:SqlConnection;

	SqlConnection = SQL_Connect(g_SqlTuple, Errcode, Error, charsmax(Error));

	if ( !SqlConnection )
	{
		log_amx("Save - Could not connect to SQL database.  [%d] %s", Errcode, Error);
		SQL_FreeHandle(SqlConnection);
		return;
	}

	new tempSaveKey[63];
	copy(tempSaveKey, charsmax(tempSaveKey), gSaveKey[id]);
	replace_all(tempSaveKey, charsmax(tempSaveKey), "'", "\'" );

	new Handle:Query;
	Query = SQL_PrepareQuery(SqlConnection, "UPDATE jbpacki SET ilosc_jbpack=%i WHERE nazwa_gracza=^"%s^"", ilosc_jbpack[id], tempSaveKey);
	if ( !SQL_Execute(Query) )
	{
		Errcode = SQL_QueryError(Query, Error, charsmax(Error));
		log_amx("Save Query failed. [%d] %s", Errcode, Error);
		SQL_FreeHandle(Query);
		SQL_FreeHandle(SqlConnection);
		return;
	}

	SQL_FreeHandle(Query);
	
	SQL_FreeHandle(SqlConnection);
}

/////////////////////////////////////////////Kantor/////////////////////////////////////////////
public kantor(id)
{
	if(get_user_team(id) == 1)
	{
		new menu = menu_create("\dKantor wymiany walut:", "handle_kantor");	

		menu_additem(menu, "\w$$$ na Szlugi", 		"1");
		menu_additem(menu, "\wSzlugi na $$$", 		"2");
	
		menu_setprop(menu, MPROP_EXITNAME, "\d| \rWyjdz \d|");
		menu_display(id, menu);
	}
}

public handle_kantor(id, menu, item)
{
	if(item == MENU_EXIT)
		return PLUGIN_HANDLED;

	new num[10], acces, callback;
	menu_item_getinfo(menu, item, acces, num, 9, _, _, callback);
	switch(str_to_num(num))
	{
		case 1: menu_jeden(id)
		case 2: menu_dwa(id)
	}
	return PLUGIN_CONTINUE
}

public menu_jeden(id)
{
	new menu,formats[64];
	new money = cs_get_user_money(id)
	formatex(formats,charsmax(formats),"\dWymiana $$$ na Szlugi ^n\wIlosc dolarow: \r%d",money);
	menu = menu_create(formats,"handle_wymien");
	{
		menu_additem(menu,"\r8000$ \w- \r10 \wSzlug ","0")
		menu_additem(menu,"\r10000$ \w- \r14 \wSzlug ","1")
		menu_additem(menu,"\r16000$ \w- \r22 \wSzlug ","2")
	}
	menu_setprop(menu,MPROP_EXITNAME,"\d| \rWyjdz \d|")
	menu_display(id,menu)
	return PLUGIN_HANDLED
}

public menu_dwa(id)
{
	new menu,formats[64];
	formatex(formats,charsmax(formats),"\dWymiana Szlugi na $$$ ^n\wIlosc szlugow: \r%i",ilosc_jbpack[id]);
	menu = menu_create(formats,"handle_wymien2");
	{
		menu_additem(menu,"\r50 \wSzlug - \r8000$ ","0")
		menu_additem(menu,"\r70 \wSzlug - \r10000$ ","1")
		menu_additem(menu,"\r100 \wSzlug - \r16000$ ","2")
	}
	menu_setprop(menu,MPROP_EXITNAME,"\d| \rWyjdz \d|")
	menu_display(id,menu)
	return PLUGIN_HANDLED
}

public handle_wymien(id, menu, item)
{
	switch(item)
	{
		case 0:
		{
			if(cs_get_user_money(id)>=8000)
			{
				cs_set_user_money(id, cs_get_user_money(id)-8000, 1);
				set_jbpack(id, return_jbpack(id)+10);
				ColorChat(id, GREEN, "[Kantor]^x01 Wymieniles 8000 Dolarow na 10 Szlugow");
			}
			else
				ColorChat(id, GREEN, "[Kantor]^x01 Nie masz wystarczajacej ilosci kasy!");
			
		}
		case 1:
		{
			if(cs_get_user_money(id)>=10000)
			{
				cs_set_user_money(id, cs_get_user_money(id)-10000, 1);
				set_jbpack(id, return_jbpack(id)+14);
				ColorChat(id, GREEN, "**JailBreak - Kantor**^x01 Wymieniles 10000 Dolarow na 14 Szlugow");
			}
			else
				ColorChat(id, GREEN, "[Kantor]^x01 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_jbpack(id, return_jbpack(id)+22);
				ColorChat(id, GREEN, "[Kantor]^x01 Wymieniles 16000 Dolarow na 22 Szlugi");
			}
			else
				ColorChat(id, GREEN, "[Kantor]^x01 Nie masz wystarczajacej ilosci kasy!");
			
		}
		
	}
	return PLUGIN_CONTINUE;
}

public handle_wymien2(id, menu, item)
{
	switch(item)
	{
		case 0:
		{
			if(return_jbpack(id)>=5)
			{
				set_jbpack(id, return_jbpack(id)-50);
				cs_set_user_money(id, cs_get_user_money(id)+8000, 1);
				ColorChat(id, GREEN, "[Kantor]^x01 Wymieniles 50 Szlugow na 8000 Dolarow");
			}
			else
				ColorChat(id, GREEN, "[Kantor]^x01 Nie masz wystarczajacej ilosci szlugow!");
			
		}
		case 1:
		{
			if(return_jbpack(id)>=10)
			{
				cs_set_user_money(id, cs_get_user_money(id)+10000, 1);
				set_jbpack(id, return_jbpack(id)-70);
				ColorChat(id, GREEN, "[Kantor]^x01 Wymieniles 70 Szlugow na 10000 Dolarow");
			}
			else
				ColorChat(id, GREEN, "[Kantor]^x01 Nie masz wystarczajacej ilosci szlugow!");
			
		}
		case 2:
		{
			if(return_jbpack(id)>=25)
			{
				cs_set_user_money(id, cs_get_user_money(id)+16000, 1);
				set_jbpack(id, return_jbpack(id)-100);
				ColorChat(id, GREEN, "[Kantor]^x01 Wymieniles 100 Szlugow na 16000 Dolarow");
			}
			else
				ColorChat(id, GREEN, "[Kantor]^x01 Nie masz wystarczajacej ilosci szlugow!");
			
		}
		
	}
	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 }
*/
