Modificare plugin

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
Post Reply
User avatar
tre3fla
Membru eXtream
Membru eXtream
Posts: 5317
Joined: 27 May 2012, 11:15
Detinator Steam: Da
CS Status: Allah Akbar !
Detinator server CS: Nu
SteamID: /id/tre3fla_xxx
Has thanked: 14 times
Been thanked: 129 times

15 Aug 2012, 15:17

| Afiseaza codul
#define SQLON 0 // 1 = Use SQL | 0 = Use file

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new HELPPAGE[] = "http://home.netcom.com/~everco_ice/bankhelp17.html"

new bool:canuse[33] = false
new interest[33] = 0
new bankfees = 0
new rounds = 0
new sayspecial[33] = 0

#if SQLON
	#include <dbi>
#else
	#include <vault>
#endif

#if SQLON
	new Sql:dbc
	new Result:result
#else
	new allowfilepath[251]
#endif

public plugin_init()
{
	register_plugin("AMX Bank","1.7","twistedeuphoria")
	register_concmd("bank_create","bank_create",ADMIN_USER,"Create a new bank account.")
	register_concmd("bank_close","bank_close",ADMIN_CVAR,"Close the AMX Bank.")
	register_concmd("bank_open","bank_open",ADMIN_CVAR,"Open the AMX Bank for business.")
	register_concmd("bank_amount","bank_amount",ADMIN_USER,"Display the amount of money you have in the bank.")
	register_concmd("bank_deposit","bank_deposit",ADMIN_USER,"<amount> :Deposit money into your bank account.")
	register_concmd("bank_withdraw","bank_withdrawl",ADMIN_USER,"<amount> :Withdraw money from your bank account.")
	register_concmd("bank_help","bank_help",ADMIN_USER,"Open up the help for the bank.")
	register_concmd("bank_transfer","bank_transfer",ADMIN_USER,"<user> <amount> : Transfer money to another player.")
	register_concmd("bank_givemoney","bank_givemoney",ADMIN_CVAR,"<user> <amount> : Give a user money.")
	register_concmd("bank_menu","bank_menu",ADMIN_USER,"Open the bank menu.")
	register_concmd("maxdep","deposit_maximum",ADMIN_USER,"Deposit all your money.")
	register_concmd("maxwit","withdrawl_maximum",ADMIN_USER,"Withdrawl until you have $16000 or your bank account is empty.")
	register_clcmd("say","say_cheese")
	register_clcmd("say_team","say_cheese")
	register_cvar("bank_default_opening","1000")
	register_cvar("bank_state","1")
	register_cvar("bank_min_players","2")
	register_cvar("bank_restrict","0") // 0 = All user can use the bank 1 = Only users defined in file or SQL
	register_cvar("bank_interest_rounds","15")
	register_cvar("bank_interest_rate","0.01")
	register_cvar("bank_fees_base","0")  //Base bank fee in $
	register_cvar("bank_fees_increase","0") //Added to the base fee for each transaction in a round
	register_cvar("bank_offrounds","1") //How many rounds from the start of the map will bank be off for
	register_cvar("bank_msg_interval","60")
	register_cvar("bank_msg","This server is using AMX Bank.  Type bank_help in console to find out how to use it.")
	register_cvar("bank_use_ip","0")
	register_menucmd(register_menuid("Bank Menu:"),1023,"bank_menu_cmd")
	register_logevent("giveinterest",2,"0=World triggered","1=Round_Start")
	register_event("Money", "hookmoney", "b") 
	#if SQLON
		set_task(5.0,"sqlinit")
	#else
		new directory[201]
		get_configsdir(directory,200)
		if(get_cvar_num("bank_restrict") == 2)
		{
			formatex(allowfilepath,250,"%s/bankusers.ini",directory)
			if(!file_exists(allowfilepath))
			{
				new writestr[101]
				formatex(writestr,100,";Put all users who can use the bank in here.")
				write_file(allowfilepath,writestr)
			}			
		}
	#endif
	set_task(float(get_cvar_num("bank_msg_interval")),"bank_spam")
}

public check_use(id,pos)
{
	if(id)
	{
		if(canuse[id] == false)
		{
			if(pos)
				client_print(id,print_chat,"You are not allowed to use the bank.")
			else
				console_print(id,"You are not allowed to use the bank.")
			return 0
		}
	}
	new cvarrounds = get_cvar_num("bank_offrounds")
	if(rounds <= cvarrounds)
	{
		if(pos)
			client_print(id,print_chat,"Sorry, the bank is disabled for the first %d rounds of the map.",cvarrounds)
		else
			console_print(id,"Sorry, the bank is disabled for the first %d rounds of the map.",cvarrounds)
		return 0
	}
	if(!get_cvar_num("bank_state"))
	{
		if(pos)
			client_print(id,print_chat,"Sorry, the bank is closed and no transactions are being processed.")
		else
			console_print(id,"Sorry, the bank is closed and no transactions are being processed.")
		return 0
	}
	new players = get_playersnum()
	new minplayers = get_cvar_num("bank_min_players")
	if(players < minplayers)
	{
		if(pos)
			client_print(id,print_chat,"There must be at least %d players connected to use the bank.",minplayers)
		else
			console_print(id,"There must be at least %d players connected to use the bank.",minplayers)
		return 0
	}
	return 1
}

public get_balance(id)
{
	new sid[35]
	new balance = -1
	if(get_cvar_num("bank_use_ip"))
		get_user_ip(id,sid,34)
	else
		get_user_authid(id,sid,34)
	#if SQLON
		result = dbi_query(dbc,"SELECT * FROM bank WHERE sid = '%s'",sid)
		if(result == RESULT_NONE)
			dbi_free_result(result)
		else
		{
			dbi_nextrow(result)
			balance = dbi_result(result,"amount")
			dbi_free_result(result)
		}
	#else
		new key[51]
		formatex(key,50,"%s_account",sid)
		if(vaultdata_exists(key))
		{
			new balancestr[21]
			get_vaultdata(key,balancestr,20)
			balance = str_to_num(balancestr)
		}
	#endif
	return balance
}

public set_balance(id,balance)
{
	new sid[35]
	if(get_cvar_num("bank_use_ip"))
		get_user_ip(id,sid,34)
	else
		get_user_authid(id,sid,34)
	#if SQLON
		result = dbi_query(dbc,"UPDATE bank SET amount = '%d' WHERE sid = '%s'",balance,sid)
		if(result == RESULT_NONE)
		{
			dbi_free_result(result)
			return -1
		}
		else
			return 1
	#else
		new key[51]
		formatex(key,50,"%s_account",sid)
		if(vaultdata_exists(key))
		{
			new balancestr[21]
			num_to_str(balance,balancestr,20)
			set_vaultdata(key,balancestr)
			return 1
		}
		else
			return -1
	#endif
	return -1	
}

public bank_menu(id)
{
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new menubody[276], keys = 0,len
	new bool:hasacc = true
	len = format(menubody,275,"\yBank Menu:\w^n")
	if(get_balance(id) == -1)
	{
		hasacc = false
		len += format(menubody[len],275-len,"1. Open a Bank Account^n\d")
		keys |= (1<<0|1<<9)		
	}
	else
		len += format(menubody[len],275-len,"\d1. Open a Bank Account^n\w")
	len += format(menubody[len],275-len,"2. Check your Balance^n3. Deposit Money^n4. Deposit All^n5. Withdraw Money^n6. Withdraw Maximum^n7. Bank Help^n8. Transfer Money^n^n")
	if(hasacc)
	{
		len += format(menubody[len],275-len,"0. Exit")
		keys |= (1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<9)
	}
	else
		len += format(menubody[len],275-len,"\w0. Exit")
	show_menu(id,keys,menubody,-1,"Bank Menu:")
	return PLUGIN_CONTINUE
}

