L 12/04/2009 - 00:03:09: [AMXX] Displaying debug trace (plugin "amx_end.amxx") L 12/04/2009 - 00:03:09: [AMXX] Run time error 4: index out of bounds L 12/04/2009 - 00:03:09: [AMXX] [0] textcCTNQj.sma::read_last_maps (line 180) L 12/04/2009 - 00:03:09: [AMXX] [1] textcCTNQj.sma::plugin_init (line 41) L 12/04/2009 - 00:23:04: Start of error session. L 12/04/2009 - 00:23:04: Info (map "de_kabul") (file "addons/amxmodx/logs/error_20091204.log") L 12/04/2009 - 00:23:04: [AMXX] Displaying debug trace (plugin "amx_end.amxx") L 12/04/2009 - 00:23:04: [AMXX] Run time error 4: index out of bounds L 12/04/2009 - 00:23:04: [AMXX] [0] textcCTNQj.sma::read_last_maps (line 180) L 12/04/2009 - 00:23:04: [AMXX] [1] textcCTNQj.sma::plugin_init (line 41) L 12/04/2009 - 00:38:10: Start of error session.
A tu amx_end.sma
// ==========
// Kobra
// www.ledsplej.net
// Use it but give me credits!
// ==========
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define LAST_MAPS 7
// 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 gCurrentMapId // id z gMaps aktualnie granej mapy
new gMapsInVote[5] // 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.3", "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", "2Game_will_restart_in" ); // TX R3X @ amxx.pl!
register_event("TextMsg", "event_reset", "a", "2Game_C") // jw <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/smile.gif' 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()
}
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() // TX R3X @ amxx.pl!
{
g_roundsWonCT=0
g_roundsWonT=0
}
public run_vote() { // przygotowujemy vote na nextmap
gVoteRunning=1
new a, toLog[128]
new rand = random_num(0, gMapsCount-1) // pierwsza mapa losowa
new iterateVotes
while(rand == gCurrentMapId) { // sprawdzamy, czy pierwsza mapa nie jest obecnie grana
rand = random_num(0, gMapsCount-1)
}
gMapsInVote[0]=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, gMapsCount-1)
if(rand == gCurrentMapId) { // sprawdzamy, czy wylosowana nie jest aktualnie grana
rand = -1
}
for(a = 0; a<iterateVotes; a++) // sprawdzamy, czy wylosowana mapa juz nie zostala wylosowana
if(rand == gMapsInVote[a]) {
rand = -1
}
for(a = 0; a<gLastMapsCount; a++) // sprawdzamy czy wylosowana mapa nie byla juz ostatnio grana
if(gLastMaps[a] == rand)
rand = -1
}
gMapsInVote[iterateVotes] = rand
format(toLog, 200, "%s %s", toLog, gMaps[rand]) // 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)
}
}
log_amx("%s",toLog) // debugger
set_task(10.0, "end_vote", 666) // za 10 sekund konczymy vote
}
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)
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.gif' 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



Temat jest zamknięty









