Jump to content

Sp1dey

Manager Server
  • Posts

    934
  • Joined

  • Last visited

Posts posted by Sp1dey

  1. Cand vei activa pe ts si vei cauta un Adm/S-M se va rezolva.

     

    Topic Inchis.

     

    #Edit

     

    Access pe TS la MIX nu ai dreptul sa ai , acolo se ocupa doar Mavrk si / sau Administratorii serverului , nimeni altcineva nu are dreptu sa primeasca grade pe canalele serverelor detinute de alte persoane in comunitate.

  2. RO: Canal Creat. Contacteaza un Administrator sau un Super-Moderator pe TS3, pentru ati adauga accesul. 

    Topic Inchis.

     

    EN: Created Canal. Contact an Administrator or Super Moderator TS3 to add your access.

    Locked topic.
    • Like 2
  3.  

     

    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
  4. Idem Bach

     

    Dreptate,face lag.

    Un singur raspuns era de ajuns. Avertizment verbal pentru amandoi Motiv: Post Hunt. Presupun ca voi doi nici nu l-ati testat de zice-ti ca face lag.

    • Like 1
  5. Topic Inchis, mai bine recunosteai din prima, ca stii cum se spune: "Lupu isi schimba paru/blana, dar naravu nu(ba)". In cazul tau, trebuiai sa recunosti ca nu sunt ale tale, ca ne-am dat toti seama. R.I.P

  6. Sper ca se intelege tot din titlu smile.png.

    NU EXISTA RECLAMA! NU ESTE NIMIC DE PE LUCRARI ONLINE SAU ACTIV!

     

    Avatare:

          

               

    Semnaturi:

      

       

     NkuIhS6.gif

     

    WebDesign: 

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Sp7qcz7.png

     

     

     

     

     

     

     

     

     

    @Edit:

    Primul avatar facut pe anul 2016 dupa 1 an jumate fara lucrari -> 

     

     

    + Un template nou ->

     

    Sa nu mai vad design de genu asta, next ai iara warn.

×
×
  • Create New...