public bank_menu_cmd(id,key)
{
	switch(key)
	{
		case 0: client_cmd(id,"bank_create 1")
		case 1: client_cmd(id,"bank_amount 1")
		case 2:
		{
			sayspecial[id] = 1
			client_print(id,print_chat,"Please enter the amount you want to deposit in chat:")
		}			
		case 3: client_cmd(id,"maxdep")
		case 4:
		{	
			sayspecial[id] = 2
			client_print(id,print_chat,"Please enter the amount you want to withdraw in chat:")
		}
		case 5: client_cmd(id,"maxwit")
		case 6:	client_cmd(id,"bank_help")
		case 7:
		{
			sayspecial[id] = 3
			client_print(id,print_chat,"Please enter the person you want to transfer to and the amount you want to transfer in chat:")
		}
	}
	return PLUGIN_HANDLED
}

public bank_givemoney(id,level,cid)
{
	if(!cmd_access(id,level,cid,3))
		return PLUGIN_HANDLED
	new target[32], tid
	read_argv(1,target,31)
	tid = cmd_target(id,target,2)
	if(!tid)
		return PLUGIN_HANDLED
	new amountstr[10], amount
	read_argv(2,amountstr,9)
	amount = str_to_num(amountstr)
	new totam = amount
	new curmoney = cs_get_user_money(tid)
	new newtotal = curmoney + amount
	if(newtotal > 16000)
	{		
		cs_set_user_money(tid,16000)
		amount = newtotal - 16000
	}
	else
	{
		cs_set_user_money(tid,newtotal)
		amount = 0
	}
	if(amount > 0)
	{	
		new balance = get_balance(tid)
		if(balance != -1)
			set_balance(id,balance + amount)
	}
	new name[32], tname[32]
	get_user_name(id,name,31)
	get_user_name(tid,tname,31)
	if(read_argc() == 4)
		client_print(id,print_chat,"You gave %s $%d.",tname,totam)
	else
		console_print(id,"You gave %s $%d.",tname,totam)
	client_print(tid,print_chat,"%s gave you $%d, $%d of which went into your bank account.",name,totam,amount)
	return PLUGIN_HANDLED
}	

public bank_transfer(id)
{
	new client = 0
	if(read_argc() > 3)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new target[32]
	read_argv(1,target,31)
	new tgt = cmd_target(id,target,8)
	if(!tgt)
		return PLUGIN_HANDLED
	if(id == tgt)
	{
		if(client)
			client_print(id,print_chat,"You may not transfer money to yourself.")
		else
			console_print(id,"You may not transfer money to yourself.")
		return PLUGIN_HANDLED
	}		
	new tamounts[9],tamount
	read_argv(2,tamounts,8)
	tamount = str_to_num(tamounts)
	if(tamount <= 0) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			client_print(id,print_chat,"You do not have a bank account to transfer money from.")
		else
			console_print(id,"You do not have a bank account to transfer money from.")
		return PLUGIN_HANDLED
	}
	new tbalance = get_balance(tgt)
	new name[32], tname[32]
	get_user_name(tgt,tname,31)
	get_user_name(id,name,31)	
	if(tbalance == -1)
	{
		if(client)
			client_print(id,print_chat,"%s does not have a bank account to transfer money to.",tname)
		else
			console_print(id,"%s does not have a bank account to transfer money to.",tname)
		client_print(tgt,print_chat,"%s tried to transfer money to your account but you don't have a bank account!",name)
		return PLUGIN_HANDLED
	}	
	balance -= tamount
	balance -= bankfees
	if(balance < 0)
	{
		if(client)
			client_print(id,print_chat,"You do not have enough money in your bank account.")
		else
			console_print(id,"You do not have enough money in your bank account.")
		return PLUGIN_HANDLED
	}
	tbalance += tamount
	if(bankfees > 0)
	{
		if(client)
			client_print(id,print_chat,"You paid $%d in bank fees.",bankfees)
		else
			console_print(id,"You paid $%d in bank fees.",bankfees)
	}		
	set_balance(id,balance)
	set_balance(tgt,tbalance)
	if(client)
		client_print(id,print_chat,"You have transferred $%d to %s's bank account. You now have $%d in your account.",tamount,tname,balance)
	else
		console_print(id,"You have transferred $%d to %s's bank account. You now have $%d in your account.",tamount,tname,balance)
	client_print(tgt,print_chat,"%s has transferred $%d to your bank account. You now have $%d in your account.",name,tamount,tbalance)
	return PLUGIN_HANDLED
}


public hookmoney()
{
	if(!get_cvar_num("bank_state"))
		return PLUGIN_CONTINUE
	new curmoney = read_data(1)
	if(curmoney < 16000)
		return PLUGIN_CONTINUE
	new id
	for(new inum=0;inum<=32;inum++)
	{
		if(!is_user_connected(inum)) continue
		new rmoney = cs_get_user_money(inum)
		if(rmoney == curmoney)
		{
			id = inum
			break;
		}
	}
	if(canuse[id] == false)
		return PLUGIN_CONTINUE
	new cvarrounds = get_cvar_num("bank_offrounds")
	if(rounds <= cvarrounds)
		return PLUGIN_CONTINUE
	if(get_playersnum() >= get_cvar_num("bank_min_players"))
	{
		new balance = get_balance(id)
		if(balance == -1)
			return PLUGIN_CONTINUE
		balance += 10000
		set_balance(id,balance)
		cs_set_user_money(id,curmoney-10000)
		client_print(id,print_chat,"$10000 has been automatically deposited in your bank account. You now have $%d in your account.",balance)
	}
	return PLUGIN_CONTINUE
}

public bank_spam()
{
	new cvarval = get_cvar_num("bank_state")
	if(cvarval)
	{
		new message[256]
		get_cvar_string("bank_msg",message,255)
		client_print(0,print_chat,message)
	}
	set_task(float(get_cvar_num("bank_msg_interval")),"bank_spam")
}

public bank_help(id)
{
	show_motd(id,HELPPAGE,"AMX Bank Help")
}

public say_cheese(id)
{
	new said[191]
	read_args(said,190)
	remove_quotes(said)
	if(sayspecial[id])
	{
		switch(sayspecial[id])
		{
			case 1: client_cmd(id,"bank_deposit %s 1",said)
			case 2: client_cmd(id,"bank_withdraw %s 1",said)
			case 3: client_cmd(id,"bank_transfer %s 1",said)
		}
		sayspecial[id] = 0
		return PLUGIN_HANDLED
	}				
	if(said[0] == 'm')
	{
		if(equali(said,"maxwit"))
		{
			withdrawl_maximum(id)
			return PLUGIN_HANDLED
		}
		if(equali(said,"maxdep"))
		{
			deposit_maximum(id)
			return PLUGIN_HANDLED
		}
	}
	else if(said[0] == 'b')
	{
		if(containi(said,"bank_") != -1)
		{
			if(equali(said,"bank_amount"))
			{
				client_cmd(id,"bank_amount 1")
				return PLUGIN_HANDLED
			}
			if(containi(said,"bank_withdraw") != -1)
			{
				replace(said,190,"bank_withdraw","")
				client_cmd(id,"bank_withdraw %s 1",said)
				return PLUGIN_HANDLED
			}
			if(containi(said,"bank_deposit") != -1)
			{
				replace(said,190,"bank_deposit","")
				client_cmd(id,"bank_deposit %s 1",said)
				return PLUGIN_HANDLED
			}
			if(containi(said,"bank_transfer") != -1)
			{
				replace(said,190,"bank_transfer","")
				new target[51],amountstr[51]
				parse(said,target,50,amountstr,50)
				client_cmd(id,"bank_transfer %s %s 1",target,amountstr)
				return PLUGIN_HANDLED
			}
			if(containi(said,"bank_givemoney") != -1)
			{
				replace(said,190,"bank_givemoney","")
				new target[51],amountstr[51]
				parse(said,target,50,amountstr,50)
				client_cmd(id,"bank_givemoney %s %s 1",target,amountstr)
				return PLUGIN_HANDLED
			}
			if(equali(said,"bank_create"))
			{
				client_cmd(id,"bank_create 1")
				return PLUGIN_HANDLED
			}			
			if(equali(said,"bank_help"))
			{
				bank_help(id)
				return PLUGIN_HANDLED
			}
			if(equali(said,"bank_open"))
			{
				client_cmd(id,"bank_open 1")
				return PLUGIN_HANDLED
			}
			if(equali(said,"bank_close"))
			{
				client_cmd(id,"bank_close 1")
				return PLUGIN_HANDLED
			}					
			if(equali(said,"bank_menu"))
			{
				client_cmd(id,"bank_menu")
				return PLUGIN_HANDLED
			}
		}
	}
	return PLUGIN_CONTINUE
}

