PHP- Kodu:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Mod Change Vote"
#define VERSION "1.0"
#define AUTHOR "akcaliberkk"
#define RESTART_ADMIN ADMIN_MAP
new menu;
new vote[2];
new status, admin;
new callback;
new const file[] = "addons/amxmodx/configs/mapchanger_cache.txt";
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
status = register_cvar("restartvote","1")
admin = register_cvar("restartvote_obeyadmin","1")
callback = menu_makecallback("MenuCallBack")
}
public plugin_cfg() {
if(!get_pcvar_num(status)) return PLUGIN_CONTINUE
new mapname[32];get_mapname(mapname,31);
new prefix[12];get_map_prefix(mapname,prefix)
if(!file_exists(file)) {
new f = fopen(file,"wt")
fclose(f)
}
else {
new szData[32],txtlen;
read_file(file,0,szData,31,txtlen)
if(!equali(szData,prefix)) {
set_task(15.0,"VoteStart")
}
}
write_file(file,prefix,0)
return PLUGIN_CONTINUE
}
public VoteStart() {
new players[32],inum;
get_players(players,inum)
menu = menu_create("\rHaritanin Modu Acilsin Mi ?","MenuHandle")
menu_additem(menu,"Evet","")
menu_additem(menu,"Hayir","")
if(get_pcvar_num(admin)) menu_additem(menu,"\yADMIN: \rOylamayi Durdur","",RESTART_ADMIN, callback)
menu_setprop(menu,MPROP_EXIT,MEXIT_NEVER)
for(new i;i<inum;i++) {
menu_display(players[i],menu)
}
set_task(15.0,"VoteTimeout",123)
}
public MenuCallBack(id,menu,item) {
if(!access(id,RESTART_ADMIN)) {
menu_item_setname(menu,2,"\dADMIN: Oylamayi Durdur")
}
}
public MenuHandle(id, menu, item) {
switch(item) {
case 0: vote[0]++
case 1: vote[1]++
case 2: VoteForceStop(id);
}
}
public VoteTimeout() {
if( vote[0] > vote[1] ) {
client_print(0,print_chat,"[AMXX] Mod Oylamasi Sonucu: EVET ( E: %d - H: %d ) ", vote[0], vote[1])
client_print(0,print_chat,"[AMXX] Modun Aktif Olmasi Icin Map Yeniden Aciliyor !")
new mapname[32]; get_mapname(mapname,31)
server_cmd("amx_map %s",mapname)
}
else if( vote[0] == vote[1]) {
client_print(0,print_chat,"[AMXX] Mod Oylamasi Sonucu: BERABERE ( E: %d - H: %d ) ", vote[0], vote[1])
client_print(0,print_chat,"[AMXX] Bilgisayarin Secimi: EVET")
client_print(0,print_chat,"[AMXX] Modun Aktif Olmasi Icin Map Yeniden Aciliyor !" )
new mapname[32]; get_mapname(mapname,31)
server_cmd("amx_map %s",mapname)
}
else {
client_print(0,print_chat,"[AMXX] Mod Oylamasi Sonucu: HAYIR ( E: %d - H: %d ) ", vote[0], vote[1])
client_print(0,print_chat,"[AMXX] Oyun Suanki Modda Devam Edecek !" )
}
}
public VoteForceStop(id) {
new name[32]; get_user_name(id,name,31)
client_print(id,print_chat,"[AMXX] ADMIN %s: Mod Oylamasini Iptal Etti !",name)
remove_task(123);
menu_destroy(menu);
}
stock get_map_prefix( mapname[] , prefix[]) {
new x;
while( x < strlen(mapname)-1 ) {
if(mapname[x] == '_') {
return 1;
}
prefix[x] = mapname[x];
x++
}
return 0;
}