// ---------------------------------------------------------------------------
// ClanMod 1.82b1 Config Pack v1.82b1 [18 February, 2004]
// ---------------------------------------------------------------------------
// This file is part of ClanMod (See README for more information).
// Copyright 2002 - 2004 UnitedAdmins (www.unitedadmins.com)
// Project originally created by OLO (http://olo.counter-strike.pl)
// ---------------------------------------------------------------------------
// Please read the manual carefully before altering this file!
// The Manual is located at docs.unitedadmins.com
// ---------------------------------------------------------------------------

cm_log "[CLANMOD] Loading MapExtend Script (&cm_configpath&/configs/scripts/cm_mapextend.cfg)"

// -------------------------------Internal CVARs------------------------------
cm_addcvar "cm_addon_mapextend" "0" abn
cm_addcvar "cm_me_nein_typ" "2" abp
cm_addcvar "cm_me_ja_typ" "1" abp
cm_addcvar "cm_me_voice" "1" abp
cm_addcvar "cm_me_counter" "3" abp
cm_addcvar "cm_me_zaehler" "0" abp
cm_addcvar "cm_me_map1" "de_aztec" abp
cm_addcvar "cm_me_map2" "de_dust2" abp
cm_addcvar "cm_me_map3" "de_inferno" abp
cm_addcvar "cm_me_map4" "de_nuke" abp
cm_addcvar "cm_me_voteratio" "0.4" abp
cm_addcvar "cm_me_timelimit" "20" abp
cm_addcvar "cm_me_public" "0" abp
cm_addcvar "cm_me_soundfile" "Gman/Gman_Choose2" abp
cm_addcvar "cm_me_add" "15" abp

// -----------------------------------Commands--------------------------------
cm_command "cm_mapvoteration" "cm_task 20 'cm_mapvoteratio &cm_mapvoteratio&' nsru 'cm_m'"
cm_command "cm_customvoteration" "cm_task 20 'cm_customvoteratio &cm_customvoteratio&' nsru 'cm_c'"
cm_command "cm_nachrichten" "cm_task 0.5 'cm_announce_action &cm_announce_action&' nsru 'cm_a_a'"
cm_command "cm_me_voicen" "cm_nachrichten;cm_announce_action 0;cm_clexec * 'spk &cm_me_soundfile&'"
cm_command "cm_me_redotask" "cm_task 2 'cm_me_ausfuehren1' bmur 'mapextend_vote'"
cm_command "cm_me_nope" "cm_say @@@@ ** MapExtend Not Possible **"
cm_command "cm_me_nein_1" "cm_nachrichten;cm_announce_action 0;cm_mapvoteration;cm_mapvoteratio &cm_me_voteratio&;cm_clexec * cm_votemapcmd;cm_say @@@@ ** MapExtend ended with global VoteMap **"
cm_command "cm_me_nein_2" "cm_mapvoteration;cm_mapvoteratio &cm_me_voteratio&;cm_votemap '&cm_me_map1&' '&cm_me_map2&' '&cm_me_map3&' '&cm_me_map4&';cm_say @@@@ ** MapExtend ended with special VoteMap **"
cm_command "cm_me_ja_1" "cm_cvarcalc mp_timelimit + &cm_me_add&;cm_say @@@@ ** MapExtend ended with TL +&cm_me_add&min **"
cm_command "cm_me_ja_2" "cm_cvarcalc mp_timelimit * 2;cm_say @@@@ ** MapExtend ended with doubled TL **"
cm_command "cm_me_ja_3" "cm_nextmap &cm_currentmap&;cm_say @@@@ ** MapExtend ended with Nextmap = Currentmap **"
cm_command "cm_me_ja_0" "cm_cvarcalc 'mp_timelimit' '+' '5';cm_say @@@@ ** MapExtend ended with TL +5min **"
cm_command "cm_me_laenger" "cm_task 2 'cm_me_redotask' nmr;cm_if cm_me_ja_typ == 1 then cm_me_ja_1;cm_if cm_me_ja_typ == 2 then cm_me_ja_2;cm_if cm_me_ja_typ == 3 then cm_me_ja_3;cm_if cm_me_ja_typ == 0 then cm_me_ja_0"
cm_command "cm_me_nixlaenger" "cm_if cm_me_nein_typ == 1 then cm_me_nein_1;cm_if cm_me_nein_typ == 2 then cm_me_nein_2;cm_if cm_me_nein_typ == 0 then cm_say @@@@ ** MapExtend ended without any action **"
cm_command "cm_me_ausfuehren3" "cm_if cm_me_voice == 1 then cm_me_voicen;cm_customvoteration;cm_customvoteratio &cm_me_voteratio&;cm_vote 'Extend Current Map?' 'Yes' 'cm_me_laenger' 'No' 'cm_me_nixlaenger'"
cm_command "cm_me_ausfuehren2" "cm_if cm_me_counter >= &cm_me_zaehler& then cm_me_ausfuehren3 else cm_me_nope"
alias "cm_me_ausfuehren1" "cm_if cm_addon_mapextend == 1 then cm_me_ausfuehren2 else cm_me_nope;cm_cvarcalc cm_me_zaehler + 1"
alias "cm_me_dozaehler" "cm_me_zaehler 0"

// -------------------------------------Tasks---------------------------------
cm_task 45 "cm_if cm_addon_mapextend == 1 then cm_me_dozaehler;cm_if cm_addon_mapextend == 1 then cm_me_timelimitcmd;cm_if cm_addon_mapextend == 1 then cm_me_redotask" asfu "mapextend_reset"
cm_task 1 "cm_if cm_addon_mapextend == 1 then cm_me_timelimitcmd" amfu "mapextend_tl_reset"

cm_command "cm_me_timelimitcmd" "mp_timelimit '&cm_me_timelimit&'"
cm_command "cm_me_timelimitset" "cm_me_timelimit '&mp_timelimit&'"
cm_task 30 "cm_me_timelimitset" nsr "mapextend_tl"

cm_alias "/vote_extend" "cm_if cm_me_public == 1 then cm_me_ausfuehren1 else cm_me_nope" astc
cm_alias "/mapextend" "cm_if cm_me_public == 1 then cm_me_ausfuehren1 else cm_me_nope" astpb
cm_alias "/extendmap" "cm_me_ausfuehren1" MVstp
cm_cmd "Start MapExtend Vote" "cm_me_ausfuehren1" MVbs
cm_task 20 "cm_cvar cm_addon_mapextend 1 1 O" nsr
cm_me_zaehler 0