public giveinterest()
{
	rounds++
	if(!check_use(0,1)) return PLUGIN_CONTINUE
	bankfees = get_cvar_num("bank_fees_base")
	new Float:rate = get_cvar_float("bank_interest_rate")
	new irounds = get_cvar_num("bank_interest_rounds")
	if(!get_cvar_num("bank_state"))
		return PLUGIN_CONTINUE
	for(new i = 1;i<=32;i++)
	{
		if(is_user_connected(i))
		{
			if(canuse)
			{
				interest++
				if(interest >= irounds)
				{
					interest = 0
					new balance = get_balance(i)
					if(balance != -1)
					{
						new Float:give = floatmul(rate,float(balance))
						new givint = floatround(give)
						if(givint > 0)
						{
							new allowed = 16000 - cs_get_user_money(i)
							if(givint <= allowed)
							{
								cs_set_user_money(i,cs_get_user_money(i)+givint)
								client_print(i,print_chat,"You were given $%d in interest.",givint)
							}
							else
							{
								new dep = givint - allowed
								client_print(i,print_chat,"You were given $%d in interest $%d of which went into your account.",givint,dep)
								cs_set_user_money(i,16000)
								balance += dep
								set_balance(i,balance)
							}
						}
					}
				}
			}
		}
	}
	return PLUGIN_CONTINUE
}

public client_putinserver(id)
{
	interest[id] = 0
	canuse[id] = false
	switch(get_cvar_num("bank_restrict"))
	{
		case 0:
		{
			canuse[id] = true
		}
		case 1:
		{
			if(access(id,ADMIN_CHAT))
				canuse[id] = true
			else
				canuse[id] = false
		}
		case 2:
		{
			canuse[id] = false
			new sid[35]
			if(get_cvar_num("bank_use_ip"))
				get_user_ip(id,sid,34,1)
			else
				get_user_authid(id,sid,34)
			#if SQLON	
				result = dbi_query(dbc,"SELECT * FROM bankusers WHERE sid = '%s'",sid)
				if(result == RESULT_NONE)
					canuse[id] = false
				else
					canuse[id] = true
				dbi_free_result(result)
			#else
				new retstr[35],a,i
				while(read_file(allowfilepath,i,retstr,34,a))
				{
					if(equali(sid,retstr))
						canuse[id] = true
					i++
				}
			#endif
		}
	}
}	

public client_disconnect(id)
{
	canuse[id] = false
	interest[id] = 0
}

public deposit_maximum(id)	
{
	if(!check_use(id,1)) return PLUGIN_HANDLED	
	new curmoney = cs_get_user_money(id)
	new balance = get_balance(id)
	if(balance == -1)
	{
		client_print(id,print_chat,"You do not have a bank account.")
		return PLUGIN_HANDLED	
	}
	balance += curmoney
	set_balance(id,balance)
	cs_set_user_money(id,0)
	client_print(id,print_chat,"You have deposited $%d in your bank account. You now have $%d in your account.",curmoney,balance)
	return PLUGIN_HANDLED
}

public withdrawl_maximum(id)
{
	if(!check_use(id,1)) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		client_print(id,print_chat,"You do not have a bank account.")
		return PLUGIN_HANDLED
	}
	new curmoney = cs_get_user_money(id)
	new maxmoney = 16000 - cs_get_user_money(id)
	if(maxmoney > balance)
		maxmoney = balance
	balance -= maxmoney
	cs_set_user_money(id,curmoney + maxmoney,1)
	if((balance - bankfees) > 0)
		balance -= bankfees
	else
		cs_set_user_money(id,cs_get_user_money(id) - bankfees)
	if(bankfees > 0)
		client_print(id,print_chat,"You paid $%d in bank fees.",bankfees)
	bankfees += get_cvar_num("bank_fees_increase")		
	set_balance(id,balance)
	client_print(id,print_chat,"You have withdrawn $%d from your bank account. You now have $%d in your account.",maxmoney,balance)
	return PLUGIN_HANDLED
}
	
public bank_amount(id)
{
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			client_print(id,print_chat,"You do not have a bank account.")
		else
			console_print(id,"You do not have a bank account.")
		return PLUGIN_HANDLED		
	}
	else
	{
		if(client)
			client_print(id,print_chat,"You have $%d in your bank account.",balance)
		else
			console_print(id,"You have $%d in your bank account.",balance)
	}
	return PLUGIN_HANDLED
}

