Jump to content

[INCOMPLET] Cerere plugin banca


L33T Kr3w

Recommended Posts

Nume : Bancă

Versiune : -

Descriere detaliata : pluginul banca când scriu Depozit să depozitezi suma iar când scri retrage să îți retragă 160000 iar la depozitare să depozitezi toți bani care îi ai , dacă aveți ceva de ex /depozit (suma) si /retragere (suma) ar fi mai faine , PS : multe am găsit pe credite să nu fie credite !

Link to comment
Share on other sites

 

 

Cvar-uri( se adauga in fisierul amxmodx\configs\amxx.cfg ) :

bank_default_opening (default 1000; in $) - Cantitatea minima de credit pentru deschiderea unui cont
-bank_state (default 1; 0|1) - Cu aceasta comanda activitati / dezactivati banca
-bank_min_players (default 2) - Nr minim de playeri pentru a accesa banca
-bank_interest_rate (default 0.01) - Procentul de bani nerambursabili la fiecare folosinta a contului
-bank_fees_increase (default 0; in $) - Cresterea taxei pe fiecare tranzactie
-bank_msg (default "This server is using AMX Bank. Type bank_help in console to find out how to use it.") - Mesajul catre jucatori in legatura cu sistemul de banking
-bank_msg_interval (default 60) - La cate secunde msajul sa apara
-bank_use_ip (default 0; 0|1) - Sistemul sa foloseasca sau nu IP-ul , default este STEAM ID Numeric
#define SQLON 0 // 1 = Use SQL | 0 = Use file

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

