Zainstalowałem ten plugin na próbę na mój serwer FFA. Po czym po 13 rundach, bo taki limit ustawiłem nie zmienia się mapa. Vote pojawia się po 10 rundzie, lecz jest problem, że nie zmienia się mapa.
// ==========
// Kobra
// www.ledsplej.net
// Use it but give me credits!
// ==========
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define LAST_MAPS 4
// Handlery do menu map-vote
new mchoose_nextmap // Menu
new mcbchoose_nextmap // Menu Callback
new g_rounds // do ilu rund gramy, wzieta z cvara amx_end_rounds
new g_roundsWonCT // ilosc wygranych rund przez CT
new g_roundsWonT // ilosc wygranych rund przez T
new gMaps[50][30] // mapy wczytywane z mapcycle.txt
new gMapsCount // ilosc wczytanych map
new gMapsFiltered[50]
new gMapsFilteredCount
new gCurrentMapId // id z gMaps aktualnie granej mapy
new gMapsInVote[5] = (-1, -1, -1, -1, -1) // id map wylosowanych do vote
new gVotes[5] // glosy na wylosowane mapy
new gVoteRunning=0 // czy vote juz uruchomiony
new gLastMaps[LAST_MAPS] // ostatnie grane mapy
new gLastMapsCount
public plugin_init() {
register_plugin("amx_end", "1.4b", "Kobra LeD")
register_event("SendAudio", "event_roundend_T", "a", "2&%!MRAD_terwin") // wygrywa T
register_event("SendAudio", "event_roundend_CT", "a", "2&%!MRAD_ctwin") // wygrywa CT
register_event("TextMsg", "event_reset", "a", "2&#Game_will_restart_in" ); // TX R3X @ amxx.pl!
register_event("TextMsg", "event_reset", "a", "2&#Game_C") // jw <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/smile.png' class='bbc_emoticon' alt=':)' />
register_cvar("amx_end_rounds", "13")
g_rounds=get_cvar_num("amx_end_rounds")
set_cvar_num("mp_maxrounds", g_rounds*2) // maksymalna ilosc rund ustawiamy na 2x wieksza
read_maps()
read_last_maps()
write_last_maps()
filterMaps()
}
public event_roundend_CT()
{
g_roundsWonCT++
roundend()
}
public event_roundend_T()
{
g_roundsWonT++
roundend()
}
public roundend()
{
if(g_roundsWonCT>g_rounds-1||g_roundsWonT>g_rounds-1) // koniec rundy, sprawdzamy czy konczymy mape
{
set_cvar_num("mp_maxrounds", 1)
} else {
client_print(0,print_chat,"****************")
client_print(0,print_chat," T: %d/%d CT: %d/%d ***",g_roundsWonT,g_rounds,g_roundsWonCT,g_rounds) // nie konczymy mapy, wypisujemy wynik
client_print(0,print_chat,"****************")
}
if((g_roundsWonCT>g_rounds-3 || g_roundsWonT>g_rounds-3) && (gVoteRunning==0)) { // odpalamy vote, jesli ktoras druzyna wygrala 10 rund
run_vote()
}
}
public event_reset() // CS-Hejdz.pl [FFA]
{
g_roundsWonCT=0
g_roundsWonT=0
}
public bool:filter_wasPlayed(map_id) {
for(new a = 0; a<gLastMapsCount; a++) { // sprawdzamy czy wylosowana mapa nie byla juz ostatnio grana
if(gLastMaps[a] == map_id) {
return true
}
}
return false
}
public bool:filter_isPlayed(map_id) {
if(map_id == gCurrentMapId) {
return true
}
return false
}
public bool:filter_isSelected(map_id) {
for(new a = 0; a<5; a++) { // sprawdzamy, czy wylosowana mapa juz nie zostala wylosowana
if(map_id == gMapsInVote[a]) {
return true
}
}
return false
}
public filterMaps() { // Filtracja map - dodajemy tylko te, ktore nie byly ostatnio grane ORAZ nie sa obecnie grana mapa
for(new a=0; a<gMapsCount; a++) {
if(!filter_isPlayed(a) && !filter_wasPlayed(a)) {
addMap(a)
log_amx("AddedFiltered %s", gMaps[a])
}
}
}
public addMap(map_id) {
gMapsFiltered[gMapsFilteredCount] = map_id
gMapsFilteredCount++
}
public run_vote() { // przygotowujemy vote na nextmap
if(gMapsFilteredCount < 5) {
log_amx("ERROR: Not enough maps after filtering!")
return PLUGIN_CONTINUE
}
gVoteRunning=1
new toLog[128]
new rand = random_num(0, gMapsFilteredCount-1) // pierwsza mapa losowa
new iterateVotes
gMapsInVote[0] = gMapsFiltered[rand];
format(toLog, 128, "%s %s", toLog, gMaps[gMapsInVote[0]]) // debugger
for(iterateVotes=1; iterateVotes<5; iterateVotes++) { // 4x szukamy nastepnych losowych map (ma byc 5)
rand=-1
while(rand == -1) {
rand = random_num(0, gMapsFilteredCount-1)
if(filter_isSelected(gMapsFiltered[rand])) {
rand = -1
}
}
gMapsInVote[iterateVotes] = gMapsFiltered[rand]
format(toLog, 200, "%s %s", toLog, gMaps[gMapsFiltered[rand]]) // debugger
}
log_amx("%s",toLog) // debugger
/* Menu choose_nextmap */
/* Use menu_display(id, mchoose_nextmap, 0) to show the menu to an user. */
mchoose_nextmap = menu_create("Wybierz nastepna mape", "mh_choose_nextmap") // przygotowujemy menu
mcbchoose_nextmap = menu_makecallback("mcb_choose_nextmap")
menu_additem(mchoose_nextmap, gMaps[gMapsInVote[0]], "ma_choose_nextmap", ADMIN_ALL, mcbchoose_nextmap)
menu_additem(mchoose_nextmap, gMaps[gMapsInVote[1]], "ma_choose_nextmap", ADMIN_ALL, mcbchoose_nextmap)
menu_additem(mchoose_nextmap, gMaps[gMapsInVote[2]], "ma_choose_nextmap", ADMIN_ALL, mcbchoose_nextmap)
menu_additem(mchoose_nextmap, gMaps[gMapsInVote[3]], "ma_choose_nextmap", ADMIN_ALL, mcbchoose_nextmap)
menu_additem(mchoose_nextmap, gMaps[gMapsInVote[4]], "ma_choose_nextmap", ADMIN_ALL, mcbchoose_nextmap)
/* Menu End */
new iPlayers[32],iNum
get_players(iPlayers, iNum)
for(new i=0;i<iNum;i++) // wyswietlamy menu dla kazdego gracz, ktory jest polaczony
{
if(is_user_connected(iPlayers[i]))
{
menu_display(iPlayers[i], mchoose_nextmap, 0)
}
}
set_task(10.0, "end_vote", 666) // za 10 sekund konczymy vote
return PLUGIN_CONTINUE
}
public read_maps() { // wczytujemy mapy z mapcycle.txt
new rsFile[128],s[128],i
new current_map[19]
get_mapname(current_map, 20)
// get_configsdir(rsFile, 128)
format(rsFile, 128 ,"mapcycle.txt", rsFile) // should be something like addons/amxmodx/configs/
i=fopen(rsFile,"rt")
gMapsCount=0
if(i==0){
log_amx("Error loading config file! [%s]", rsFile)
} else {
while (!feof(i)) // Czytamy mapki
{
fgets(i,s,30)
trim(s)
if(s[0]!=0) {
log_amx("Loaded [%s]", s);
if(equal(current_map, s)) {
gCurrentMapId=gMapsCount // zapisujemy ID aktualnie granej mapy - przydatne do pozniejszego losowania map
}
copy(gMaps[gMapsCount], 30, s)
gMapsCount++
}
}
fclose(i)
}
log_amx("Current Map ID: %d", gCurrentMapId) // debugger
log_amx("Loaded maps: %d", gMapsCount)
return PLUGIN_CONTINUE
}
public read_last_maps() { // wczytujemy ostatnie mapy z lastmaps.ini
new rsFile[128],s[128],i
get_configsdir(rsFile, 128)
format(rsFile, 128 ,"%s/last_maps.ini", rsFile) // should be something like addons/amxmodx/configs/
i=fopen(rsFile,"rt")
gLastMapsCount=0
if(i==0){
log_amx("Error loading last_maps file! [%s]", rsFile)
} else {
while (!feof(i)) // Czytamy ostatnio grane mapki
{
fgets(i,s,30)
trim(s)
if(s[0]!=0) {
for(new x=0; x<gMapsCount; x++) {
if(equal(gMaps[x], s)) {
gLastMaps[gLastMapsCount]=x // zapisujemy ID ostatnio granej mapy
log_amx("Loaded last_maps [%s]", s);
gLastMapsCount++
}
}
}
}
fclose(i)
}
log_amx("Loaded last_maps: %d", gLastMapsCount)
return PLUGIN_CONTINUE
}
public write_last_maps() {
new current_map[19], ile_do_zapisania, rsFile[128]
get_configsdir(rsFile, 128)
format(rsFile, 128 ,"%s/last_maps.ini", rsFile) // should be something like addons/amxmodx/configs/
if(file_exists(rsFile))
delete_file(rsFile)
get_mapname(current_map, 20)
ile_do_zapisania = gLastMapsCount
if(gLastMapsCount>=LAST_MAPS)
ile_do_zapisania = LAST_MAPS - 1
write_file(rsFile, current_map)
log_amx("Wrote last_maps [%s]", current_map)
for(new x=0; x<ile_do_zapisania; x++) {
write_file(rsFile, gMaps[gLastMaps[x]])
log_amx("Wrote last_maps [%s]", gMaps[gLastMaps[x]])
}
}
public end_vote() { //vote po 10-tej rundzie
new winner=0
for(new i=1; i<5; i++) { // wyszukujemy mape z najwyzsza iloscia glosow
if(gVotes[i]>gVotes[winner]) {
winner = i
}
}
menu_destroy(mchoose_nextmap) // usuwamy menu - koniec glosowania!
set_cvar_string("amx_nextmap",gMaps[gMapsInVote[winner]]) // ustawiamy nextmap
client_print(0, print_chat,"****************")
client_print(0, print_chat,"*** KONIEC GLOSOWANIA! Nastepna mapa: %s (glosow: %i)", gMaps[gMapsInVote[winner]], gVotes[winner]) // wyswietlamy info o nastepnej mapie
client_print(0, print_chat,"****************")
log_amx("Nastepna mapa: %s (glosow: %i)", gMaps[gMapsInVote[winner]], gVotes[winner])
}
/* Menu choose_nextmap */
public mh_choose_nextmap(id, menu, item) {
/* This event is called when someone presses a key on this menu */
if(item>-1 && item<5) { // 5 map, nie obchodza nas inne wybory (a i tablica wieksza nie jest <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/wink.png' class='bbc_emoticon' alt=';)' />)
new name[31]
get_user_name (id, name, 32)
gVotes[item]++
client_print(0,print_chat,"%s wybral %s (glosow: %i)", name, gMaps[gMapsInVote[item]], gVotes[item]) // wypisujemy jaka mape wybral gracz i ile ma glosow
}
}
public ma_choose_nextmap(id) {
/* This event is called when an item was selected */
}
public mcb_choose_nextmap(id, menu, item) {
/* This is the callback-event, here you can set items enabled or disabled. */
/* If you want to enable an item, use: return ITEM_ENABLED */
/* If you want to disable an item, use: return ITEM_DISABLED */
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/


Dodatki SourceMod