public bank_open(id,level,cid)
{
	if(!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(get_cvar_num("bank_state"))
	{
		if(client)
			client_print(id,print_chat,"The AMX bank is already open.")
		else
			console_print(id,"The AMX bank is already open.")
	}
	else
	{
		console_cmd(id,"amx_cvar bank_state 1")
		if(get_cvar_num("bank_state"))
		{
			if(client)
				client_print(id,print_chat,"The bank is now open.")
			else
				console_print(id,"The bank is now open.")
			client_print(0,print_chat,"The bank is now open for business.")
		}		
		else
		{
			if(client)
				client_print(id,print_chat,"You may not open the bank.")
			else
				console_print(id,"You may not open the bank.")
		}	
	}
	return PLUGIN_HANDLED
}

public bank_close(id,level,cid)
{	
	if(!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	new client = 0 
	if(read_argc() > 1)
		client = 1
	if(!get_cvar_num("bank_state"))
	{
		if(client)
			client_print(id,print_chat,"The AMX bank is already closed.")
		else
			console_print(id,"The AMX bank is already closed.")
	}
	else
	{
		console_cmd(id,"amx_cvar bank_state 0")
		if(!get_cvar_num("bank_state"))
		{
			if(client)
				client_print(id,print_chat,"The bank is now closed.")
			else
				console_print(id,"The bank is now closed.")
			client_print(0,print_chat,"The bank is now closed.")
		}		
		else
		{
			if(client)
				client_print(id,print_chat,"You may not close the bank.")
			else
				console_print(id,"You may not close the bank.")
		}	
	}
	return PLUGIN_HANDLED
}

public sqlinit()
{
	#if SQLON
		new error[32],sqlhostname[35],sqluser[35],sqlpass[35],sqldbname[35]
		get_cvar_string("amx_sql_host",sqlhostname,34)
		get_cvar_string("amx_sql_user",sqluser,34)
		get_cvar_string("amx_sql_pass",sqlpass,34)
		get_cvar_string("amx_sql_db",sqldbname,34)
		dbc = dbi_connect(sqlhostname,sqluser,sqlpass,sqldbname,error,31)
		if(dbc == SQL_FAILED)
		{
			server_print("Could not connect.")
			return PLUGIN_HANDLED
		}
		result = dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `bank` (`sid` VARCHAR(35), `amount` BIGINT(20))")
		dbi_free_result(result)
		result = dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `bankusers` (`sid` VARCHAR(35), `comments` VARCHAR(100))")
		dbi_free_result(result)
	#endif
	return 1
}

public bank_create(id)
{
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new curmoney,neededmoney, amount
	neededmoney = get_cvar_num("bank_default_opening")
	curmoney = cs_get_user_money(id)
	if(curmoney >= neededmoney)
	{
		amount = neededmoney
		curmoney -= neededmoney
	}
	else
	{
		amount = curmoney
		curmoney = 0
	}
	#if SQLON
		new sid[35]
		if(get_cvar_num("bank_use_ip"))
			get_user_ip(id,sid,34,1)
		else
			get_user_authid(id,sid,34)
		result = dbi_query(dbc,"SELECT * FROM bank WHERE sid = '%s'",sid)
		if(result != RESULT_NONE)
		{
			if(client)
				client_print(id,print_chat,"You already have a bank account!")
			else
				console_print(id,"You already have a bank account!")
			return PLUGIN_HANDLED
		}
		dbi_free_result(result)
		result = dbi_query(dbc,"INSERT INTO bank VALUES ( '%s' , '%d')",sid,amount)
		dbi_free_result(result)
	#else
		new sid[35],key[51]
		if(get_cvar_num("bank_use_ip"))
			get_user_ip(id,sid,34,1)
		else
			get_user_authid(id,sid,34)
		format(key,50,"%s_account",sid)
		if(vaultdata_exists(key))
		{
			if(client)
				client_print(id,print_chat,"You already have a bank account!")
			else
				console_print(id,"You already have a bank account!")
			return PLUGIN_HANDLED
		}
		new saveamstr[21]
		num_to_str(amount,saveamstr,20)
		set_vaultdata(key,saveamstr)
	#endif			
	cs_set_user_money(id,curmoney)
	if(client)
		client_print(id,print_chat,"Bank account created successfully. Your account has $%d in it.",amount)
	else
		console_print(id,"Bank account created successfully. Your account has $%d in it.",amount)
	return PLUGIN_HANDLED
}

public bank_withdrawl(id)
{
	new client = 0
	if(read_argc() > 2)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			client_print(id,print_chat,"You do not have a bank account.")
		else
			console_print(id,"You do not have a bank account.")
		return PLUGIN_HANDLED		
	}
	new ams[9],amn,maxam	
	read_args(ams,8)
	amn = str_to_num(ams)
	if(amn <= 0) return PLUGIN_HANDLED	
	maxam = 16000 - cs_get_user_money(id)
	if(amn > maxam)
		amn = maxam
	if(amn > balance)
	{
		if(client)
			client_print(id,print_chat,"There is not enough money in your bank account.")
		else
			console_print(id,"There is not enough money in your bank account.")
		return PLUGIN_HANDLED
	}
	balance -= amn
	cs_set_user_money(id,cs_get_user_money(id) + amn)
	if(balance >= bankfees)
		balance -= bankfees
	else
		cs_set_user_money(id,cs_get_user_money(id) - bankfees)	
	set_balance(id,balance)
	if(bankfees > 0)
	{
		if(client)
			client_print(id,print_chat,"You paid $%d in bank fees.",bankfees)
		else
			console_print(id,"You paid $%d in bank fees.",bankfees)
	}
	bankfees += get_cvar_num("bank_fees_increase")
	if(client)
		client_print(id,print_chat,"You have withdrawn $%d from your bank account. You now have $%d in your account.",amn,balance)
	else
		console_print(id,"You have withdrawn $%d from your bank account. You now have $%d in your account.",amn,balance)
	return PLUGIN_HANDLED
}

public bank_deposit(id)
{
	new client = 0
	if(read_argc() > 2)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new damounts[9],damount,curmoney
	read_args(damounts,8)
	damount = str_to_num(damounts)
	if(damount <= 0) return PLUGIN_HANDLED
	curmoney = cs_get_user_money(id)
	if(damount > curmoney)
	{
		if(client)
			client_print(id,print_chat,"You don't have that much money.")
		else
			console_print(id,"You don't have that much money.")
		return PLUGIN_HANDLED
	}
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			client_print(id,print_chat,"You do not have a bank account.")
		else
			console_print(id,"You do not have a bank account.")
		return PLUGIN_HANDLED
	}
	balance += damount
	set_balance(id,balance)
	cs_set_user_money(id,curmoney - damount)
	if(client)
		client_print(id,print_chat,"You have deposited $%d in your bank account. You now have $%d in your account.",damount,balance)
	else
		console_print(id,"You have deposited $%d in your bank account. You now have $%d in your account.",damount,balance)
	return PLUGIN_HANDLED
}


Vreau sa-mi colorati acest plugin,mai precis sa-mi adaugati care un prefix in fata fiecarui mesaj din chat cate un [Bank] si sa schimbati comenzile urmatoare :

create_bank in /signup
bank_amount in "bank"
bank_deposit in deposit
bank_withdraw in withdraw
bank_transfer in transfer
bank_givemoney in amx_givemoney
bank_menu /bmenu
maxdep in save all
maxwit in take all

am incercat sa-l colorez cu colorchat,am pus totul cum trebuie,am inclus .inc'ul am moficiat print_chat cu ColorChat,de pomana tot eroare la compilare :(
RoyalServer 2
User avatar
K1d0x
Fost moderator
Fost moderator
Posts: 800
Joined: 26 Feb 2012, 15:57
Detinator Steam: Da
CS Status: We Build Together ;3 RedFear
Detinator server CS: PuB.RedFear.Ro
SteamID: k1dox
Reputatie: Fost moderator ajutator
Location: Reșița
Been thanked: 152 times
Contact:

15 Aug 2012, 15:44

| Afiseaza codul
#define SQLON 0 // 1 = Use SQL | 0 = Use file

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

/* ChatColor */
enum Color { NORMAL = 1, GREEN, TEAM_COLOR, GREY, RED, BLUE, }

new TeamName[][] = { "", "TERRORIST", "CT", "SPECTATOR" }

new HELPPAGE[] = "http://home.netcom.com/~everco_ice/bankhelp17.html"

new bool:canuse[33] = false
new interest[33] = 0
new bankfees = 0
new rounds = 0
new sayspecial[33] = 0

#if SQLON
	#include <dbi>
#else
	#include <vault>
#endif

#if SQLON
	new Sql:dbc
	new Result:result
#else
	new allowfilepath[251]
#endif

public plugin_init()
{
	register_plugin("AMX Bank","1.7","twistedeuphoria")
	register_concmd("bank_create","bank_create",ADMIN_USER,"Create a new bank account.")
	register_concmd("bank_close","bank_close",ADMIN_CVAR,"Close the AMX Bank.")
	register_concmd("bank_open","bank_open",ADMIN_CVAR,"Open the AMX Bank for business.")
	register_concmd("bank_amount","bank_amount",ADMIN_USER,"Display the amount of money you have in the bank.")
	register_concmd("bank_deposit","bank_deposit",ADMIN_USER,"<amount> :Deposit money into your bank account.")
	register_concmd("bank_withdraw","bank_withdrawl",ADMIN_USER,"<amount> :Withdraw money from your bank account.")
	register_concmd("bank_help","bank_help",ADMIN_USER,"Open up the help for the bank.")
	register_concmd("bank_transfer","bank_transfer",ADMIN_USER,"<user> <amount> : Transfer money to another player.")
	register_concmd("amx_givemoney","bank_givemoney",ADMIN_CVAR,"<user> <amount> : Give a user money.")
	register_concmd("bank_menu","bank_menu",ADMIN_USER,"Open the bank menu.")
	register_concmd("maxdep","deposit_maximum",ADMIN_USER,"Deposit all your money.")
	register_concmd("maxwit","withdrawl_maximum",ADMIN_USER,"Withdrawl until you have $16000 or your bank account is empty.")
	register_clcmd("say","say_cheese")
	register_clcmd("say_team","say_cheese")
	register_cvar("bank_default_opening","1000")
	register_cvar("bank_state","1")
	register_cvar("bank_min_players","2")
	register_cvar("bank_restrict","0") // 0 = All user can use the bank 1 = Only users defined in file or SQL
	register_cvar("bank_interest_rounds","15")
	register_cvar("bank_interest_rate","0.01")
	register_cvar("bank_fees_base","0")  //Base bank fee in $
	register_cvar("bank_fees_increase","0") //Added to the base fee for each transaction in a round
	register_cvar("bank_offrounds","1") //How many rounds from the start of the map will bank be off for
	register_cvar("bank_msg_interval","60")
	register_cvar("bank_msg","This server is using AMX Bank.  Type bank_help in console to find out how to use it.")
	register_cvar("bank_use_ip","0")
	register_menucmd(register_menuid("Bank Menu:"),1023,"bank_menu_cmd")
	register_logevent("giveinterest",2,"0=World triggered","1=Round_Start")
	register_event("Money", "hookmoney", "b") 
	#if SQLON
		set_task(5.0,"sqlinit")
	#else
		new directory[201]
		get_configsdir(directory,200)
		if(get_cvar_num("bank_restrict") == 2)
		{
			formatex(allowfilepath,250,"%s/bankusers.ini",directory)
			if(!file_exists(allowfilepath))
			{
				new writestr[101]
				formatex(writestr,100,";Put all users who can use the bank in here.")
				write_file(allowfilepath,writestr)
			}			
		}
	#endif
	set_task(float(get_cvar_num("bank_msg_interval")),"bank_spam")
}