new HELPPAGE[] = "http://rangfort.ro/forum"

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[i])
			{
				interest[i]++
				if(interest[i] >= irounds)
				{
					interest[i] = 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
} 

 

 

  • Like 1
Link to comment
Share on other sites

  • 2 months later...


Descriere: Acesta este un plugin de credite pentru modul furien.

Deasemenea poate fi folosit si in alte moduri.

In ce consta acest plugin? Ei bine, cand ai 16000$, prin simpla comanda, /deposit, iti transformi banii in 1 credit.

Nu exista limita de credite.

Creditele se salveaza pe nume.

 

Plugin-ul are si native, cu care poti afla/modifica creditele unui jucator, din alte plugine.

 

 

Descarcare:

Furien Credits System 1.4.6 | Ascunde codul#include < amxmodx >

#include < amxmisc >

#include < cstrike >

#include < fakemeta >

#include < hamsandwich >

#include < nvault >

//#include < CC_ColorChat >

 

#pragma semicolon 1

 

 

#define PLUGIN "Furien Credits System"

#define VERSION "1.4.6" // Sper sa nu mai fie buguri.

 

#define    ONE_DAY_IN_SECONDS    86400

 

// |-- CC_ColorChat --|

 

enum Color

{

    NORMAL = 1,         // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.

    GREEN,             // Culoare Verde.

    TEAM_COLOR,         // Culoare Rosu, Albastru, Gri.

    GREY,             // Culoarea Gri.

    RED,             // Culoarea Rosu.

    BLUE,             // Culoarea Albastru.

};

 

new TeamName[ ][ ] =

{

    "",

    "TERRORIST",

    "CT",

    "SPECTATOR"

};

 

// |-- CC_ColorChat --|

 

new const g_szTag[ ] = "[Furien Credits]";

 

new const g_szGiveCreditsFlag[ ] = "a";

 

new g_szName[ 33 ][ 32 ];

new g_iUserCredits[ 33 ];

new g_iUserRetired[ 33 ];

 

new g_iCvarPruneDays;

new g_iCvarEntry;

new g_iCvarRetire;

new iVault;

 

public plugin_init( )

{

    register_plugin( PLUGIN, VERSION, "Askhanar" );

    register_cvar( "fcs_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );

 

    g_iCvarPruneDays = register_cvar( "fcs_prunedays", "15" );

    g_iCvarEntry = register_cvar( "fcs_entry_credits", "300" );

    g_iCvarRetire = register_cvar( "fcs_maxretrieve", "0" );

    

    register_clcmd( "say", "ClCmdSay" );

    register_clcmd( "say_team", "ClCmdSay" );

    

    register_clcmd( "say /depozit", "ClCmdSayDepozit" );

    register_clcmd( "say /deposit", "ClCmdSayDepozit" );

    register_clcmd( "say_team /depozit", "ClCmdSayDepozit" );

    register_clcmd( "say_team /deposit", "ClCmdSayDepozit" );

    

    register_clcmd( "say /retrage", "ClCmdSayRetrage" );

    register_clcmd( "say /withdraw", "ClCmdSayRetrage" );

    register_clcmd( "say_team /retrage", "ClCmdSayRetrage" );

    register_clcmd( "say_team /withdraw", "ClCmdSayRetrage" );

    

    register_clcmd( "fcs_credite", "ClCmdCredits" );

    register_clcmd( "fcs_credits", "ClCmdCredits" );

    

    register_clcmd( "amx_give_credits", "ClCmdGiveCredits" );

    register_clcmd( "amx_take_credits", "ClCmdTakeCredits" );

    

    RegisterHam( Ham_Spawn, "player", "ham_SpawnPlayerPost", true );

    register_forward( FM_ClientUserInfoChanged, "Fwd_ClientUserInfoChanged" );

 

}

 

public plugin_natives()

{

    

    register_library( "fcs" );

    register_native( "fcs_get_user_credits", "_fcs_get_user_credits" );

    register_native( "fcs_set_user_credits", "_fcs_set_user_credits" );

    

}

 

public _fcs_get_user_credits( iPlugin, iParams )

{

    return g_iUserCredits[ get_param( 1 ) ];

}

 

public _fcs_set_user_credits( iPlugin, iParams )

{

    new id = get_param( 1 );

    g_iUserCredits[ id ] = max( 0, get_param( 2 ) );

    SaveCredits( id );

    return g_iUserCredits[ id ];

}

 

public client_authorized( id )

{

    if( is_user_bot( id ) )

        return PLUGIN_CONTINUE;

    

    g_iUserRetired[ id ] = 0;

    get_user_name( id, g_szName[ id ], sizeof ( g_szName[] ) -1 );

    LoadCredits( id );

    

    return PLUGIN_CONTINUE;

    

}

 

public client_disconnect( id )

{

    if( is_user_bot( id ) )

        return PLUGIN_CONTINUE;

        

    g_iUserRetired[ id ] = 0;

    SaveCredits( id );

    

    return PLUGIN_CONTINUE;

    

}

 

public ClCmdSay( id )

{

    static szArgs[192];

    read_args( szArgs, sizeof ( szArgs ) -1 );

    

    if( !szArgs[ 0 ] )

        return PLUGIN_CONTINUE;

    

    new szCommand[ 15 ];

    remove_quotes( szArgs );

    

    if( equal( szArgs, "/credite", strlen( "/credite" ) )

        || equal( szArgs, "/credits", strlen( "/credits" ) ) )

    {

        replace( szArgs, sizeof ( szArgs ) -1, "/", "" );

        formatex( szCommand, sizeof ( szCommand ) -1, "fcs_%s", szArgs );

        client_cmd( id, szCommand );

        return PLUGIN_HANDLED;

    }

    

    return PLUGIN_CONTINUE;

}

 

public ClCmdCredits( id )

{

    if( !is_user_connected( id ) )

        return PLUGIN_HANDLED;

        

    new szArg[ 32 ];

    read_argv( 1, szArg, sizeof ( szArg ) -1 );

 

    if( equal( szArg, "" ) )

    {

        

        ColorChat( id, RED, "^x04%s^x01 Ai^x03 %i^x01 credite.", g_szTag, g_iUserCredits[ id ] );

        return PLUGIN_HANDLED;

    }

    

    new iPlayer = cmd_target( id, szArg, 8 );

    if( !iPlayer || !is_user_connected( iPlayer ) )

    {

        ColorChat( id, RED,"^x04%s^x01 Jucatorul specificat nu a fost gasit!", g_szTag, szArg );

        return PLUGIN_HANDLED;

    }

 

    new szName[ 32 ];

    get_user_name( iPlayer, szName, sizeof ( szName ) -1 );

    ColorChat( id, RED,"^x04%s^x01 Jucatorul^x03 %s^x01 are^x03 %i^x01 credit%s", g_szTag, szName, g_iUserCredits[ iPlayer ], g_iUserCredits[ iPlayer ] == 1 ? "." : "e." );

    

    return PLUGIN_HANDLED;

    

}

 

public ClCmdSayDepozit( id)

{

    

    if( !is_user_connected( id ) )

        return PLUGIN_HANDLED;

        

    new CsTeams:iTeam = cs_get_user_team( id );

    

    if( CS_TEAM_T <= iTeam <= CS_TEAM_CT )

    {

        new iMoney = cs_get_user_money( id );

        if( iMoney >= 16000 )

        {

            

            ColorChat( id, RED, "^x04%s^x01 Ai depozitat^x03 16000$^x01 si ai primit^x03 1^x01 credit.", g_szTag );

            cs_set_user_money( id, 0 );

            g_iUserCredits[ id ] += 1;

            

            SaveCredits( id );

            return PLUGIN_HANDLED;

        }

        else

        {

            ColorChat( id, RED, "^x04%s^x01 Iti trebuie^x03 16000$^x01 pentru a putea depozita.", g_szTag );

            return PLUGIN_HANDLED;

        }

    }

    

    return PLUGIN_HANDLED;

 

}

 

public ClCmdSayRetrage( id)

{

    

    new CsTeams:iTeam = cs_get_user_team( id );

    

    if( CS_TEAM_T <= iTeam <= CS_TEAM_CT )

    {

        

        if( g_iUserCredits[ id ] > 0 )

        {

            new iMaxRetrieve = get_pcvar_num( g_iCvarRetire );

            if( iMaxRetrieve > 0 )

            {

                if( g_iUserRetired[ id ] >= iMaxRetrieve )

                {

                    ColorChat( id, RED, "^x04%s^x01 Ai retras deja^x03 %i^x01 credit%s runda asta^x01.", g_szTag, iMaxRetrieve, iMaxRetrieve == 1 ? "" : "e" );

                    return PLUGIN_HANDLED;

                }

            }

            

            new iMoney = cs_get_user_money( id );

            

            ColorChat( id, RED, "^x04%s^x01 Ai retras^x03 1^x01 credit si, ai primi^x03 16000$^x01.", g_szTag );

            cs_set_user_money( id, iMoney + 16000 );

            

            g_iUserCredits[ id ] -=1;

            g_iUserRetired[ id ]++;

            

            SaveCredits( id );

            

            if( ( iMoney + 16000 ) > 16000 )

            {

                ColorChat( id, RED, "^x04%s^x03 ATENTIE^x01, ai^x03 %i$^x01 !", g_szTag, iMoney + 16000 );

                ColorChat( id, RED, "^x04%s^x01 La spawn, vei pierde tot ce depaseste suma de^x03 16000$^x01.", g_szTag );

                return PLUGIN_HANDLED;

            }

        }

        else

        {

            ColorChat(id, RED, "^x04%s^x03 NU^x01 ai ce sa retragi, ai^x03 0^x01 credite.", g_szTag );

            return PLUGIN_HANDLED;

        }

        

    }

    

    return PLUGIN_HANDLED;

 

}

 

public ClCmdGiveCredits( id )

{

    

    if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )

    {

        client_cmd( id, "echo NU ai acces la aceasta comanda!" );

        return PLUGIN_HANDLED;

    }

    

    new szFirstArg[ 32 ], szSecondArg[ 10 ];

    

    read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );

    read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );

    

    if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) )

    {

        client_cmd( id, "echo amx_give_credits < nume/ @ALL/ @T/ @CT > < credite >" );

        return PLUGIN_HANDLED;

    }

    

    new iPlayers[ 32 ];

    new iPlayersNum;

    

    new iCredits = str_to_num( szSecondArg );

    if( iCredits <= 0 )

    {

        client_cmd( id, "echo Valoare creditelor trebuie sa fie mai mare decat 0!" );

        return PLUGIN_HANDLED;

    }

    

    if( szFirstArg[ 0 ] == '@' )

    {

        

        switch ( szFirstArg[ 1 ] )

        {

            case 'A':

            {

                if( equal( szFirstArg, "@ALL" ) )

                {

                    

                    get_players( iPlayers, iPlayersNum, "ch" );

                    for( new i = 0; i < iPlayersNum ; i++ )

                        g_iUserCredits[ iPlayers[ i ] ] += iCredits;

                        

                    new szName[ 32 ];

                    get_user_name( id, szName, sizeof ( szName ) -1 );

                    ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite tuturor jucatorilor!", g_szTag, szName, iCredits );

                    return PLUGIN_HANDLED;

                }

            }

            

            case 'T':

            {

                if( equal( szFirstArg, "@T" ) )

                {

                    

                    get_players( iPlayers, iPlayersNum, "ceh", "TERRORIST" );

                    if( iPlayersNum == 0 )

                    {

                        client_cmd( id, "echo NU se afla niciun jucator in aceasta echipa!" );

                        return PLUGIN_HANDLED;

                    }

                    for( new i = 0; i < iPlayersNum ; i++ )

                        g_iUserCredits[ iPlayers[ i ] ] += iCredits;

                        

                    new szName[ 32 ];

                    get_user_name( id, szName, sizeof ( szName ) -1 );

                    ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 TERO^x01!", g_szTag, szName, iCredits );

                    return PLUGIN_HANDLED;

                }

            }

            

            case 'C':

            {

                if( equal( szFirstArg, "@CT" ) )

                {

                    

                    get_players( iPlayers, iPlayersNum, "ceh", "CT" );

                    if( iPlayersNum == 0 )

                    {

                        client_cmd( id, "echo NU se afla niciun jucator in aceasta echipa!" );

                        return PLUGIN_HANDLED;

                    }

                    for( new i = 0; i < iPlayersNum ; i++ )

                        g_iUserCredits[ iPlayers[ i ] ] += iCredits;

                        

                    new szName[ 32 ];

                    get_user_name( id, szName, sizeof ( szName ) -1 );

                    ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 CT^x01!", g_szTag, szName, iCredits );

                    return PLUGIN_HANDLED;

                }

            }

        }

    }

        

    new iPlayer = cmd_target( id, szFirstArg, 8 );

    if( !iPlayer )

    {

        client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );

        return PLUGIN_HANDLED;

    }

    

    g_iUserCredits[ iPlayer ] += iCredits;

    

    new szName[ 32 ], _szName[ 32 ];

    get_user_name( id, szName, sizeof ( szName ) -1 );

    get_user_name( iPlayer, _szName, sizeof ( _szName ) -1 );

    

    ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a dat^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );

    

    return PLUGIN_HANDLED;

    

    

}

 

