Kod:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <nvault>
#include <fun>
#define PLUGIN "Money Banka Plugini"
#define VERSION "1.1"
#define AUTHOR "byetovice & Optimist"
new anavault;
new username[33][200]
new password[33][200]
new g_username[33][200]
new g_password[33][200]
new k_username[33][200]
new k_password[33][200]
new g_IslemUcreti
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
anavault = nvault_open("Banka")
register_clcmd("Hesap_Ismi","Giris_ID")
register_clcmd("Hesap_Ismi_Secin","Kayit_ID")
register_clcmd("Vereceginiz_Miktar","Para_Yatir")
register_clcmd("Alacaginiz_Miktar","Para_Cek")
register_clcmd("Sifreniz","Giris_Pw")
register_clcmd("Sifre_Secin","Kayit_Pw")
register_clcmd("say /banka","login_menusu")
g_IslemUcreti = register_cvar("banka_islem_ucreti","0")
set_task(60.0,"tanit_beni",3476,"",0,"b")
}
public client_connect(id)
{
copy(username[id],199,"")
copy(password[id],199,"")
copy(g_username[id],199,"")
copy(g_password[id],199,"")
copy(k_username[id],199,"")
copy(k_password[id],199,"")
}
public client_disconnect(id)
{
copy(username[id],199,"")
copy(password[id],199,"")
copy(g_username[id],199,"")
copy(g_password[id],199,"")
copy(k_username[id],199,"")
copy(k_password[id],199,"")
}
public login_menusu(id)
{
if(!is_user_connected(id) || !is_user_alive(id)) return PLUGIN_HANDLED
new banka_ismi[128],map_name[128]
get_mapname(map_name,127)
replace_all(map_name,127,"zm_","")
formatex(banka_ismi,127,"\r%s \wSehir Bankasi",map_name)
new menu = menu_create(banka_ismi,"login_devam")
if(equal(username[id],""))
{
menu_additem(menu,"Giris Yap","1",0)
menu_additem(menu,"Kayit Ol","2",0)
}
else
{
menu_additem(menu,"Para Yatir","3",0)
menu_additem(menu,"Para Cek","4",0)
menu_additem(menu,"Hesap Durumu","5",0)
menu_additem(menu,"Cikis Yap","6",0)
}
if(get_user_flags(id) & ADMIN_BAN) // Userlerin Bankasına Bakma Yetkısı
{
menu_additem(menu,"Oyuncularin Hesaplarina Bak","7",ADMIN_BAN) // Userlerin Bankasına Bakma Yetkısı
}
menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
menu_display(id,menu,0)
return PLUGIN_HANDLED
}
public login_devam(id,menu,item)
{
if(!is_user_connected(id) || !is_user_alive(id)) return PLUGIN_HANDLED
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new acces,data2[24],iname[64],callback,data
menu_item_getinfo(menu,item,acces,data2,23,iname,63,callback)
data = str_to_num(data2)
switch(data)
{
case 1:
{
client_cmd(id,"messagemode Hesap_Ismi")
}
case 2:
{
client_cmd(id,"messagemode Hesap_Ismi_Secin")
}
case 3:
{
client_cmd(id,"messagemode Vereceginiz_Miktar")
}
case 4:
{
client_cmd(id,"messagemode Alacaginiz_Miktar")
}
case 5:
{
copy(username[id],199,"")
copy(password[id],199,"")
client_print(id,print_center,"Cikis yaptiniz..")
}
case 6:
{
set_hudmessage(255, 255, 255, 0.29, 0.30, 0, 6.0, 5.0,_,_,-1)
show_hudmessage(id, "Hesabinizdaki Para Miktari : ^n %d $",get_hesap_Money(username[id]))
}
case 7:
{
if((get_user_flags(id) & ADMIN_BAN))
{
new message[899],len;
len = formatex(message,898,"<body bgcolor=black><b>");
for(new i = 1; i < 33; i++)
{
if(is_user_connected(i))
{
new iName[64]
get_user_name(i,iName,63)
if(!equal(username[i],""))
{
len += formatex(message[len],898-len,"<font color=red>%s</font><font color=white> (Uzerinde %d Para) - Hesap Adi= %s Hesapta= %d Para</font>",iName,cs_get_user_money(i),username[i],get_hesap_Money(username[i]));
}
else
{
len += formatex(message[len],898-len,"<font color=red>%s</font><font color=white> (Uzerinde %d Para) - Hesabi Yok",iName,cs_get_user_money(i));
}
}
}
show_motd(id,message," - Admin Takip Paneli - ");
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public Giris_ID(id)
{
new say[300]
read_args(say, charsmax(say))
remove_quotes(say)
if(equal(say, "") || !equal(username[id],"") || strlen(say) > 12)
{
copy(g_username[id],199,"")
copy(g_password[id],199,"")
copy(k_username[id],199,"")
copy(k_password[id],199,"")
return PLUGIN_HANDLED
}
copy(g_password[id],199,"")
copy(k_username[id],199,"")
copy(k_password[id],199,"")
copy(g_username[id],199,say)
client_cmd(id,"messagemode Sifreniz")
return PLUGIN_CONTINUE
}
public Giris_Pw(id)
{
new say[300]
read_args(say, charsmax(say))
remove_quotes(say)
if(equal(say, "") || !equal(username[id],"") || equal(g_username[id],"") || strlen(say) > 12)
{
copy(g_username[id],199,"")
copy(g_password[id],199,"")
copy(k_username[id],199,"")
copy(k_password[id],199,"")
return PLUGIN_HANDLED
}
copy(g_password[id],199,say)
giris_yap(id,g_username[id], g_password[id])
copy(g_password[id],199,"")
copy(g_username[id],199,"")
copy(k_password[id],199,"")
copy(k_username[id],199,"")
return PLUGIN_CONTINUE
}
/////////////////////////
////#Kayit Islemleri#////
/////////////////////////
public Kayit_ID(id)
{
new say[300]
read_args(say, charsmax(say))
remove_quotes(say)
if(equal(say, "") || !equal(username[id],"") || strlen(say) > 12)
{
copy(g_username[id],199,"")
copy(g_password[id],199,"")
copy(k_username[id],199,"")
copy(k_password[id],199,"")
return PLUGIN_HANDLED
}
copy(k_password[id],199,"")
copy(g_username[id],199,"")
copy(g_password[id],199,"")
copy(k_username[id],199,say)
client_cmd(id,"messagemode Sifre_Secin")
return PLUGIN_CONTINUE
}
public Kayit_Pw(id)
{
new say[300]
read_args(say, charsmax(say))
remove_quotes(say)
if(equal(say, "") || !equal(username[id],"") || equal(k_username[id],"") || strlen(say) > 12)
{
copy(g_username[id],199,"")
copy(g_password[id],199,"")
copy(k_username[id],199,"")
copy(k_password[id],199,"")
return PLUGIN_HANDLED
}
copy(k_password[id],199,say)
kayit_yap(id,k_username[id], k_password[id])
copy(g_password[id],199,"")
copy(g_username[id],199,"")
copy(k_password[id],199,"")
copy(k_username[id],199,"")
return PLUGIN_CONTINUE
}
///////////////////////////
///////////////////////////
public giris_yap(id,userid[],psw[])
{
if(!is_user_connected(id) || equal(userid,"") || equal(psw,"") || !equal(username[id],""))
return PLUGIN_HANDLED
new getPw[32], IDFormat[64]
formatex(IDFormat,63,"%s-ID",userid)
nvault_get(anavault,IDFormat,getPw,31)
if(equali(psw,getPw))
{
copy(username[id],199,userid)
copy(password[id],199,psw)
client_print(id,print_chat,"Hesabiniza basariyla giris yapildi. Su anda %d $ bulunduruyorsunuz!",get_hesap_Money(userid))
}
else
{
client_print(id,print_center,"Yanlis hesap ismi veya sifre !")
}
return PLUGIN_HANDLED
}
public kayit_yap(id,userid[],psw[])
{
if(!is_user_connected(id) || equal(userid,"") || equal(psw,"") || !equal(username[id],""))
return PLUGIN_HANDLED
new getPw[32], IDFormat[64]
formatex(IDFormat,63,"%s-ID",userid)
nvault_get(anavault,IDFormat,getPw,31)
if(equali(getPw,""))
{
copy(username[id],199,userid)
copy(password[id],199,psw)
new MoneyKey[64], hesapKey[64]
formatex(hesapKey,63,"%s-ID",userid)
formatex(MoneyKey,63,"%s-Para",userid)
nvault_set(anavault,hesapKey,psw)
nvault_set(anavault,MoneyKey,"0")
client_print(id,print_chat,"Hesabinizi kaydettik.Islemler icin ^"/banka^" yazin..")
client_print(id,print_chat,"Hesap adi = %s Sifreniz = %s",userid,psw)
}
else
{
client_print(id,print_center,"Bu hesap zaten kayitlarda var..")
}
return PLUGIN_HANDLED
}
public Para_Yatir(id)
{
new say[300]
read_args(say, charsmax(say))
remove_quotes(say)
if(!is_str_num(say) || equal(say, "") || equal(username[id],"") || strlen(say) > 12)
return PLUGIN_HANDLED
if(cs_get_user_money(id) < str_to_num(say) + get_pcvar_num(g_IslemUcreti))
{
client_print(id,print_center,"O kadar Para var mi ? ( Islem ucreti = %d $ )",get_pcvar_num(g_IslemUcreti))
return PLUGIN_HANDLED
}
cs_set_user_money(id,cs_get_user_money(id) - (str_to_num(say) + get_pcvar_num(g_IslemUcreti)))
set_hesap_Money(username[id],get_hesap_Money(username[id]) + str_to_num(say))
client_print(id,print_center,"Hesabiniza %d $ transfer edildi..",str_to_num(say))
return PLUGIN_HANDLED
}
public Para_Cek(id)
{
new say[300]
read_args(say, charsmax(say))
remove_quotes(say)
if(!is_str_num(say) || equal(say, "") || equal(username[id],"") || strlen(say) > 12)
return PLUGIN_HANDLED
if(get_hesap_Money(username[id]) < str_to_num(say))
{
client_print(id,print_center,"Hesabinizda yeterli Para yok..!")
return PLUGIN_HANDLED
}
cs_set_user_money(id,cs_get_user_money(id) + str_to_num(say))
set_hesap_Money(username[id],get_hesap_Money(username[id]) - str_to_num(say))
client_print(id,print_center,"Hesabinizdan %d $ cektiniz..",str_to_num(say))
return PLUGIN_HANDLED
}
public get_hesap_Money(userid[])
{
new gData[64], gMoneyKey[64]
formatex(gMoneyKey,63,"%s-Para",userid)
nvault_get(anavault,gMoneyKey,gData,63)
return str_to_num(gData)
}
public set_hesap_Money(userid[],miktar)
{
new gMoneyKey[64], miktar2[128]
num_to_str(miktar,miktar2,127)
formatex(gMoneyKey,63,"%s-Para",userid)
nvault_set(anavault,gMoneyKey,miktar2)
return 1
}
public tanit_beni(TaskID)
{
set_hudmessage(255, 255, 255, 0.01, 0.30, 0, 6.0, 6.0)
show_hudmessage(0, "Bankaya ulasmak icin^n/banka yazin ! ")
client_print(0,print_chat,"Size en yakin bankaya ulasmak icin ^"/banka^" yazin !")
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1055\\ f0\\ fs16 \n\\ par }
*/