public check_use(id,pos)
{
	if(id)
	{
		if(canuse[id] == false)
		{
			if(pos)
				ColorChat(id, NORMAL, "^x04[Bank] ^x01You are not allowed to use the bank.")
			else
				console_print(id,"You are not allowed to use the bank.")
			return 0
		}
	}
	new cvarrounds = get_cvar_num("bank_offrounds")
	if(rounds <= cvarrounds)
	{
		if(pos)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01Sorry, the bank is disabled for the first %d rounds of the map.",cvarrounds)
		else
			console_print(id,"Sorry, the bank is disabled for the first %d rounds of the map.",cvarrounds)
		return 0
	}
	if(!get_cvar_num("bank_state"))
	{
		if(pos)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01Sorry, the bank is closed and no transactions are being processed.")
		else
			console_print(id,"Sorry, the bank is closed and no transactions are being processed.")
		return 0
	}
	new players = get_playersnum()
	new minplayers = get_cvar_num("bank_min_players")
	if(players < minplayers)
	{
		if(pos)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01There must be at least %d players connected to use the bank.",minplayers)
		else
			console_print(id,"There must be at least %d players connected to use the bank.",minplayers)
		return 0
	}
	return 1
}

public get_balance(id)
{
	new sid[35]
	new balance = -1
	if(get_cvar_num("bank_use_ip"))
		get_user_ip(id,sid,34)
	else
		get_user_authid(id,sid,34)
	#if SQLON
		result = dbi_query(dbc,"SELECT * FROM bank WHERE sid = '%s'",sid)
		if(result == RESULT_NONE)
			dbi_free_result(result)
		else
		{
			dbi_nextrow(result)
			balance = dbi_result(result,"amount")
			dbi_free_result(result)
		}
	#else
		new key[51]
		formatex(key,50,"%s_account",sid)
		if(vaultdata_exists(key))
		{
			new balancestr[21]
			get_vaultdata(key,balancestr,20)
			balance = str_to_num(balancestr)
		}
	#endif
	return balance
}

public set_balance(id,balance)
{
	new sid[35]
	if(get_cvar_num("bank_use_ip"))
		get_user_ip(id,sid,34)
	else
		get_user_authid(id,sid,34)
	#if SQLON
		result = dbi_query(dbc,"UPDATE bank SET amount = '%d' WHERE sid = '%s'",balance,sid)
		if(result == RESULT_NONE)
		{
			dbi_free_result(result)
			return -1
		}
		else
			return 1
	#else
		new key[51]
		formatex(key,50,"%s_account",sid)
		if(vaultdata_exists(key))
		{
			new balancestr[21]
			num_to_str(balance,balancestr,20)
			set_vaultdata(key,balancestr)
			return 1
		}
		else
			return -1
	#endif
	return -1	
}

public bank_menu(id)
{
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new menubody[276], keys = 0,len
	new bool:hasacc = true
	len = format(menubody,275,"yBank Menu:w^n")
	if(get_balance(id) == -1)
	{
		hasacc = false
		len += format(menubody[len],275-len,"1. Open a Bank Account^nd")
		keys |= (1<<0|1<<9)		
	}
	else
		len += format(menubody[len],275-len,"d1. Open a Bank Account^nw")
	len += format(menubody[len],275-len,"2. Check your Balance^n3. Deposit Money^n4. Deposit All^n5. Withdraw Money^n6. Withdraw Maximum^n7. Bank Help^n8. Transfer Money^n^n")
	if(hasacc)
	{
		len += format(menubody[len],275-len,"0. Exit")
		keys |= (1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<9)
	}
	else
		len += format(menubody[len],275-len,"w0. Exit")
	show_menu(id,keys,menubody,-1,"Bank Menu:")
	return PLUGIN_CONTINUE
}

public bank_menu_cmd(id,key)
{
	switch(key)
	{
		case 0: client_cmd(id,"bank_create 1")
		case 1: client_cmd(id,"bank_amount 1")
		case 2:
		{
			sayspecial[id] = 1
			ColorChat(id, NORMAL, "^x04[Bank] ^x01Please enter the amount you want to deposit in chat:")
		}			
		case 3: client_cmd(id,"maxdep")
		case 4:
		{	
			sayspecial[id] = 2
			ColorChat(id, NORMAL, "^x04[Bank] ^x01Please enter the amount you want to withdraw in chat:")
		}
		case 5: client_cmd(id,"maxwit")
		case 6:	client_cmd(id,"bank_help")
		case 7:
		{
			sayspecial[id] = 3
			ColorChat(id, NORMAL, "^x04[Bank] ^x01Please enter the person you want to transfer to and the amount you want to transfer in chat:")
		}
	}
	return PLUGIN_HANDLED
}

public bank_givemoney(id,level,cid)
{
	if(!cmd_access(id,level,cid,3))
		return PLUGIN_HANDLED
	new target[32], tid
	read_argv(1,target,31)
	tid = cmd_target(id,target,2)
	if(!tid)
		return PLUGIN_HANDLED
	new amountstr[10], amount
	read_argv(2,amountstr,9)
	amount = str_to_num(amountstr)
	new totam = amount
	new curmoney = cs_get_user_money(tid)
	new newtotal = curmoney + amount
	if(newtotal > 16000)
	{		
		cs_set_user_money(tid,16000)
		amount = newtotal - 16000
	}
	else
	{
		cs_set_user_money(tid,newtotal)
		amount = 0
	}
	if(amount > 0)
	{	
		new balance = get_balance(tid)
		if(balance != -1)
			set_balance(id,balance + amount)
	}
	new name[32], tname[32]
	get_user_name(id,name,31)
	get_user_name(tid,tname,31)
	if(read_argc() == 4)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01You gave %s $%d.",tname,totam)
	else
		console_print(id,"You gave %s $%d.",tname,totam)
	ColorChat(id, NORMAL, "^x04[Bank] ^x01%s gave you $%d, $%d of which went into your bank account.",name,totam,amount)
	return PLUGIN_HANDLED
}	

public bank_transfer(id)
{
	new client = 0
	if(read_argc() > 3)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new target[32]
	read_argv(1,target,31)
	new tgt = cmd_target(id,target,8)
	if(!tgt)
		return PLUGIN_HANDLED
	if(id == tgt)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You may not transfer money to yourself.")
		else
			console_print(id,"You may not transfer money to yourself.")
		return PLUGIN_HANDLED
	}		
	new tamounts[9],tamount
	read_argv(2,tamounts,8)
	tamount = str_to_num(tamounts)
	if(tamount <= 0) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You do not have a bank account to transfer money from.")
		else
			console_print(id,"You do not have a bank account to transfer money from.")
		return PLUGIN_HANDLED
	}
	new tbalance = get_balance(tgt)
	new name[32], tname[32]
	get_user_name(tgt,tname,31)
	get_user_name(id,name,31)	
	if(tbalance == -1)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01%s does not have a bank account to transfer money to.",tname)
		else
			console_print(id,"%s does not have a bank account to transfer money to.",tname)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01%s tried to transfer money to your account but you don't have a bank account!",name)
		return PLUGIN_HANDLED
	}	
	balance -= tamount
	balance -= bankfees
	if(balance < 0)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You do not have enough money in your bank account.")
		else
			console_print(id,"You do not have enough money in your bank account.")
		return PLUGIN_HANDLED
	}
	tbalance += tamount
	if(bankfees > 0)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You paid $%d in bank fees.",bankfees)
		else
			console_print(id,"You paid $%d in bank fees.",bankfees)
	}		
	set_balance(id,balance)
	set_balance(tgt,tbalance)
	if(client)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01You have transferred $%d to %s's bank account. You now have $%d in your account.",tamount,tname,balance)
	else
		console_print(id,"You have transferred $%d to %s's bank account. You now have $%d in your account.",tamount,tname,balance)
	ColorChat(id, NORMAL, "^x04[Bank] ^x01%s has transferred $%d to your bank account. You now have $%d in your account.",name,tamount,tbalance)
	return PLUGIN_HANDLED
}


