#include <amxmodx>
#include <cstrike>
#include <ColorChat>

native cod_get_user_Zloto(id)
native cod_set_user_Zloto(id, wartosc)

public plugin_init()
{
	register_plugin("Wymiana Dolarów na Zloto", "1.0", "Play")
	register_logevent("nowa_runda", 2, "0=World triggered", "1=Round_Start")
}

public nowa_runda()
{
	new Players[32],Num, id, money, licz
	get_players(Players,Num,"h")
	
	for(new i=0; i<Num; i++)
	{
		id = Players[i]
		if(!is_user_connected(id)) continue
		
		licz = 0
		money = cod_get_user_Zloto(id)
		while(money >= 16000)
		{
			cod_set_user_Zloto(id, cod_get_user_Zloto(id)+5)
			money -= 16000
			cs_set_user_money(id, money)
			licz++
		}
		if(licz)	
			ColorChat(id, GREEN, "[Katujemy.eu]^x01 Wymieniono^x03 %i$^x01 na^x03 %i^x04 %s", (16000*licz),licz,(licz == 1 ? "Order" : (licz < 5 ? "Zlota" : "Zlota")))
	}
	return PLUGIN_CONTINUE
}