public ClCmdTakeCredits( id )

{

    

    if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )

    {

        client_cmd( id, "echo NU ai acces la aceasta comanda!" );

        return PLUGIN_HANDLED;

    }

    

    new szFirstArg[ 32 ], szSecondArg[ 10 ];

    

    read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );

    read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );

    

    if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) )

    {

        client_cmd( id, "echo amx_take_credits < nume > < credite >" );

        return PLUGIN_HANDLED;

    }

    

    new iCredits = str_to_num( szSecondArg );

    if( iCredits <= 0 )

    {

        client_cmd( id, "echo Valoarea creditelor trebuie sa fie mai mare decat 0!" );

        return PLUGIN_HANDLED;

    }

            

    new iPlayer = cmd_target( id, szFirstArg, 8 );

    if( !iPlayer )

    {

        client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );

        return PLUGIN_HANDLED;

    }

    

    if( g_iUserCredits[ iPlayer ] < iCredits )

    {

        client_cmd( id, "echo Jucatorul %s nu are atatea credite!Are doar %i", szFirstArg, g_iUserCredits[ iPlayer ] );

        return PLUGIN_HANDLED;

    }

    

    g_iUserCredits[ iPlayer ] -= iCredits;

    

    new szName[ 32 ], _szName[ 32 ];

    get_user_name( id, szName, sizeof ( szName ) -1 );

    get_user_name( iPlayer, _szName, sizeof ( _szName ) -1 );

    

    ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a sters^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );

    

    return PLUGIN_HANDLED;

    

    

}

 