public hookmoney()
{
	if(!get_cvar_num("bank_state"))
		return PLUGIN_CONTINUE
	new curmoney = read_data(1)
	if(curmoney < 16000)
		return PLUGIN_CONTINUE
	new id
	for(new inum=0;inum<=32;inum++)
	{
		if(!is_user_connected(inum)) continue
		new rmoney = cs_get_user_money(inum)
		if(rmoney == curmoney)
		{
			id = inum
			break;
		}
	}
	if(canuse[id] == false)
		return PLUGIN_CONTINUE
	new cvarrounds = get_cvar_num("bank_offrounds")
	if(rounds <= cvarrounds)
		return PLUGIN_CONTINUE
	if(get_playersnum() >= get_cvar_num("bank_min_players"))
	{
		new balance = get_balance(id)
		if(balance == -1)
			return PLUGIN_CONTINUE
		balance += 10000
		set_balance(id,balance)
		cs_set_user_money(id,curmoney-10000)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01$10000 has been automatically deposited in your bank account. You now have $%d in your account.",balance)
	}
	return PLUGIN_CONTINUE
}

public bank_spam()
{
	new cvarval = get_cvar_num("bank_state")
	if(cvarval)
	{
		new message[256]
		get_cvar_string("bank_msg",message,255)
		client_print(0,print_chat,message)
	}
	set_task(float(get_cvar_num("bank_msg_interval")),"bank_spam")
}

public bank_help(id)
{
	show_motd(id,HELPPAGE,"AMX Bank Help")
}

public say_cheese(id)
{
	new said[191]
	read_args(said,190)
	remove_quotes(said)
	if(sayspecial[id])
	{
		switch(sayspecial[id])
		{
			case 1: client_cmd(id,"bank_deposit %s 1",said)
			case 2: client_cmd(id,"bank_withdraw %s 1",said)
			case 3: client_cmd(id,"bank_transfer %s 1",said)
		}
		sayspecial[id] = 0
		return PLUGIN_HANDLED
	}				
	if(said[0] == 'm')
	{
		if(equali(said,"save all"))
		{
			withdrawl_maximum(id)
			return PLUGIN_HANDLED
		}
		if(equali(said,"take all"))
		{
			deposit_maximum(id)
			return PLUGIN_HANDLED
		}
	}
	else if(said[0] == 'b')
	{
			if(equali(said,"bank"))
			{
				client_cmd(id,"bank_amount 1")
				return PLUGIN_HANDLED
			}
			if(containi(said,"withdraw") != -1)
			{
				replace(said,190,"bank_withdraw","")
				client_cmd(id,"bank_withdraw %s 1",said)
				return PLUGIN_HANDLED
			}
			if(containi(said,"deposit") != -1)
			{
				replace(said,190,"bank_deposit","")
				client_cmd(id,"bank_deposit %s 1",said)
				return PLUGIN_HANDLED
			}
			if(containi(said,"transfer") != -1)
			{
				replace(said,190,"bank_transfer","")
				new target[51],amountstr[51]
				parse(said,target,50,amountstr,50)
				client_cmd(id,"bank_transfer %s %s 1",target,amountstr)
				return PLUGIN_HANDLED
			}
			if(containi(said,"bank_givemoney") != -1)
			{
				replace(said,190,"bank_givemoney","")
				new target[51],amountstr[51]
				parse(said,target,50,amountstr,50)
				client_cmd(id,"bank_givemoney %s %s 1",target,amountstr)
				return PLUGIN_HANDLED
			}
			if(equali(said,"signup"))
			{
				client_cmd(id,"bank_create 1")
				return PLUGIN_HANDLED
			}			
			if(equali(said,"bank_help"))
			{
				bank_help(id)
				return PLUGIN_HANDLED
			}
			if(equali(said,"bank_open"))
			{
				client_cmd(id,"bank_open 1")
				return PLUGIN_HANDLED
			}
			if(equali(said,"bank_close"))
			{
				client_cmd(id,"bank_close 1")
				return PLUGIN_HANDLED
			}					
			if(equali(said,"bmenu"))
			{
				client_cmd(id,"bank_menu")
				return PLUGIN_HANDLED
			}
	}
	return PLUGIN_CONTINUE
}

public giveinterest()
{
	rounds++
	if(!check_use(0,1)) return PLUGIN_CONTINUE
	bankfees = get_cvar_num("bank_fees_base")
	new Float:rate = get_cvar_float("bank_interest_rate")
	new irounds = get_cvar_num("bank_interest_rounds")
	if(!get_cvar_num("bank_state"))
		return PLUGIN_CONTINUE
	for(new i = 1;i<=32;i++)
	{
		if(is_user_connected(i))
		{
			if(canuse)
			{
				interest++
				if(interest >= irounds)
				{
					interest = 0
					new balance = get_balance(i)
					if(balance != -1)
					{
						new Float:give = floatmul(rate,float(balance))
						new givint = floatround(give)
						if(givint > 0)
						{
							new allowed = 16000 - cs_get_user_money(i)
							if(givint <= allowed)
							{
								cs_set_user_money(i,cs_get_user_money(i)+givint)
								ColorChat(i, NORMAL, "^x04[Bank] ^x01You were given $%d in interest.",givint)
							}
							else
							{
								new dep = givint - allowed
								ColorChat(i, NORMAL, "^x04[Bank] ^x01You were given $%d in interest $%d of which went into your account.",givint,dep)
								cs_set_user_money(i,16000)
								balance += dep
								set_balance(i,balance)
							}
						}
					}
				}
			}
		}
	}
	return PLUGIN_CONTINUE
}

public client_putinserver(id)
{
	interest[id] = 0
	canuse[id] = false
	switch(get_cvar_num("bank_restrict"))
	{
		case 0:
		{
			canuse[id] = true
		}
		case 1:
		{
			if(access(id,ADMIN_CHAT))
				canuse[id] = true
			else
				canuse[id] = false
		}
		case 2:
		{
			canuse[id] = false
			new sid[35]
			if(get_cvar_num("bank_use_ip"))
				get_user_ip(id,sid,34,1)
			else
				get_user_authid(id,sid,34)
			#if SQLON	
				result = dbi_query(dbc,"SELECT * FROM bankusers WHERE sid = '%s'",sid)
				if(result == RESULT_NONE)
					canuse[id] = false
				else
					canuse[id] = true
				dbi_free_result(result)
			#else
				new retstr[35],a,i
				while(read_file(allowfilepath,i,retstr,34,a))
				{
					if(equali(sid,retstr))
						canuse[id] = true
					i++
				}
			#endif
		}
	}
}	

public client_disconnect(id)
{
	canuse[id] = false
	interest[id] = 0
}

public deposit_maximum(id)	
{
	if(!check_use(id,1)) return PLUGIN_HANDLED	
	new curmoney = cs_get_user_money(id)
	new balance = get_balance(id)
	if(balance == -1)
	{
		ColorChat(id, NORMAL, "^x04[Bank] ^x01You do not have a bank account.")
		return PLUGIN_HANDLED	
	}
	balance += curmoney
	set_balance(id,balance)
	cs_set_user_money(id,0)
	ColorChat(id, NORMAL, "^x04[Bank] ^x01You have deposited $%d in your bank account. You now have $%d in your account.",curmoney,balance)
	return PLUGIN_HANDLED
}

