cyxnzb
|
分享:
▲
▼
Re:伺服器人气情境侦测系统
new luremap_ini_file[64]; new normap_ini_file[64]; new primalntmap[32]; new admonline; new bots; new luremapnums; new normapnums; new ctmap[32]; new RDntmap[32]; new luremap[32]; new Array:load_luremaps; new Array:load_normaps; new primaltimelimit; new primalwinlimit; new primalmaxrounds; new len1[128]; new len2[128]; new len3[128]; new len4[128]; new len5[128]; new g_teamScore[2]; new bool:g_startvote; new bool:timecheck; new bool:checkRDset; new bool:votecheckskip; cstrike_running() { new mod_name[32]; get_modname(mod_name, ""); new var1; return equal(mod_name, "cstrike", "cstrike") || equal(mod_name, "czero", "cstrike") || equal(mod_name, "csv15", "cstrike") || equal(mod_name, "cs13", "cstrike"); }
get_configsdir(name[], len) { return get_localinfo("amxx_configsdir", name, len); }
public plugin_init() { register_plugin("server_lure_system", "1.0b", "Gu Gu*"); register_clcmd("say", "handle_say", -1, 3992, -1); register_cvar("amx_timebuffer", "60.0", "cstrike", "cstrike"); register_cvar("amx_admbreak", 4128, "cstrike", "cstrike"); register_cvar("amx_fewppl", "10", "cstrike", "cstrike"); register_cvar("amx_highppl", "16", "cstrike", "cstrike"); register_cvar("amx_botcheck", 4304, "cstrike", "cstrike"); register_cvar("amx_luremap", "cs_bloodstrike", "cstrike", "cstrike"); register_dictionary("adminvote.txt"); register_dictionary("common.txt"); register_dictionary("mapsmenu.txt"); get_mapname(ctmap, ""); load_luremaps = ArrayCreate("czero", "czero"); load_normaps = ArrayCreate("czero", "czero"); if (cstrike_running()) { register_event("TeamScore", "team_score", 4656, 4664); } loadinglurefile(); loadingnorfile(); set_task(1097859072, "waitload", "cstrike", 4704, "cstrike", 4708, "cstrike"); return 0; }
public waitload() { format(len1, 127, "\x01[\x03人氣情境偵測系統\x01] 目前伺服器 - \x04尚未確認"); format(len2, 127, "\x03下一張地圖\x01設定型態 - \x04尚未確認"); format(len3, 127, "\x01作者:\x03\nHLDS\x01架設班導師【\x04-oGc- | Gu Gu*\x01】"); format(len4, 127, "\x04\nDLC數位生活頻道\x01:\x03\nhttp://c7.no-ip.org"); format(len5, 127, "\x04相關訊息查詢\x01 -\x03 /map_type"); set_task(floatsub(get_cvar_float("amx_timebuffer"), 1097859072), "timebuffer", "cstrike", 4704, "cstrike", 4708, "cstrike"); get_cvar_string("amx_nextmap", primalntmap, ""); get_cvar_string("amx_luremap", luremap, ""); primaltimelimit = get_cvar_num("mp_timelimit"); primalwinlimit = get_cvar_num("mp_winlimit"); primalmaxrounds = get_cvar_num("mp_maxrounds"); return 0; }
public timebuffer() { primaltimelimit = get_cvar_num("mp_timelimit"); primalwinlimit = get_cvar_num("mp_winlimit"); primalmaxrounds = get_cvar_num("mp_maxrounds"); timecheck = true; case_check(); return 0; }
public client_putinserver(id) { if (is_user_bot(id)) { bots += 1; } if (get_user_flags(id, "cstrike") & 32) { admonline += 1; } if (!timecheck) { return 0; } Announce1(id); case_check(); return 0; }
public client_disconnect(id) { if (is_user_bot(id)) { bots -= 1; } if (get_user_flags(id, "cstrike") & 32) { admonline -= 1; } if (!timecheck) { return 0; } case_check(); return 0; }
public case_check() { new playersnum = get_playersnum("cstrike"); if (!get_cvar_num("amx_botcheck")) { playersnum -= bots; } if (playersnum <= 1) { server_empty(); } else { if (1 < playersnum <= get_cvar_num("amx_fewppl")) { server_fewppl(); } new var1; if (playersnum > get_cvar_num("amx_fewppl") && playersnum <= get_cvar_num("amx_highppl")) { server_norppl(); } server_highppl(); } return 0; }
public server_empty() { active_AD(0); if (task_exists(987456, "cstrike")) { remove_task(987456, "cstrike"); } new var1; if (get_cvar_num("amx_admbreak") && admonline > 0) { return 0; } if (!equal(ctmap, luremap, "cstrike")) { if (ValidMap(luremap)) { server_print("[SVLS] server empty! champ map to %s", luremap); server_cmd("changelevel %s", luremap); } } if (get_cvar_num("mp_timelimit")) { set_cvar_num("mp_timelimit", "cstrike"); } if (get_cvar_num("mp_winlimit")) { set_cvar_num("mp_winlimit", "cstrike"); } if (get_cvar_num("mp_maxrounds")) { set_cvar_num("mp_maxrounds", "cstrike"); } return 0; }
public server_fewppl() { active_AD(1); if (primaltimelimit != get_cvar_num("mp_timelimit")) { set_cvar_num("mp_timelimit", primaltimelimit); } if (primalwinlimit != get_cvar_num("mp_winlimit")) { set_cvar_num("mp_winlimit", primalwinlimit); } if (primalmaxrounds != get_cvar_num("mp_maxrounds")) { set_cvar_num("mp_maxrounds", primalmaxrounds); } new var1; if (get_cvar_num("amx_admbreak") && admonline > 0 && task_exists(987456, "cstrike")) { remove_task(987456, "cstrike"); return 0; } new var2; if (get_cvar_num("amx_admbreak") && admonline > 0 && !task_exists(987456, "cstrike")) { return 0; } new var3; if (!isInMenu(ctmap, load_luremaps, luremapnums) && !equal(ctmap, luremap, "cstrike")) { votecheckskip = true; } else { votecheckskip = false; } if (!task_exists(987456, "cstrike")) { set_task(1097859072, "voteNextmap", 987456, 7408, "cstrike", 7412, "cstrike"); } return 0; }
public server_norppl() { if (task_exists(987456, "cstrike")) { remove_task(987456, "cstrike"); } new var1; if (get_cvar_num("amx_admbreak") && admonline > 0) { return 0; } if (isInMenu(ctmap, load_normaps, normapnums)) { Onornextmap(); } else { Rnornextmap(); } active_AD(2); return 0; }
public server_highppl() { active_AD(3); new var1; if (get_cvar_num("amx_admbreak") && admonline > 0) { return 0; } new ctntmap[32]; get_cvar_string("amx_nextmap", ctntmap, ""); if (!equal(primalntmap, ctntmap, "cstrike")) { set_cvar_string("amx_nextmap", primalntmap); server_print("[SVLS] High ppl.! switch nextmap to %s", primalntmap); } return 0; }
public Rnornextmap() { new ntmap[32]; get_cvar_string("amx_nextmap", ntmap, ""); if (isInMenu(primalntmap, load_normaps, normapnums)) { set_cvar_string("amx_nextmap", primalntmap); server_print("[SVLS] Normal ppl.! switch nextmap to %s", primalntmap); return 0; } if (!checkRDset) { new b = random_num("cstrike", luremapnums + -1); ArrayGetString(load_normaps, b, RDntmap, ""); set_cvar_string("amx_nextmap", RDntmap); server_print("[SVLS] Normal ppl.! switch nextmap to %s", RDntmap); checkRDset = true; return 0; } if (!equal(ntmap, RDntmap, "cstrike")) { set_cvar_string("amx_nextmap", RDntmap); server_print("[SVLS] Normal ppl.! switch nextmap to %s", RDntmap); } return 0; }
public Onornextmap() { new newntmap[32]; new tpmap[32]; new i; while (i < normapnums) { ArrayGetString(load_normaps, i, tpmap, ""); if (equal(tpmap, ctmap, "cstrike")) { new var1; if (normapnums + -1 == i) { var1 = 0; } else { i++; var1 = i; } ArrayGetString(load_normaps, var1, newntmap, ""); set_cvar_string("amx_nextmap", newntmap); server_print("[SVLS] Normal ppl.! switch nextmap to %s", newntmap); return 0; } i++; } return 0; }
public voteNextmap() { g_startvote = false; if (!votecheckskip) { new winlimit = get_cvar_num("mp_winlimit"); new maxrounds = get_cvar_num("mp_maxrounds"); new timelimit = get_cvar_num("mp_timelimit"); if (winlimit) { new c = winlimit + -2; new var1; if (c < g_teamScore[0] || c < g_teamScore[1]) { g_startvote = true; } } if (maxrounds) { if (g_teamScore[1] + g_teamScore[0] > maxrounds + -2) { g_startvote = true; } } if (timelimit) { new timeleft = get_timeleft(); new var2; if (timeleft > 1 && timeleft < 129) { g_startvote = true; } } } else { g_startvote = true; } if (!g_startvote) { return 0; } new votestring[128]; if (luremapnums == 1) { ArrayGetString(load_luremaps, "cstrike", votestring, 127); server_cmd("amx_votemap %s", votestring); Announce(1); return 0; } new vmapnum; new selectmap = 3; if (selectmap > luremapnums) { selectmap = luremapnums + -1; } new doneselectmap[3][32] = { { 37, 115, 32, 37, 115, 0, 37, 115, 0, 97, 109, 120, 95, 118, 111, 116, 101, 109, 97, 112, 32, 37, 115, 0, 46, 98, 115, 112, 0, 37, 115, 47 }, { 108, 117, 114, 101, 109, 97, 112, 46, 105, 110, 105, 0, 114, 0, 37, 115, 47, 110, 111, 114, 109, 97, 112, 46, 105, 110, 105, 0, 114, 0, 1, 91 }, { 3, 228, 186, 186, 230, 176, 163, 230, 131, 133, 229, 162, 131, 229, 129, 181, 230, 184, 172, 231, 179, 187, 231, 181, 177, 1, 93, 32, 231, 155, 174, 229 } }; while (vmapnum < selectmap) { new smap[32]; new rannum = random_num("cstrike", luremapnums + -1); ArrayGetString(load_luremaps, rannum, smap, ""); if (!(equal(smap, ctmap, "cstrike"))) { new beselected; new i; while (i < 3) { if (equal(smap, doneselectmap, "cstrike")) { beselected = 1; } i++; } if (!(beselected == 1)) { format(votestring, 127, 8896, votestring, smap); format(doneselectmap[vmapnum], "", "%s", smap); vmapnum++; } } } server_cmd("amx_votemap %s", votestring); return 0; }
bool:ValidMap(mapname[]) { if (is_map_valid(mapname)) { return true; } new len = strlen(mapname) - 4; if (0 > len) { return false; } if (equali(mapname[len], ".bsp", "cstrike")) { mapname[len] = 0; if (is_map_valid(mapname)) { return true; } } return false; }
public isInMenu(checkmap[], Array:mapmenufile, mapsize) { new a; while (a < mapsize) { new ctmp[32]; ArrayGetString(mapmenufile, a, ctmp, ""); if (equal(checkmap, ctmp, "cstrike")) { return 1; } a++; } return 0; }
public team_score() { new team[2]; read_data(1, team, 1); new var1; if (team[0] == 67) { var1 = 0; } else { var1 = 1; } g_teamScore[var1] = read_data(2); return 0; }
public loadinglurefile() { get_configsdir(luremap_ini_file, 63); format(luremap_ini_file, 63, "%s/luremap.ini", luremap_ini_file); if (!file_exists(luremap_ini_file)) { return 0; } new szText[32]; new buff[256]; new fp = fopen(luremap_ini_file, 9072); while (!feof(fp)) { buff[0] = 0; fgets(fp, buff, 255); parse(buff, szText, 31); new var1; if (szText[0] != 59 && ValidMap(szText)) { ArrayPushString(load_luremaps, szText); luremapnums += 1; } } fclose(fp); return luremapnums; }
public loadingnorfile() { get_configsdir(normap_ini_file, 63); format(normap_ini_file, 63, "%s/normap.ini", normap_ini_file); if (!file_exists(normap_ini_file)) { return 0; } new szText[32]; new buff[256]; new fp = fopen(normap_ini_file, 9136); while (!feof(fp)) { buff[0] = 0; fgets(fp, buff, 255); parse(buff, szText, 31); new var1; if (szText[0] != 59 && ValidMap(szText)) { ArrayPushString(load_normaps, szText); normapnums += 1; } } fclose(fp); return normapnums; }
public active_AD(type) { format(len1, 127, "\x01[\x03人氣情境偵測系統\x01] 目前伺服器 -"); format(len2, 127, "\x03下一張地圖\x01設定型態 -"); switch (type) { case 0: { format(len1, 127, "%s \x04閒置", len1); format(len2, 127, "%s 將地圖保持於\x04%s", len2, luremap); } case 1: { format(len1, 127, "%s \x04人氣低落", len1); format(len2, 127, "%s 進行\x04熱圖投票", len2); } case 2: { format(len1, 127, "%s \x04人氣普普", len1); format(len2, 127, "%s \x04官方地圖", len2); } case 3: { format(len1, 127, "%s \x04人氣鼎沸", len1); format(len2, 127, "%s \x04原始地圖設定", len2); } default: { } } return 0; }
public Announce(type) { if (!timecheck) { return 0; } new var1; if (get_cvar_num("amx_admbreak") && admonline > 0) { return 0; } print_allmsg(len1, type); print_allmsg(len2, type); print_allmsg(len5, type); return 0; }
public Announce1(id) { if (!timecheck) { return 0; } new var1; if (get_cvar_num("amx_admbreak") && admonline > 0) { return 0; } print_onemsg(len1, id); print_onemsg(len5, id); return 0; }
public handle_say(id) { new said[192]; read_args(said, 192); if (contain(said, "/map_type") != -1) { print_onemsg(len1, id); print_onemsg(len2, id); print_onemsg(len3, id); print_onemsg(len4, id); } return 0; }
public print_allmsg(msg[], dead_or_not) { if (get_maxplayers()) { switch (dead_or_not) { case 0: { new i; while (get_maxplayers() > i) { new var2; if (is_user_connected(i) && !is_user_bot(i)) { message_begin(1, get_user_msgid("SayText"), 10244, i); write_byte(i); write_string(msg); message_end(); } i++; } } case 1: { new i; while (get_maxplayers() > i) { new var1; if (is_user_connected(i) && !is_user_bot(i) && !is_user_alive(i)) { message_begin(1, get_user_msgid("SayText"), 10288, i); write_byte(i); write_string(msg); message_end(); } i++; } } default: { } } return 0; } return 0; }
public print_onemsg(msg[], id) { message_begin(1, get_user_msgid("SayText"), 10332, id); write_byte(id); write_string(msg); message_end(); return 0; }
public plugin_end() { new current_map[32]; get_mapname(current_map, ""); set_localinfo("lastMap", current_map); return 0; }
|