public ham_SpawnPlayerPost( id )

{

    if( !is_user_alive( id ) )

        return;

        

    g_iUserRetired[ id ] = 0;

}

 

public Fwd_ClientUserInfoChanged( id, szBuffer )

{

    if ( !is_user_connected( id ) )

        return FMRES_IGNORED;

    

    static szNewName[ 32 ];

    

    engfunc( EngFunc_InfoKeyValue, szBuffer, "name", szNewName, sizeof ( szNewName ) -1 );

    

    if ( equal( szNewName, g_szName[ id ] ) )

        return FMRES_IGNORED;

    

    SaveCredits( id );

    

    ColorChat( id, RED, "^x04%s^x01 Tocmai ti-ai schimbat numele din^x03 %s^x01 in^x03 %s^x01 !", g_szTag, g_szName[ id ], szNewName );

    ColorChat( id, RED, "^x04%s^x01 Am salvat^x03 %i^x01 credite pe numele^x03 %s^x01 !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );

    

    copy( g_szName[ id ], sizeof ( g_szName[] ) -1, szNewName );

    LoadCredits( id );

    

    ColorChat( id, RED, "^x04%s^x01 Am incarcat^x03 %i^x01 credite de pe noul nume (^x03 %s^x01 ) !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );

    

    return FMRES_IGNORED;

}

 

 

public LoadCredits( id )

{

    iVault = nvault_open( "FurienCreditsSystem" );

    

    if( iVault == INVALID_HANDLE )

    {

        set_fail_state( "nValut returned invalid handle!" );

    }

    

    static szData[ 256 ], iTimestamp;

    

    if( nvault_lookup( iVault, g_szName[ id ], szData, sizeof ( szData ) -1, iTimestamp ) )

    {

        static szCredits[ 15 ];

        parse( szData, szCredits, sizeof ( szCredits ) -1 );

        g_iUserCredits[ id ] = str_to_num( szCredits );

        return;

    }

    else

    {

        g_iUserCredits[ id ] = get_pcvar_num( g_iCvarEntry );

    }

    

    nvault_close( iVault );

    

}

 

 

public SaveCredits( id )

{

    iVault = nvault_open( "FurienCreditsSystem" );

    

    if( iVault == INVALID_HANDLE )

    {

        set_fail_state( "nValut returned invalid handle!" );

    }

    

    static szData[ 256 ];

    formatex( szData, sizeof ( szData ) -1, "%i", g_iUserCredits[ id ] );

    

    nvault_set( iVault, g_szName[ id ], szData );

    nvault_close( iVault );

}

 

public plugin_end( )

{

    iVault = nvault_open( "FurienCreditsSystem" );

    

    if( iVault == INVALID_HANDLE )

    {

        set_fail_state( "nValut returned invalid handle!" );

    }

    

    new iDays = get_pcvar_num( g_iCvarPruneDays );

    if( iDays > 0 )

    {

        nvault_prune( iVault, 0, get_systime( ) - ( iDays * ONE_DAY_IN_SECONDS ) );

    }

    

    nvault_close( iVault );

}

 

// |-- CC_ColorChat --|

 

ColorChat( id, Color:iType, const msg[ ], { Float, Sql, Result, _}:... )

{

    

    // Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..

    if( !get_playersnum( ) ) return;

    

    new szMessage[ 256 ];

 

    switch( iType )

    {

         // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.

        case NORMAL:    szMessage[ 0 ] = 0x01;

        

        // Culoare Verde.

        case GREEN:    szMessage[ 0 ] = 0x04;

        

        // Alb, Rosu, Albastru.

        default:     szMessage[ 0 ] = 0x03;

    }

 

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

 

    // Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.

    szMessage[ 192 ] = '^0';

    

 

    new iTeam, iColorChange, iPlayerIndex, MSG_Type;

    

    if( id )

    {

        MSG_Type = MSG_ONE_UNRELIABLE;

        iPlayerIndex = id;

    }

    else

    {

        iPlayerIndex = CC_FindPlayer( );

        MSG_Type = MSG_ALL;

    }

    

    iTeam = get_user_team( iPlayerIndex );

    iColorChange = CC_ColorSelection( iPlayerIndex, MSG_Type, iType);

 

    CC_ShowColorMessage( iPlayerIndex, MSG_Type, szMessage );

        

    if( iColorChange )    CC_Team_Info( iPlayerIndex, MSG_Type, TeamName[ iTeam ] );

 

}

 

CC_ShowColorMessage( id, const iType, const szMessage[ ] )

{

    

    static bool:bSayTextUsed;

    static iMsgSayText;

    

    if( !bSayTextUsed )

    {

        iMsgSayText = get_user_msgid( "SayText" );

        bSayTextUsed = true;

    }

    

    message_begin( iType, iMsgSayText, _, id );

    write_byte( id );        

    write_string( szMessage );

    message_end( );

}

 

CC_Team_Info( id, const iType, const szTeam[ ] )

{

    static bool:bTeamInfoUsed;

    static iMsgTeamInfo;

    if( !bTeamInfoUsed )

    {

        iMsgTeamInfo = get_user_msgid( "TeamInfo" );

        bTeamInfoUsed = true;

    }

    

    message_begin( iType, iMsgTeamInfo, _, id );

    write_byte( id );

    write_string( szTeam );

    message_end( );

 

    return PLUGIN_HANDLED;

}

 

CC_ColorSelection( id, const iType, Color:iColorType)

{

    switch( iColorType )

    {

        

        case RED:    return CC_Team_Info( id, iType, TeamName[ 1 ] );

        case BLUE:    return CC_Team_Info( id, iType, TeamName[ 2 ] );

        case GREY:    return CC_Team_Info( id, iType, TeamName[ 0 ] );

 

    }

 

    return PLUGIN_CONTINUE;

}

 

CC_FindPlayer( )

{

    new iMaxPlayers = get_maxplayers( );

    

    for( new i = 1; i <= iMaxPlayers; i++ )

        if( is_user_connected( i ) )

            return i;

    

    return -1;

}

 

// |-- CC_ColorChat --|

 

Nume: Furien Credits System

Versiune: v0.4.6

Link oficial: http://www.extreamcs.com/forum

 

Instalare:

1. Fisierul FurienCreditsSystem.sma il puneti in addons/amxmodx/scripting

2. Fisierul FurienCreditsSystem.amxx il puneti in addons/amxmodx/plugins

3. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati la urma:

Code:

FurienCreditsSystem.amxx

4. Alti pasi necesari....

 

Modificati in fisierul sursa:

Code:

new const g_szGiveCreditsFlag[ ] = "a";

 

in loc de "a" puneti flagul pentru comenzize de mai jos.

 

NEW!

Cvar-uri (se adauga in fisierul amxmodx\configs\amxx.cfg):

fcs_prunedays "15" - sterge toate inregistrarile din nvault care nu au intrat pe server de x zile ( la fiecare sfarsit de mapa ) | setati valoarea 0 pentru a dezactiva functia.

NEW!fcs_entry_credits "300" - cate credite primesc cand intra pentru prima data pe server.

NEW! [ 20.03.2014 ]fcs_maxretrieve "0" - nr maxim de credite pe care il pot retrage intr-o runda. ( 0 fara limita de retragere )

 

 

Comenzi administrative (se tasteaza in consola si trebuie sa fiti administrator):

amx_give_credits < nume/ @ALL/ @CT/ @T > < credite > - dai credite cuiva.

amx_take_credits < nume > - ii stergi din credite cuiva.

 

Comenzi publice (se tasteaza in joc prin apasarea tastei Y):/credits - aflii cate credite ai

/credits < nume > - aflii cate credite are jucatorul respectiv

/deposit sau /depozit - depozitezi 16000$ si primesti un credit

/retrage sau /withdraw - retragi un credit si premesti 16000$

 

Module necesare (se sterge ; din fata modulului de mai jos; acestea le gasiti in fisierul amxmodx\configs\modules.ini):

- cstrike

- fakemeta

- nvault

Link to comment
Share on other sites

  • 2 weeks later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...