#include <amxmodx>
#include <amxmisc>
#include <zombieplague>
#include <nvault>
#define PLUGIN "[ZP]: Ammo 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","Ammo_Yatir")
register_clcmd("Alacaginiz_Miktar","Ammo_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","3")
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 \wRazeOp's Banka",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,"Ammo Yatir","3",0)
menu_additem(menu,"Ammo Cek","4",0)
menu_additem(menu,"Ammo Hesap Durumu","5",0)
menu_additem(menu,"Cikis Yap","6",0)
}
if(get_user_flags(id) & ADMIN_BAN)
{
menu_additem(menu,"Oyuncularin Hesaplarina Bak","7",ADMIN_BAN)
}
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 Ammo Miktari : ^n %d Ammo",get_hesap_ammo(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 Ammo) - Hesap Adi= %s Hesapta= %d Ammo</font>",iName,zp_get_user_ammo_packs(i),username[i],get_hesap_ammo(username[i]));
}
else
{
len += formatex(message[len],898-len,"<font color=red>%s</font><font color=white> (Uzerinde %d Ammo) - Hesabi Yok",iName,zp_get_user_ammo_packs(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 Ammo depoluyorsunuz!",get_hesap_ammo(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 ammoKey[64], hesapKey[64]
formatex(hesapKey,63,"%s-ID",userid)
formatex(ammoKey,63,"%s-Ammo",userid)
nvault_set(anavault,hesapKey,psw)
nvault_set(anavault,ammoKey,"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 Ammo_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(zp_get_user_ammo_packs(id) < str_to_num(say) + get_pcvar_num(g_IslemUcreti))
{
client_print(id,print_center,"O kadar ammon var mi ? ( Islem ucreti = %d Ammo )",get_pcvar_num(g_IslemUcreti))
return PLUGIN_HANDLED
}
zp_set_user_ammo_packs(id,zp_get_user_ammo_packs(id) - (str_to_num(say) + get_pcvar_num(g_IslemUcreti)))
set_hesap_ammo(username[id],get_hesap_ammo(username[id]) + str_to_num(say))
client_print(id,print_center,"Hesabiniza %d Ammo transfer edildi..",str_to_num(say))
return PLUGIN_HANDLED
}
public Ammo_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(str_to_num(say)>1000){
client_print(id,print_center,"Uzgunum en fazla 1000 ammo cekebilirsiniz!");
return PLUGIN_HANDLED;
}
if(get_hesap_ammo(username[id]) < str_to_num(say))
{
client_print(id,print_center,"Hesabinizda yeterli ammo yok..!")
return PLUGIN_HANDLED
}
zp_set_user_ammo_packs(id,zp_get_user_ammo_packs(id) + str_to_num(say))
set_hesap_ammo(username[id],get_hesap_ammo(username[id]) - str_to_num(say))
client_print(id,print_center,"Hesabinizdan %d Ammo cektiniz..",str_to_num(say))
return PLUGIN_HANDLED
}
public get_hesap_ammo(userid[])
{
new gData[64], gAmmoKey[64]
formatex(gAmmoKey,63,"%s-Ammo",userid)
nvault_get(anavault,gAmmoKey,gData,63)
return str_to_num(gData)
}
public set_hesap_ammo(userid[],miktar)
{
new gAmmoKey[64], miktar2[128]
num_to_str(miktar,miktar2,127)
formatex(gAmmoKey,63,"%s-Ammo",userid)
nvault_set(anavault,gAmmoKey,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 !")
}