public withdrawl_maximum(id)
{
	if(!check_use(id,1)) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		ColorChat(id, NORMAL, "^x04[Bank] ^x01You do not have a bank account.")
		return PLUGIN_HANDLED
	}
	new curmoney = cs_get_user_money(id)
	new maxmoney = 16000 - cs_get_user_money(id)
	if(maxmoney > balance)
		maxmoney = balance
	balance -= maxmoney
	cs_set_user_money(id,curmoney + maxmoney,1)
	if((balance - bankfees) > 0)
		balance -= bankfees
	else
		cs_set_user_money(id,cs_get_user_money(id) - bankfees)
	if(bankfees > 0)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01You paid $%d in bank fees.",bankfees)
	bankfees += get_cvar_num("bank_fees_increase")		
	set_balance(id,balance)
	ColorChat(id, NORMAL, "^x04[Bank] ^x01You have withdrawn $%d from your bank account. You now have $%d in your account.",maxmoney,balance)
	return PLUGIN_HANDLED
}
	
public bank_amount(id)
{
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You do not have a bank account.")
		else
			console_print(id,"You do not have a bank account.")
		return PLUGIN_HANDLED		
	}
	else
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You have $%d in your bank account.",balance)
		else
			console_print(id,"You have $%d in your bank account.",balance)
	}
	return PLUGIN_HANDLED
}

public bank_open(id,level,cid)
{
	if(!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(get_cvar_num("bank_state"))
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01The AMX bank is already open.")
		else
			console_print(id,"The AMX bank is already open.")
	}
	else
	{
		console_cmd(id,"amx_cvar bank_state 1")
		if(get_cvar_num("bank_state"))
		{
			if(client)
				ColorChat(id, NORMAL, "^x04[Bank] ^x01The bank is now open.")
			else
				console_print(id,"The bank is now open.")
			ColorChat(id, NORMAL, "^x04[Bank] ^x01The bank is now open for business.")
		}		
		else
		{
			if(client)
				ColorChat(id, NORMAL, "^x04[Bank] ^x01You may not open the bank.")
			else
				console_print(id,"You may not open the bank.")
		}	
	}
	return PLUGIN_HANDLED
}

public bank_close(id,level,cid)
{	
	if(!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	new client = 0 
	if(read_argc() > 1)
		client = 1
	if(!get_cvar_num("bank_state"))
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01The AMX bank is already closed.")
		else
			console_print(id,"The AMX bank is already closed.")
	}
	else
	{
		console_cmd(id,"amx_cvar bank_state 0")
		if(!get_cvar_num("bank_state"))
		{
			if(client)
				ColorChat(id, NORMAL, "^x04[Bank] ^x01The bank is now closed.")
			else
				console_print(id,"The bank is now closed.")
			ColorChat(id, NORMAL, "^x04[Bank] ^x01The bank is now closed.")
		}		
		else
		{
			if(client)
				ColorChat(id, NORMAL, "^x04[Bank] ^x01You may not close the bank.")
			else
				console_print(id,"You may not close the bank.")
		}	
	}
	return PLUGIN_HANDLED
}

public sqlinit()
{
	#if SQLON
		new error[32],sqlhostname[35],sqluser[35],sqlpass[35],sqldbname[35]
		get_cvar_string("amx_sql_host",sqlhostname,34)
		get_cvar_string("amx_sql_user",sqluser,34)
		get_cvar_string("amx_sql_pass",sqlpass,34)
		get_cvar_string("amx_sql_db",sqldbname,34)
		dbc = dbi_connect(sqlhostname,sqluser,sqlpass,sqldbname,error,31)
		if(dbc == SQL_FAILED)
		{
			server_print("Could not connect.")
			return PLUGIN_HANDLED
		}
		result = dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `bank` (`sid` VARCHAR(35), `amount` BIGINT(20))")
		dbi_free_result(result)
		result = dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `bankusers` (`sid` VARCHAR(35), `comments` VARCHAR(100))")
		dbi_free_result(result)
	#endif
	return 1
}

public bank_create(id)
{
	new client = 0
	if(read_argc() > 1)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new curmoney,neededmoney, amount
	neededmoney = get_cvar_num("bank_default_opening")
	curmoney = cs_get_user_money(id)
	if(curmoney >= neededmoney)
	{
		amount = neededmoney
		curmoney -= neededmoney
	}
	else
	{
		amount = curmoney
		curmoney = 0
	}
	#if SQLON
		new sid[35]
		if(get_cvar_num("bank_use_ip"))
			get_user_ip(id,sid,34,1)
		else
			get_user_authid(id,sid,34)
		result = dbi_query(dbc,"SELECT * FROM bank WHERE sid = '%s'",sid)
		if(result != RESULT_NONE)
		{
			if(client)
				ColorChat(id, NORMAL, "^x04[Bank] ^x01You already have a bank account!")
			else
				console_print(id,"You already have a bank account!")
			return PLUGIN_HANDLED
		}
		dbi_free_result(result)
		result = dbi_query(dbc,"INSERT INTO bank VALUES ( '%s' , '%d')",sid,amount)
		dbi_free_result(result)
	#else
		new sid[35],key[51]
		if(get_cvar_num("bank_use_ip"))
			get_user_ip(id,sid,34,1)
		else
			get_user_authid(id,sid,34)
		format(key,50,"%s_account",sid)
		if(vaultdata_exists(key))
		{
			if(client)
				ColorChat(id, NORMAL, "^x04[Bank] ^x01You already have a bank account!")
			else
				console_print(id,"You already have a bank account!")
			return PLUGIN_HANDLED
		}
		new saveamstr[21]
		num_to_str(amount,saveamstr,20)
		set_vaultdata(key,saveamstr)
	#endif			
	cs_set_user_money(id,curmoney)
	if(client)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01Bank account created successfully. Your account has $%d in it.",amount)
	else
		console_print(id,"Bank account created successfully. Your account has $%d in it.",amount)
	return PLUGIN_HANDLED
}

public bank_withdrawl(id)
{
	new client = 0
	if(read_argc() > 2)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You do not have a bank account.")
		else
			console_print(id,"You do not have a bank account.")
		return PLUGIN_HANDLED		
	}
	new ams[9],amn,maxam	
	read_args(ams,8)
	amn = str_to_num(ams)
	if(amn <= 0) return PLUGIN_HANDLED	
	maxam = 16000 - cs_get_user_money(id)
	if(amn > maxam)
		amn = maxam
	if(amn > balance)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01There is not enough money in your bank account.")
		else
			console_print(id,"There is not enough money in your bank account.")
		return PLUGIN_HANDLED
	}
	balance -= amn
	cs_set_user_money(id,cs_get_user_money(id) + amn)
	if(balance >= bankfees)
		balance -= bankfees
	else
		cs_set_user_money(id,cs_get_user_money(id) - bankfees)	
	set_balance(id,balance)
	if(bankfees > 0)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You paid $%d in bank fees.",bankfees)
		else
			console_print(id,"You paid $%d in bank fees.",bankfees)
	}
	bankfees += get_cvar_num("bank_fees_increase")
	if(client)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01You have withdrawn $%d from your bank account. You now have $%d in your account.",amn,balance)
	else
		console_print(id,"You have withdrawn $%d from your bank account. You now have $%d in your account.",amn,balance)
	return PLUGIN_HANDLED
}

