// ==========
// Kobra
// www.ledsplej.net
// Use it but give me credits!
// ==========
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define LAST_MAPS 1
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 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", "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.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,"****************")
}
}
public event_reset() // TX R3X @ amxx.pl!
{
g_roundsWonCT=0
g_roundsWonT=0
}
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]])
}
}
Mam nadzieje że za dużo błędów nie narobiłem
Edit.
Sorki tera zauważyłem błąd zara poprawie.
Edit2.
kk chyba już powinno działać
Użytkownik Owner123 edytował ten post 18.01.2010 21:39