public bank_deposit(id)
{
	new client = 0
	if(read_argc() > 2)
		client = 1
	if(!check_use(id,client)) return PLUGIN_HANDLED
	new damounts[9],damount,curmoney
	read_args(damounts,8)
	damount = str_to_num(damounts)
	if(damount <= 0) return PLUGIN_HANDLED
	curmoney = cs_get_user_money(id)
	if(damount > curmoney)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You don't have that much money.")
		else
			console_print(id,"You don't have that much money.")
		return PLUGIN_HANDLED
	}
	new balance = get_balance(id)
	if(balance == -1)
	{
		if(client)
			ColorChat(id, NORMAL, "^x04[Bank] ^x01You do not have a bank account.")
		else
			console_print(id,"You do not have a bank account.")
		return PLUGIN_HANDLED
	}
	balance += damount
	set_balance(id,balance)
	cs_set_user_money(id,curmoney - damount)
	if(client)
		ColorChat(id, NORMAL, "^x04[Bank] ^x01You have deposited $%d in your bank account. You now have $%d in your account.",damount,balance)
	else
		console_print(id,"You have deposited $%d in your bank account. You now have $%d in your account.",damount,balance)
	return PLUGIN_HANDLED
}

ColorChat(id, Color:type, const msg[], {Float, Sql, Result, _}:...) {
	if(!get_playersnum())
		return;
	
	new message[256];

	switch(type) {
		case NORMAL: {
			message[0] = 0x01;
		}
		case GREEN: {
			message[0] = 0x04;
		}
		default: {
			message[0] = 0x03;
		}
	}

	vformat(message[1], 251, msg, 4);

	message[192] = '^0';

	new team, ColorChange, index, MSG_Type;
	
	if(id) {
		MSG_Type = MSG_ONE;
		index = id;
	} else {
		index = FindPlayer();
		MSG_Type = MSG_ALL;
	}
	
	team = get_user_team(index);
	ColorChange = ColorSelection(index, MSG_Type, type);

	ShowColorMessage(index, MSG_Type, message);
		
	if(ColorChange) {
		Team_Info(index, MSG_Type, TeamName[team]);
	}
}

ShowColorMessage(id, type, message[]) {
	static bool:saytext_used;
	static get_user_msgid_saytext;
	if(!saytext_used) {
		get_user_msgid_saytext = get_user_msgid("SayText");
		saytext_used = true;
	}

	message_begin(type, get_user_msgid_saytext, _, id);
	write_byte(id)		
	write_string(message);
	message_end();	
}

Team_Info(id, type, team[]) {
	static bool:teaminfo_used;
	static get_user_msgid_teaminfo;
	if(!teaminfo_used) {
		get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
		teaminfo_used = true;
	}

	message_begin(type, get_user_msgid_teaminfo, _, id);
	write_byte(id);
	write_string(team);
	message_end();

	return 1;
}

ColorSelection(index, type, Color:Type) {
	switch(Type) {
		case RED: {
			return Team_Info(index, type, TeamName[1]);
		}
		case BLUE: {
			return Team_Info(index, type, TeamName[2]);
		}
		case GREY: {
			return Team_Info(index, type, TeamName[0]);
		}
	}

	return 0;
}

FindPlayer() {
	new i = -1;

	while(i <= get_maxplayers()) {
		if(is_user_connected(++i))
			return i;
	}

	return -1;
}
Image
32slots.net - Sursa ta de încredere de KIT-uri CS 1.6
RedFear.Ro România - | Afiseaza codul
Vă aştept cu un Register pe Forum
- Suntem în căutare de Dezvoltatori & Administratori :
HTML
PHP
MYSQL
C++
Ofer Server CS spre administrare | Afiseaza codul
Condiții : 
- Să dispui de timp liber
- Să ai cunoștințe AMXX & HLDS
Boostul este asigurat de către Mine (PM pentru. detalii)
[email protected]
User avatar
tre3fla
Membru eXtream
Membru eXtream
Posts: 5317
Joined: 27 May 2012, 11:15
Detinator Steam: Da
CS Status: Allah Akbar !
Detinator server CS: Nu
SteamID: /id/tre3fla_xxx
Has thanked: 14 times
Been thanked: 129 times

15 Aug 2012, 15:55

Deja incep sa tin la tine :* :)
Edit : Da nu modificasi comenzile :-s... daca poate cineva sa le modfice :|
User avatar
K1d0x
Fost moderator
Fost moderator
Posts: 800
Joined: 26 Feb 2012, 15:57
Detinator Steam: Da
CS Status: We Build Together ;3 RedFear
Detinator server CS: PuB.RedFear.Ro
SteamID: k1dox
Reputatie: Fost moderator ajutator
Location: Reșița
Been thanked: 152 times
Contact:

15 Aug 2012, 15:57

tre3fla wrote:Deja incep sa tin la tine :* :)
Ai grija sa nu incepi sa ma si iubesti \:m/ :O o_O
Image
32slots.net - Sursa ta de încredere de KIT-uri CS 1.6
RedFear.Ro România - | Afiseaza codul
Vă aştept cu un Register pe Forum
- Suntem în căutare de Dezvoltatori & Administratori :
HTML
PHP
MYSQL
C++
Ofer Server CS spre administrare | Afiseaza codul
Condiții : 
- Să dispui de timp liber
- Să ai cunoștințe AMXX & HLDS
Boostul este asigurat de către Mine (PM pentru. detalii)
[email protected]
User avatar
tre3fla
Membru eXtream
Membru eXtream
Posts: 5317
Joined: 27 May 2012, 11:15
Detinator Steam: Da
CS Status: Allah Akbar !
Detinator server CS: Nu
SteamID: /id/tre3fla_xxx
Has thanked: 14 times
Been thanked: 129 times

15 Aug 2012, 15:57

Vezi editu de sus,fereste-te sa te iubesc eu =)))) :)))
User avatar
tweky
Fost moderator
Fost moderator
Posts: 2705
Joined: 22 Jun 2009, 01:54
Detinator Steam: Da
CS Status: Inactiv
Detinator server CS: Da
SteamID: twekymihai
Reputatie: Fost eXtream Mod
Nume anterior: Mihaita
Fost Membru Club eXtreamCS
Location: Ilfov
Has thanked: 126 times
Been thanked: 173 times

15 Aug 2012, 16:45

Mutat in Prima pagină » eXtream - Counter-Strike 1.6 » Pluginuri » Cereri
my website
:hand_over_mouth: :ghosts:

1. vevios.ro

2. minios.ro
User avatar
K1d0x
Fost moderator
Fost moderator
Posts: 800
Joined: 26 Feb 2012, 15:57
Detinator Steam: Da
CS Status: We Build Together ;3 RedFear
Detinator server CS: PuB.RedFear.Ro
SteamID: k1dox
Reputatie: Fost moderator ajutator
Location: Reșița
Been thanked: 152 times
Contact:

15 Aug 2012, 16:47

Pai eu am modificat comenzile din containi si equal nu din register_concmd (comanda de consola)
Image
32slots.net - Sursa ta de încredere de KIT-uri CS 1.6
RedFear.Ro România - | Afiseaza codul
Vă aştept cu un Register pe Forum
- Suntem în căutare de Dezvoltatori & Administratori :
HTML
PHP
MYSQL
C++
Ofer Server CS spre administrare | Afiseaza codul
Condiții : 
- Să dispui de timp liber
- Să ai cunoștințe AMXX & HLDS
Boostul este asigurat de către Mine (PM pentru. detalii)
[email protected]
User avatar
tre3fla
Membru eXtream
Membru eXtream
Posts: 5317
Joined: 27 May 2012, 11:15
Detinator Steam: Da
CS Status: Allah Akbar !
Detinator server CS: Nu
SteamID: /id/tre3fla_xxx
Has thanked: 14 times
Been thanked: 129 times

15 Aug 2012, 16:50

TwEky wrote:Mutat in Prima pagină » eXtream - Counter-Strike 1.6 » Pluginuri » Cereri
Era deja aici,ce ai ?

@k1d0X ok,mersi :)
User avatar
tre3fla
Membru eXtream
Membru eXtream
Posts: 5317
Joined: 27 May 2012, 11:15
Detinator Steam: Da
CS Status: Allah Akbar !
Detinator server CS: Nu
SteamID: /id/tre3fla_xxx
Has thanked: 14 times
Been thanked: 129 times

15 Aug 2012, 17:18

AM incercat sa-l testez pe server dar imi da Bad Load :|,l-am pus ultimul in lista de plugine
Post Reply

Return to “Cereri”

  • Information