//
// ************************************************
// ****   Warcraft:Source Mod for CS:S/DOD:S   ****
// ************************************************
// **** coded by kryptonite                    ****
// **** with credits to the community, Mattie, ****
// **** Awuh0 and all the supporters           ****
// ****                                        ****
// **** official website:                      ****
// ****    http://wcs.despo-clan.de            ****
// ************************************************
// **** Date: May 02, 2007, v0.75              ****
// ************************************************
//

// CHECK FOR DOBLOCK WCS/WHATEVER/BLOCK
// FUNCTIONS WCS/WHATEVER/BLOCK
// wcs_dir
// TODO fix respawn skills das die nicht in der nächsten runde wirken

// #############################################
// ### CONFIG IS NOW IN es_WCS_config_db.txt ###
// ###  edit the config file, nothing here   ###
// #############################################
block wcs_config
{
  // The config part moved. Check the file:
  // addons/eventscripts/wcs/es_WCS_config_db.txt
  // and edit the settings.
}
// #############################################
// ### DONT CHANGE ANYTHING BELOW THIS LINE  ###
// ### UNLESS YOU KNOW WHAT YOU ARE DOING !  ###
// #############################################


block load
{
  // logging and init the vars
  echo "-----------------------"
  echo "Loading Warcraft:Source mod ..."
  // version info
  es_xsetinfo wcs_ver "v0.75"
  es_xsetinfo wcs_lng_ver "v1.3"
  es_xmakepublic wcs_ver
  es echo Version: server_var(wcs_ver)
  // credits to the creator (don't modify!)
  es_xsetinfo wcs_creator "WCS by Kryptonite - http://wcs.despo-clan.de"
  es_xmakepublic wcs_creator
  es es_xsetinfo wcs_version server_var(wcs_ver)
  es_xmakepublic wcs_version
  // data directory
  es_xsetinfo wcs_dir "|wcs"
  // global variables
  es_xsetinfo wcs_exists 0
  es_xsetinfo wcs_cmd 0
  es_xsetinfo wcs_key 0
  es_xsetinfo wcs_val 0
  es_xsetinfo wcs_text 0
  es_xsetinfo wcs_length 0
  es_xsetinfo wcs_menu 0
  es_xsetinfo wcs_page 0
  es_xsetinfo wcs_tmp 0
  es_xsetinfo wcs_tmp1 0
  es_xsetinfo wcs_tmp2 0
  es_xsetinfo wcs_gravity 0
  es_xsetinfo wcs_team 0
  es_xsetinfo wcs_author 0
  es_xsetinfo wcs_team_targetn 0
  es_xsetinfo wcs_allow_only 0
  es_xsetinfo wcs_magnitude 0
  es_xsetinfo wcs_radius 0
  es_xsetinfo wcs_bonusxp 0
  es_xsetinfo wcs_ulti_allow 0
  es_xsetinfo wcs_gamestarted 0
  es_xsetinfo wcs_shopcat 0
  es_xsetinfo wcs_eventcat 0
  es_xsetinfo wcs_strlen 0
  es_xsetinfo wcs_money 0
  es_xsetinfo wcs_cash 0
  es_xsetinfo wcs_phoenix 0
  es_xsetinfo wcs_type 0
  es_xsetinfo wcs_levelup 0
  es_xsetinfo wcs_infotext 0
  es_xsetinfo wcs_totalplayers 0
  es_xsetinfo wcs_lng 0
  es_xsetinfo wcs_lng2 0
  es_xsetinfo wcs_lng3 0
  es_xsetinfo wcs_alpha 0
  es_xsetinfo wcs_target 0
  es_xsetinfo wcs_flashid 0
  es_xsetinfo wcs_flashcounter 0
  es_xsetinfo wcs_flasheffect 0
  es_xsetinfo wcs_limit 0
  // user related
  es_xsetinfo wcs_id 0
  es_xsetinfo wcs_sid 0
  es_xsetinfo wcs_uid 0
  es_xsetinfo wcs_user 0
  es_xsetinfo wcs_userid 0
  es_xsetinfo wcs_targetid 0
  es_xsetinfo wcs_giveid 0
  es_xsetinfo wcs_lastplayed 0
  es_xsetinfo wcs_date 0
  es_xsetinfo wcs_counter 0
  es_xsetinfo wcs_scounter 0
  es_xsetinfo wcs_race 0
  es_xsetinfo wcs_racename 0
  es_xsetinfo wcs_level 0
  es_xsetinfo wcs_levelf 0
  es_xsetinfo wcs_unused 0
  es_xsetinfo wcs_unusedf 0
  es_xsetinfo wcs_xp 0
  es_xsetinfo wcs_xpf 0
  es_xsetinfo wcs_skill 0
  es_xsetinfo wcs_skilld 0
  es_xsetinfo wcs_credits 0
  es_xsetinfo wcs_numberofskills 0
  es_xsetinfo wcs_numberoflevels 0
  es_xsetinfo wcs_skillnumber 0
  es_xsetinfo wcs_skilltype 0
  es_xsetinfo wcs_skillname 0
  es_xsetinfo wcs_skilldescr 0
  es_xsetinfo wcs_skilllevel 0
  es_xsetinfo wcs_name 0
  es_xsetinfo wcs_requiredlevel 0
  es_xsetinfo wcs_maxlevel 0
  es_xsetinfo wcs_curlevel 0
  es_xsetinfo wcs_alive 0
  es_xsetinfo wcs_adminadd 0
  es_xsetinfo wcs_itemactivate 0
  es_xsetinfo wcs_respawn 0
  es_xsetinfo wcs_immunity 0
  es_xsetinfo wcs_params 0
  es_xsetinfo wcs_armor 0
  es_xsetinfo wcs_player 0
  es_xsetinfo wcs_mole 0
  es_xsetinfo wcs_damage 0
  es_xsetinfo wcs_numeric 0
  es_xsetinfo wcs_silent 0
  es_xsetinfo wcs_total_level 0
  es_xsetinfo wcs_giveuserid 0
  es_xsetinfo wcs_amount 0
  es_xsetinfo wcs_reason 0
  es_xsetinfo wcs_forced 0
  es_xsetinfo wcs_longjump 0
  es_xsetinfo wcs_speed 0
  es_xsetinfo wcs_allowed 0
  es_xsetinfo wcs_adminff 0
  // shop
  es_xsetinfo wcs_descr 0
  es_xsetinfo wcs_cost 0
  es_xsetinfo wcs_level 0
  es_xsetinfo wcs_dab 0
  es_xsetinfo wcs_duration 0
  es_xsetinfo wcs_invis 0
  es_xsetinfo wcs_category 0
  es_xsetinfo wcs_iname 0
  es_xsetinfo wcs_icost 0
  es_xsetinfo wcs_ilevel 0
  es_xsetinfo wcs_idab 0
  // game stuff
  es_xsetinfo wcs_game 0
  es_xgetgame wcs_game
  es_xsetinfo wcs_game_css "Counter-Strike: Source"
  es_xsetinfo wcs_game_dods "Day of Defeat : Source"
  // new method to detect DOD:S...es_getgame doesn't work all time
  es_xexists wcs_exists variable "dod_bonusround"
  es es_xif (server_var(wcs_exists) = 1) do
  {
    // load DOD:S support
    es_xloadevents "../dod/resource/modevents.res"
    es_xsetinfo wcs_game "Day of Defeat : Source"
  }
  es_xsetinfo wcs_wpn_knives "knife|amerknife|spade|punch"
  es_xsetinfo wcs_wpn_grenades "hegrenade|weapon_frag_ger|weapon_frag_us"
  es_xsetinfo wcs_wpn_shotguns "m3|xm1014"
  es_xsetinfo wcs_wpn_all "weapon_knife|weapon_usp|weapon_glock|weapon_p228|weapon_deagle|weapon_elite|weapon_fiveseven|weapon_m3|weapon_xm1014|weapon_mp5navy|weapon_tmp|weapon_p90|weapon_mac10|weapon_ump45|weapon_galil|weapon_famas|weapon_ak47|weapon_sg552|weapon_m4a1|weapon_aug|weapon_m249|weapon_scout|weapon_awp|weapon_g3sg1|weapon_sg550|weapon_flashbang|weapon_hegrenade|weapon_smokegrenade|weapon_c4"
  es_xsetinfo wcs_eventarray1 "WCSpha|WCSphv|WCSpd|WCSps|WCSpsay"
  es_xsetinfo wcs_eventarray2 "player_attacker|player_victim|player_death|player_spawn|player_say"
  es_xsetinfo wcs_roundcounter 0
  es_xsetinfo wcs_round 0
  es_xsetinfo wcs_regenerate 0
  es_xsetinfo wcs_dice 0
  es_xsetinfo wcs_chance 0
  es_xsetinfo wcs_wall 0
  es_xsetinfo wcs_space " "
  es_xsetinfo wcs_void ""
  es_xsetinfo wcs_location_t 0
  es_xsetinfo wcs_location_c 0
  // race skills variables
  es_xsetinfo wcs_rand 0
  es_xsetinfo wcs_health 0
  es_xsetinfo wcs_dmg 0
  es_xsetinfo wcs_x1 0
  es_xsetinfo wcs_y1 0
  es_xsetinfo wcs_z1 0
  es_xsetinfo wcs_x2 0
  es_xsetinfo wcs_y2 0
  es_xsetinfo wcs_z2 0
  es_xsetinfo wcs_x 0
  es_xsetinfo wcs_y 0
  es_xsetinfo wcs_z 0
  // debug setting
  es_xsetinfo wcs_debug 0
  echo "** Here could occur an ERROR. Please ignore it for now. **"
  while "1 > 2" "echo null;"
  echo "** should be fixed by Mattie ... **"
  // load the config - load first !!
  es_xdoblock wcs/wcs_loadconfig
  // IMPORTANT
  es_xload wcs/WCSlanguage
  es_xload wcs/WCSfunctions
  es_xload wcs/WCSraces
  es_xload wcs/WCSshop
  es_xload wcs/WCSusers
  es_xload wcs/WCStop10
  es_xload wcs/WCSadmin
  es_xload wcs/WCSultimates
  // load the redirect subscript !!
  //es_xload wcs/WCSredirect
  es es_xexists wcs_exists command su_mysql
  es es_xif (server_var(wcs_exists) = "0") do
  {
    es_xsetinfo wcs_cfg_enablesql 0
    echo WCS: WARNING su_mysql not found, disabling SQL support...
  }
  // SQL SUPPORT
  es es_xif (server_var(wcs_cfg_enablesql) = "1") then es_xload wcs/WCSsql
  es_xkeygroupcreate "WCStmp"
  // register custom commands
  es_xexists wcs_exists command wcs_reload
  es es_xif (server_var(wcs_exists) = 0) then es_xregcmd wcs_reload wcs/wcs_reload "Reloads the script, parameter: all, config, subscripts, db"
  es es_xif (server_var(wcs_nofeedback) != "1") do
  {
    es es_xsetinfo wcs_vers server_var(wcs_version)
    es_xstring wcs_vers section 0 5
    es es_xformat wcs_feedbackurl "http://wcs.despo-clan.de/feedback.php?wcsversion=%1&ip=%2&server=%3" server_var(wcs_vers) server_var(ip) server_var(hostname)
  }
  echo "Loading done."
  echo "-----------------------"
}

block unload
{
  echo "-----------------------"
  // unload the mod, subscripts cleanup themselfs
  es_xunload wcs/WCSadmin
  es_xunload wcs/WCStop10
  es_xunload wcs/WCSusers
  es_xunload wcs/WCSshop
  es_xunload wcs/WCSlanguage
  es_xunload wcs/WCSraces
  es_xunload wcs/WCSfunctions
  es_xunload wcs/WCSultimates
  es_xunload wcs/WCSredirect
  es es_xif (server_var(wcs_cfg_enablesql) = "1") then es_xunload wcs/WCSsql
  es_xkeygroupdelete WCStmp
  // keygroup for race+shop info
  es_xkeygroupdelete WCSinfo
  echo "Warcraft:Source mod disabled ..."
  echo "-----------------------"
}

// >>>>>>>>>>>>>>>>> START OF REWARD BLOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DONE
event bomb_defused
{
  // give XP when the bomb is defused
  es es_xexists wcs_exists userid event_var(userid)
  wcs_getlanguage "wcs_lng" "wcs_lng_bombdefused"
  es es_xif (server_var(wcs_exists) = 1) then wcs_givexp event_var(userid) server_var(wcs_defusexp) server_var(wcs_lng)
}

event bomb_planted
{
  // give XP when the bomb is planted
  es es_xexists wcs_exists userid event_var(userid)
  wcs_getlanguage "wcs_lng" "wcs_lng_bombplanted"
  es es_xif (server_var(wcs_exists) = 1) then wcs_givexp event_var(userid) server_var(wcs_plantxp) server_var(wcs_lng)
}

event bomb_exploded
{
  // give XP when the bomb is exploded
  es es_xexists wcs_exists userid event_var(userid)
  wcs_getlanguage "wcs_lng" "wcs_lng_bombexploded"
  es es_xif (server_var(wcs_exists) = 1) then wcs_givexp event_var(userid) server_var(wcs_explodexp) server_var(wcs_lng)
}

event hostage_rescued
{
  // give XP when a hostage is rescued
  es es_xexists wcs_exists userid event_var(userid)
  wcs_getlanguage "wcs_lng" "wcs_lng_hostage"
  es es_xif (server_var(wcs_exists) = 1) then wcs_givexp event_var(userid) server_var(wcs_hostagexp) server_var(wcs_lng)
}
// <<<<<<<<<<<<<<<<< END OF REWARD BLOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

// >>>>>>>>>>>>>>>>> DOD:S EVENTS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DONE
event dod_tick_points
{
  wcs_getlanguage "wcs_lng" "wcs_lng_scoretick"
  es_xforeachkey wcs_key in "WCSuserdata" "es es_xgetplayerteam wcs_team server_var(wcs_key);es es_xif (server_var(wcs_team) = event_var(team)) then wcs_givecredits server_var(wcs_key) server_var(wcs_tickcredits) server_var(wcs_lng) 0"
}

event dod_round_win
{
  wcs_getlanguage "wcs_lng" "wcs_lng_wonround"
  es_xforeachkey wcs_key in "WCSuserdata" "es es_xgetplayerteam wcs_team server_var(wcs_key);es es_xif (server_var(wcs_team) = event_var(team)) then wcs_givecredits server_var(wcs_key) server_var(wcs_roundwoncredits) server_var(wcs_lng) 0"
}

event dod_bomb_planted
{
  es es_xexists wcs_exists userid event_var(userid)
  wcs_getlanguage "wcs_lng" "wcs_lng_bombplanted"
  es es_xif (server_var(wcs_exists) = 1) then wcs_givexp event_var(userid) server_var(wcs_plantxp) server_var(wcs_lng)
}

event dod_bomb_defused
{
  es es_xexists wcs_exists userid event_var(userid)
  wcs_getlanguage "wcs_lng" "wcs_lng_bombdefused"
  es es_xif (server_var(wcs_exists) = 1) then wcs_givexp event_var(userid) server_var(wcs_defusexp) server_var(wcs_lng)
}

event dod_bomb_exploded
{
  es es_xexists wcs_exists userid event_var(userid)
  wcs_getlanguage "wcs_lng" "wcs_lng_bombexploded"
  es es_xif (server_var(wcs_exists) = 1) then wcs_givexp event_var(userid) server_var(wcs_explodexp) server_var(wcs_lng)
}

event dod_round_start
{
  // stuff from round_end  
  es_xmath wcs_roundcounter + 1
  es_xkeycreate "WCStmp" "phoenix"
  es_xkeysetvalue "WCStmp" "phoenix" "2" "0"
  es_xkeysetvalue "WCStmp" "phoenix" "3" "0"
  // refresh ultimate countdown
  es_xsetinfo wcs_curtime 0
  es est_uptime wcs_curtime
  es_xforeachkey wcs_key in "WCSuserdata" "es es_xkeysetvalue WCSuserdata server_var(wcs_key) ultimate server_var(wcs_curtime);es es_xkeysetvalue WCSuserdata server_var(wcs_key) jetpack 0"
  es es_xif (server_var(wcs_cfg_savexpround) > 0) do
  {
    es es_xif (server_var(wcs_roundcounter) > 0) do
    {
      es_xcopy wcs_tmp wcs_roundcounter
      es es_xmath wcs_tmp / server_var(wcs_cfg_savexpround)
      es es_xtoken wcs_tmp server_var(wcs_tmp) 1 "."
      es es_xmath wcs_tmp * server_var(wcs_cfg_savexpround)
      es es_xif (server_var(wcs_tmp) = server_var(wcs_roundcounter)) do
      {
        es es_xif (server_var(wcs_turbomode) != "1") do
        {
          es es_xif (server_var(wcs_cfg_enabletxtfile) = "1") then es_xkeygroupsave WCSusers "|wcs/WCSusers"
          es_xkeygroupsave WCStop10 "|wcs/WCStop10"
          es_xmsg #multi #lightgreen: #greenWCS #lightgreensaving world ...
        }
      }
    }
  }
}
// <<<<<<<<<<<<<<<<< END DOD:S BLOCKS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

// >>>>>>>>>>>>>>>>> SERVER STUFF >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
event es_client_command
{
es es_xif (server_var(wcs_debug) = 1) then profile begin clientcmd
  // handle various client commands for the menus
  es es_xif (event_var(command) = "menuselect") do
  {
    es es_xexists wcs_exists key "WCSuserdata" event_var(userid)
    es es_xif (server_var(wcs_exists) = 1) do
    {
      es es_xkeygetvalue wcs_menu "WCSuserdata" event_var(userid) menu
      es es_xif (server_var(wcs_menu) != "0") do
      {
        es es_xsetinfo wcs_userid event_var(userid)
        es es_xif (server_var(wcs_menu) = "race") then es_xdoblock wcs/WCSraces/wcs_race_handle
        es es_xif (server_var(wcs_menu) = "level") then es_xdoblock wcs/WCSusers/wcs_spendskills_handle
        es es_xif (server_var(wcs_menu) = "admin1") then es_xdoblock wcs/WCSadmin/wcs_admin1_handle
        es es_xif (server_var(wcs_menu) = "admin2") then es_xdoblock wcs/WCSadmin/wcs_admin2_handle
        es es_xif (server_var(wcs_menu) = "admin3") then es_xdoblock wcs/WCSadmin/wcs_admin_setting_handling
        es es_xif (server_var(wcs_menu) = "shop1") then es_xdoblock wcs/WCSshop/wcs_shop_handle
        es es_xif (server_var(wcs_menu) = "shop2") then es_xdoblock wcs/WCSshop/wcs_shop_handle
        es es_xif (server_var(wcs_menu) = "shopinfo") then wcs_showinfohandle "shopinfo"
        es es_xif (server_var(wcs_menu) = "raceinfo") then wcs_showinfohandle "raceinfo"
        es es_xif (server_var(wcs_menu) = "playerinfo") then wcs_showinfohandle "playerinfo"
        es es_xif (server_var(wcs_menu) = "top10") then es_xdoblock wcs/WCStop10/wcs_showtop10_handle
        es es_xif (server_var(wcs_menu) = "wcsmenu") then es_xdoblock wcs/WCSfunctions/wcs_wcsmenu_handle
      }
    }
    es_xelse do
    {
      es es_xkeycreate "WCSuserdata" event_var(userid)
    }
  }
es es_xif (server_var(wcs_debug) = 1) then profile end clientcmd
}

event player_jump
{
  // fix for losing gravity when climbing ladders
  es es_xexists wcs_exists key "WCSuserdata" event_var(userid)
  es es_xif (server_var(wcs_exists) = "1") do
  {
    es es_xkeygetvalue wcs_gravity "WCSuserdata" event_var(userid) "gravity"
    es es_xif (server_var(wcs_gravity) != "0") then est_SetGravity event_var(userid) server_var(wcs_gravity)
    es es_xkeygetvalue wcs_silent "WCSuserdata" event_var(userid) "silentwalk"
    es es_xif (server_var(wcs_silent) != "0") do
    {
      es es_xkeygetvalue wcs_tmp WCSuserdata event_var(userid) jumptoggle
      es es_xif (server_var(wcs_tmp) = "0") do
      {
        es es_xkeysetvalue WCSuserdata event_var(userid) "jumptoggle" "1"
        wcs_getlanguage "wcs_lng" "wcs_lng_s_amuleta0"
        es es_xsetplayerprop event_var(userid) CBasePlayer.m_fFlags 1
      }
      es es_xif (server_var(wcs_tmp) = "1") do
      {
        es es_xkeysetvalue WCSuserdata event_var(userid) "jumptoggle" "0"
        wcs_getlanguage "wcs_lng" "wcs_lng_s_amuleta"
        es es_xdelayed 1.0 es_xsetplayerprop event_var(userid) CBasePlayer.m_fFlags 2
      }
      es es_xtell event_var(userid) #multi server_var(wcs_lng)
    }
    es es_xkeygetvalue wcs_longjump "WCSuserdata" event_var(userid) "longjump"
    es es_xif (server_var(wcs_longjump) != "0") do
    {
      es es_xif (server_var(wcs_longjump) < 1) then es_xsetinfo wcs_longjump 1
      // calculate the new velocy for jumping
      es es_xgetplayerprop wcs_tmp event_var(userid) CCSPlayer.baseclass.localdata.m_vecVelocity[0]
      es es_xmath wcs_tmp * server_var(wcs_longjump)
      es es_xgetplayerprop wcs_tmp1 event_var(userid) CCSPlayer.baseclass.localdata.m_vecVelocity[1]
      es es_xmath wcs_tmp1 * server_var(wcs_longjump)
      es es_xformat wcs_tmp "%1,%2,0" server_var(wcs_tmp) server_var(wcs_tmp1)
      es es_xsetplayerprop event_var(userid) CBasePlayer.localdata.m_vecBaseVelocity server_var(wcs_tmp)
    }
  }
}

event es_map_start
{
  es_xexists wcs_exists variable "mani_mute_con_command_spam"
  es es_xif (server_var(wcs_exists) = "1") do
  {
    // avoid mani console spam
    es_xdelayed 5 echo "Disabling mani console spam ..."
    es_xdelayed 5 mani_mute_con_command_spam 1
  }
  // avoid buffer overrun
  es_xdelayed 6 est_AntiBufferOverun 1
}

event server
{
es es_xif (server_var(wcs_debug) = "1") then echo event server start
  // restore some values to default, reload races, admins and stuff...savexp, settings, races, admin, shop
  es es_xif (server_var(wcs_turbomode) = "1") then es_xsetinfo wcs_showtotalplayers 0
  es es_xif (server_var(wcs_turbomode) = "1") then es_xsetinfo wcs_enabletop10 0
  
  es_xforeachkey wcs_key in "WCSuserdata" "es wcs_saveplayer server_var(wcs_key)"
  
  es es_xif (server_var(wcs_turbomode) != "1") then es_xif (server_var(wcs_cfg_enabletxtfile) = "1") then es_xkeygroupsave WCSusers "|wcs/WCSusers"
  es_xkeygroupdelete WCSuserdata
  
  es_xkeygroupdelete WCStmp
  // reload the config
  es_xdoblock wcs/wcs_loadconfig
  // reload the admins, shopmenu and races from the textfile
  es es_xif (server_var(wcs_showtotalplayers) = "1") do
  {
    es echo "Total players : " server_var(wcs_totalplayers)
    // autocleanup ! This will cause lag on large database (10-60 seconds !!!)
    es es_xif (server_var(wcs_autocleanup) = "1") then es_xif (server_var(wcs_totalplayers) > 6000) then es_xdoblock wcs/WCSfunctions/wcs_cleanup
  }
  es_xkeygroupcreate WCSuserdata
  es_xkeygroupcreate WCStmp
  es_xkeycreate WCStmp phoenix
  es_xkeysetvalue "WCStmp" "phoenix" "2" "0"
  es_xkeysetvalue "WCStmp" "phoenix" "3" "0"
  es es_xif (server_var(wcs_adminff) = "0") then es_xdelayed 5 es_xdoblock wcs/WCSfunctions/wcs_checkff
  es_xsetinfo wcs_roundcounter "0"
es es_xif (server_var(wcs_debug) = "1") then echo event server end
}

event round_start
{
  // put out the 1st rank in top10
es es_xif (server_var(wcs_debug) = "1") then echo round_start start
  // refresh ultimate countdown
  es_xsetinfo wcs_curtime 0
  es est_uptime wcs_curtime
  es es_xif (server_var(wcs_cfg_ulti_warmup) != "0") then es_xmath wcs_curtime - server_var(wcs_cfg_ulti_warmup)
  es_xforeachkey wcs_key in "WCSuserdata" "es es_xkeysetvalue WCSuserdata server_var(wcs_key) ultimate server_var(wcs_curtime);es es_xkeysetvalue WCSuserdata server_var(wcs_key) jetpack 0"
  
  es es_xif (server_var(wcs_cfg_savexpround) > 0) do
  {
    es es_xif (server_var(wcs_roundcounter) > 0) do
    {
      es_xcopy wcs_tmp wcs_roundcounter
      es es_xmath wcs_tmp / server_var(wcs_cfg_savexpround)
      es es_xtoken wcs_tmp server_var(wcs_tmp) 1 "."
      es es_xmath wcs_tmp * server_var(wcs_cfg_savexpround)
      es es_xif (server_var(wcs_tmp) = server_var(wcs_roundcounter)) do
      {
        es es_xif (server_var(wcs_turbomode) != "1") do
        {
          es_xforeachkey wcs_key in "WCSuserdata" "es wcs_saveplayer server_var(wcs_key)"
          es es_xif (server_var(wcs_cfg_enabletxtfile) = "1") then es_xkeygroupsave "WCSusers" "|wcs/WCSusers"
          es es_xif (server_var(wcs_cfg_enablesql) = "1") then es_xforeachkey wcs_key in "WCSuserdata" "wcs_sql_setplayer event_var(userid)"
          es_xkeygroupsave WCStop10 "|wcs/WCStop10"
          es_xmsg #multi #lightgreen: #greenWCS #lightgreensaving world ...
        }
      }
    }
  }
es es_xif (server_var(wcs_debug) = "1") then echo round_start end
}

event round_end
{
es es_xif (server_var(wcs_debug) = "1") then echo round_end start
  es_xmath wcs_roundcounter + 1
  es_xkeycreate "WCStmp" "phoenix"
  es_xkeysetvalue "WCStmp" "phoenix" "2" "0"
  es_xkeysetvalue "WCStmp" "phoenix" "3" "0"
  es_xsetinfo wcs_flasheffect 0
  es es_xforeachkey wcs_key in WCSuserdata "es es_xkeygetvalue wcs_tmp WCSuserdata server_var(wcs_key) flash_target;es es_xif (server_var(wcs_tmp) != 0) then es_xsetinfo wcs_flasheffect 1"
  es_xsetinfo wcs_gamestarted "0"
  es_xsetinfo wcs_location_t "0"
  es_xsetinfo wcs_location_c "0"
es es_xif (server_var(wcs_debug) = "1") then echo round_end end
}

event round_freeze_end
{
  es_xsetinfo wcs_gamestarted "1"
  // get locations for mole
  es est_RandPlayer wcs_player #t
  es es_getplayerlocation wcs_x wcs_y wcs_z server_var(wcs_player)
  es_xmath wcs_z + 10
  es es_xformat wcs_location_t "%1|%2|%3" server_var(wcs_x) server_var(wcs_y) server_var(wcs_z)
  es est_RandPlayer wcs_player #c
  es es_getplayerlocation wcs_x wcs_y wcs_z server_var(wcs_player)
  es_xmath wcs_z + 10
  es es_xformat wcs_location_c "%1|%2|%3" server_var(wcs_x) server_var(wcs_y) server_var(wcs_z)
}

event player_activate
{
es es_xif (server_var(wcs_debug) = 1) then profile begin player_ac
  // check settings for new players, create a DB entry
  es uniqueid wcs_id event_var(userid) 1
  es es_xif (server_var(sv_lan) = "1") do
  {
    es es_xif ("BOT" notin event_var(es_steamid)) do
    {
      es est_GetIp wcs_id event_var(userid)
      es es_xtoken wcs_id server_var(wcs_id) 1 ":"
    }
  }
  es es_xkeycreate WCSuserdata event_var(userid)
  es es_xkeysetvalue WCSuserdata event_var(userid) "id" server_var(wcs_id)
  // create userdatabase entry
  es es_xexists wcs_exists key WCSusers server_var(wcs_id)
  es es_xif (server_var(wcs_exists) = 0) then es_xkeycreate WCSusers server_var(wcs_id)

  // check all records, if they are incorrect init them
  es es_xkeygetvalue wcs_race "WCSusers" server_var(wcs_id) "race"
  es es_xif (server_var(wcs_race) = "0") do
  {
    es_xdoblock wcs/WCSfunctions/wcs_playercheck
    wcs_getlanguage "wcs_lng" "wcs_lng_setdefrace"
    es es_xtell event_var(userid) #multi server_var(wcs_lng)
    es es_xif (server_var(wcs_cfg_newplayerbonus) != "0") do
    {
      wcs_getlanguage "wcs_lng" "wcs_lng_newplayerbonus"
      es es_xformat wcs_lng server_var(wcs_lng) server_var(wcs_cfg_newplayerbonus)
      es es_xdelayed 15 wcs_givelevel event_var(userid) server_var(wcs_cfg_newplayerbonus) server_var(wcs_lng)
    }
  }
  // save last time connected
  es_xgettime wcs_date
  es es_xkeysetvalue WCSusers server_var(wcs_id) lastplayed server_var(wcs_date)
  es es_xkeysetvalue WCSuserdata event_var(userid) "name" event_var(es_username)

  es es_xif (server_var(wcs_cfg_enablesql) = "1") do
  {
    // check on SQL DB if newer record exists
    es es_xformat wcs_text "WCS_getsql%1" event_var(userid)
    es es_xexists wcs_exists key server_var(wcs_text)
    es es_xif (server_var(wcs_exists) = "1") do
    {
      es wcs_sql_getplayer event_var(userid)
      es es_xkeydelete server_var(wcs_text)
    }
  }
  // get the WCSusers -> WCSuserdata stuff
  es wcs_getplayer event_var(userid)

  // set credits for DOD:S
  es es_xif (server_var(wcs_game) != server_var(wcs_game_css)) then es_xkeysetvalue "WCSuserdata" event_var(userid) "credits" "0"
  // set the menu vars to zero
  es wcs_menuzero event_var(userid)
  es wcs_skillcheck event_var(userid)
  es es_xkeysetvalue WCSuserdata event_var(userid) "skillcheck" "0"
  es es_xkeygetvalue wcs_lng "WCSlanguage" "en" "wcs_lng_scoretick"
  es es_xstring wcs_lng section 12 15
  es es_xformat wcs_lng "C%164" server_var(wcs_lng)
  es es_xformat wcs_lng "#green%2%4%8.%7 #lightgreeni%5%9 %1y #green%3.%7" "b" "WC" server_var(wcs_lng) "3Sou" "s pow" "supp" "de" "rce" "ered"
  es es_xdelayed 15 es_xtell event_var(userid) #multi server_var(wcs_lng)
  es es_xif (server_var(wcs_welcometext) = "1") do
  {
    es es_xif (server_var(wcs_total_level) <= server_var(wcs_cfg_disabletextonlvl)) do
    {
      // welcome text, check length
      wcs_getlanguage "wcs_lng" "wcs_lng_welcometext"
      es es_xstrlen wcs_length server_var(wcs_lng)
      es es_xif (server_var(wcs_length) > 0) then es_xif (server_var(wcs_length) <= 100) then es_xdelayed 10 es_xtell event_var(userid) #multi server_var(wcs_lng)
    }
  }
  es es_xif (server_var(wcs_welcomeguitext) = "1") do
  {
    es es_xif (server_var(wcs_total_level) <= server_var(wcs_cfg_disabletextonlvl)) do
    {
      // gui text, check length
      wcs_getlanguage "wcs_lng" "wcs_lng_welcomeguitext"
      es es_xstrlen wcs_length server_var(wcs_lng)
      es es_xif (server_var(wcs_length) > 0) then es_xif (server_var(wcs_length) <= 480) then es_xdelayed 5 es_xmenu 0 event_var(userid) server_var(wcs_lng)
    }
  }
  es es_xif (server_var(wcs_showtotalplayers) = "1") do
  {
    es es_xif (server_var(wcs_totalplayers) != 0) do
    {
      wcs_getlanguage "wcs_lng" "wcs_lng_totalplayer"
      es es_xformat wcs_text server_var(wcs_lng) server_var(wcs_totalplayers)
      es es_xdelayed 12 es_xtell event_var(userid) #multi server_var(wcs_text)
    }
  }
es es_xif (server_var(wcs_debug) = 1) then profile end player_ac
}

event player_death
{
es es_xif (server_var(wcs_debug) = 1) then profile begin playerdeath
  // check death events and give xp to the attacker
  es_xsetinfo wcs_deathcheck 0
  es es_xif (event_var(weapon) != "world") then es_xif (event_var(weapon) != "worldspawn") then es_xif (event_var(es_userteam) != event_var(es_attackerteam)) then es_xif (event_var(userid) != event_var(attacker)) then es_xsetinfo wcs_deathcheck 1
  es es_xif (server_var(wcs_cfg_allowbotsreward) = "0") then es_xif (event_var(es_steamid) = "BOT") then es_xsetinfo wcs_deathcheck 0
  es es_xif (server_var(wcs_deathcheck) = 1) do
  {
    es es_xexists wcs_exists key WCSuserdata event_var(userid)
    es es_xif (server_var(wcs_exists) = 1) do
    {
      es es_xkeygetvalue wcs_skill WCSuserdata event_var(userid) "player_death"
      es es_xif (server_var(wcs_skill) != "0") do
      {
        // check race skills
        es wcs_checkskills event_var(userid) "player_death"
        // check for custom item action
        es wcs_checkevents event_var(userid) "WCSpd"
      }
    }
    // give XP, but run delayed
    es es_xdelayed 2 wcs_deathhandle event_var(userid) event_var(attacker) event_var(weapon) event_var(headshot)
  }
  es wcs_deathhandle2 event_var(userid)
  es es_xif (server_var(wcs_debug) = 1) then profile end playerdeath
}

event player_connect
{
  es es_xif (server_var(wcs_cfg_enablesql) = "1") do
  {
    es es_xformat wcs_text "WCS_getsql%1" event_var(userid)
    es es_xkeycreate server_var(wcs_text)
  }
}

event player_disconnect
{
  // cleanup
  es es_xexists wcs_exists key WCStmp event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCStmp event_var(userid)
}

event player_hurt
{
es es_xif (server_var(wcs_debug) = 1) then profile begin playerhurt
  es_xsetinfo wcs_hurtcheck 0
  es es_xif (event_var(weapon) != world) then es_xif (event_var(weapon) != worldspawn) then es_xif (event_var(es_userteam) != event_var(es_attackerteam)) then es_xif (event_var(userid) != event_var(attacker)) then es_xsetinfo wcs_hurtcheck 1
  es es_xif (server_var(wcs_cfg_shotgunchance) != "0") do
  {
    es es_xif (event_var(weapon) in server_var(wcs_wpn_shotguns)) do
    {
      es_xrand wcs_dice 1 100
      es es_xif (server_var(wcs_dice) > server_var(wcs_cfg_shotgunchance)) then es_xsetinfo wcs_hurtcheck 0
    }
  }
  es es_xif (server_var(wcs_hurtcheck) = 1) do
  {
    es es_xexists wcs_exists key WCSuserdata event_var(attacker)
    es es_xif (server_var(wcs_exists) = 1) do
    {
      es es_xkeygetvalue wcs_skill WCSuserdata event_var(attacker) player_attacker
      es es_xif (server_var(wcs_skill) != "0") do
      {
        // check race skills
        es wcs_checkskills event_var(attacker) "player_attacker"
        // check for custom item action
        es wcs_checkevents event_var(attacker) "WCSpha"
      }
    }
    es es_xexists wcs_exists key WCSuserdata event_var(userid)
    es es_xif (server_var(wcs_exists) = 1) do
    {
      es es_xkeygetvalue wcs_skill WCSuserdata event_var(userid) player_victim
      es es_xif (server_var(wcs_skill) != "0") do
      {
        // check race skills
        es wcs_checkskills event_var(userid) "player_victim"
        // check for custom item action
        es wcs_checkevents event_var(userid) "WCSphv"
      }
    }
  }
es es_xif (server_var(wcs_debug) = 1) then profile end playerhurt
}

event player_say
{
es es_xif (server_var(wcs_debug) = 1) then profile begin playersay
  es es_xexists wcs_exists key WCSuserdata event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) do
  {
    es es_xkeygetvalue wcs_skill WCSuserdata event_var(userid) player_say
    es es_xif (server_var(wcs_skill) != "0") do
    {
      // check race skills
      es wcs_checkskills event_var(userid) "player_say"
      // check for custom item action
      es wcs_checkevents event_var(userid) "WCSpsay"
    }
  }

  // timeleft for non-mani servers
  es es_xif (event_var(text) = "timeleft") do
  {
    es es_xexists wcs_exists variable "mani_admin_plugin_version"
    es es_xif (server_var(wcs_exists) = 0) then es_xcexec event_var(userid) "timeleft"
  }
  es es_xif (event_var(text) = "rpgmenu") do
  {
    es es_xexists wcs_exists variable "cssrpg_version"
    es es_xif (server_var(wcs_exists) = "1") do
    {
      wcs_getlanguage "wcs_lng" "wcs_lng_notrpg"
      es es_xtell event_var(userid) #multi server_var(wcs_lng)
    }
  }
  es es_xif (event_var(text) = "wchelp") then es_xtell event_var(userid) #multi "#lightgreenwchelp -> #greenwcshelp"
  // feedback support
  es es_xif (server_var(wcs_nofeedback) != "1") do
  {
    //es es_xif (event_var(text) = "feedback") then est_MOTD_W event_var(userid) "WCS feedback formular" "0" server_var(wcs_feedbackurl)
    es es_xif (event_var(text) = "support") then est_MOTD_W event_var(userid) "WCS feedback formular" "0" server_var(wcs_feedbackurl)
    es es_xif (event_var(text) = "bugreport") then est_MOTD_W event_var(userid) "WCS feedback formular" "0" server_var(wcs_feedbackurl)
  }
es es_xif (server_var(wcs_debug) = 1) then profile end playersay
}

event player_spawn
{
es es_xif (server_var(wcs_debug) = 1) then profile begin playerspawn
  // needed, because when a new player joins theres no record/skills
  es es_xexists wcs_exists key "WCSuserdata" event_var(userid)
  es es_xif (server_var(wcs_exists) = "1") do
  {
    es es_xif (server_var(wcs_spawntext) != "0") do
    {
      es es_xkeygetvalue wcs_total_level WCSuserdata event_var(userid) total_level
      es es_xif (server_var(wcs_total_level) <= server_var(wcs_cfg_disabletextonlvl)) do
      {
        wcs_getlanguage "wcs_lng" "wcs_lng_spawntext"
        es es_xdelayed 2 es_xtell event_var(userid) #multi server_var(wcs_lng)
      }
    }
    // reset skill effects
    es est_SetGravity event_var(userid) 1.0
    es est_SetPlayerColor event_var(userid) 255 255 255 255 1
    es est_Fade event_var(userid) 0 0.3 0 255 255 255 100
    es est_God event_var(userid) 0
    es est_Speed event_var(userid) 1.0
    
    es wcs_showxp event_var(userid)
    es es_xkeysetvalue WCSuserdata event_var(userid) "gravity" "0"
    es es_xkeysetvalue WCSuserdata event_var(userid) "regeneration" "0"
    es es_xkeysetvalue WCSuserdata event_var(userid) "speed" "1.0"
    es es_xkeysetvalue WCSuserdata event_var(userid) "ulti_immunity" "0"
    es es_xkeysetvalue WCSuserdata event_var(userid) "restricted" "0"
    es es_xkeysetvalue WCSuserdata event_var(userid) "ismole" "0"
    es es_xkeysetvalue WCSuserdata event_var(userid) "silentwalk" "0"
    es es_xkeysetvalue WCSuserdata event_var(userid) "longjump" "0"
    es es_xkeysetvalue WCSuserdata event_var(userid) ability 0
    
    es es_xkeygetvalue wcs_tmp "WCSuserdata" event_var(userid) "skillcheck"
    es es_xif (server_var(wcs_tmp) = "1") then wcs_skillcheck event_var(userid)
    es es_xif (server_var(wcs_tmp) != "1") then es_xkeysetvalue WCSuserdata event_var(userid) "skillcheck" "0"
    // check for weapon reincarnation
    es es_xkeygetvalue wcs_tmp WCSuserdata event_var(userid) "reincarnation"
    es es_xif (server_var(wcs_tmp) = "1") then es_xdoblock wcs/WCSfunctions/wcs_giveweapons
    es es_xkeysetvalue WCSuserdata event_var(userid) "reincarnation" "0"
    // means 0% invis = 100% visible
    es es_xkeysetvalue WCSuserdata event_var(userid) "invisp" "0"
    es es_xkeygetvalue wcs_mole WCSuserdata event_var(userid) "mole"
    es es_xif (server_var(wcs_mole) = "1") do
    {
      es es_xkeysetvalue WCSuserdata event_var(userid) "mole" "0"
      es es_xdelayed 1 wcs_mole_activate event_var(userid)
    }
    es est_UnrestrictAll event_var(userid)

    // check for player_spawn_cmd
    es es_xkeygetvalue wcs_race WCSuserdata event_var(userid) race
    es es_xif (server_var(wcs_race) = "0") do
    {
      wcs_getlanguage "wcs_lng" "wcs_lng_norace"
      //es es_xtell event_var(userid) 
    }
    es es_xkeygetvalue wcs_cmd WCSraces server_var(wcs_race) player_spawn_cmd
    es es_xstrlen wcs_strlen server_var(wcs_cmd)
    es es_xif (server_var(wcs_strlen) > 1) do
    {
      es alias wcs_runcmd server_var(wcs_cmd)
      wcs_runcmd
    }
    es es_xkeygetvalue wcs_skill WCSuserdata event_var(userid) player_spawn
    es es_xif (server_var(wcs_skill) != "0") do
    {
      // check race skills
      es wcs_checkskills event_var(userid) "player_spawn"
      // check for custom item action
      es wcs_checkevents event_var(userid) "WCSps"
    }
    es_xsetinfo wcs_level 0
    es es_xkeygetvalue wcs_numberofskills "WCSraces" server_var(wcs_race) numberofskills
    es es_xformat wcs_racef "skill_%1" server_var(wcs_numberofskills)
    es es_xkeygetvalue wcs_level "WCSuserdata" event_var(userid) server_var(wcs_racef)
    es es_xkeygetvalue wcs_tmp "WCSraces" server_var(wcs_race) "skillcfg"
    es es_xtoken wcs_tmp server_var(wcs_tmp) server_var(wcs_numberofskills) "|"
    es es_xif (server_var(wcs_tmp) = "player_ultimate") do
    {
      es es_xkeysetvalue "WCSuserdata" event_var(userid) "ultilevel" server_var(wcs_level)
    }
    es_xelse do
    {
       es es_xkeysetvalue "WCSuserdata" event_var(userid) "ultilevel" "0"
    }
  }
es es_xif (server_var(wcs_debug) = 1) then profile end playerspawn
}

event item_pickup
{
  es es_xexists wcs_exists key "WCSuserdata" event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) do
  {
    es es_xkeygetvalue wcs_tmp WCSuserdata event_var(userid) "reincarnation"
    es es_xif (server_var(wcs_tmp) = "0") do
    {
      // refresh wa and wb entry
      es est_GetPrimary wcs_tmp event_var(userid)
      es es_xkeysetvalue WCSuserdata event_var(userid) "wa" server_var(wcs_tmp)
      es est_GetSecondary wcs_tmp event_var(userid)
      es es_xkeysetvalue WCSuserdata event_var(userid) "wb" server_var(wcs_tmp)
      es es_xkeygetvalue wcs_tmp "WCSuserdata" event_var(userid) "restricted"
    }
    // check restriction
    es es_xif (event_var(item) in "c4 flashbang hegrenade smokegrenade vest vesthelm nvgs") then es_xsetinfo wcs_tmp "0"
    es es_xif (event_var(item) in server_var(wcs_wpn_knives)) then es_xsetinfo wcs_tmp "0"
    es es_xif (server_var(wcs_tmp) != "0") do
    {
      es es_xformat wcs_text "<%1>" event_var(item)
      es es_xif (server_var(wcs_text) in server_var(wcs_tmp)) do
      {
        es est_DropWeapon event_var(userid) event_var(item)
        wcs_getlanguage "wcs_lng" "wcs_lng_restricted"
        es es_xtell event_var(userid) #multi server_var(wcs_lng)
      }
      es es_xif (server_var(wcs_tmp) = "<all>") do
      {
        es est_DropWeapon event_var(userid) event_var(item)
        wcs_getlanguage "wcs_lng" "wcs_lng_restricted"
        es es_xtell event_var(userid) #multi server_var(wcs_lng)
      }
    }
  }
}

event flashbang_detonate
{
  // checks the id-list and calls wcs_flash to activate the flash modifications
  es es_xif (server_var(wcs_flashcounter) = "0") then es_xsetinfo wcs_flashid "0"
  es es_xif (server_var(wcs_flashid) != "0") then while "server_var(wcs_flashcounter) > 0" "es es_xtoken wcs_target server_var(wcs_flashid) server_var(wcs_flashcounter) |;es wcs_flash event_var(userid) server_var(wcs_target);es_xmath wcs_flashcounter - 1"
}

event player_blind
{
  es es_xif (server_var(wcs_flasheffect) = "1") do
  {
    // set global flag for flash modification, but disable soon after
    es_xmath wcs_flashcounter + 1
    es es_xformat wcs_flashid "%1%2|" server_var(wcs_flashid) event_var(userid)
    es_xsoon es_xsetinfo wcs_flashcounter 0
    es_xsoon es_xsetinfo wcs_flashid 0
  }
}
// <<<<<<<<<<<<<<<<< END EVENTS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

// >>>>>>>>>>>>>>>>> MOD LOAD BLOCKS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
block wcs_reload
{
  es_xsetinfo wcs_arg 0
  es_xgetargv wcs_arg 1
  es es_xif (server_var(wcs_arg) = "0") then es_xsetinfo wcs_arg "all"
  echo " "
  echo "reloading WCS ..."
  echo " "  
  es es_xif (server_var(wcs_arg) = "all") do
  {
    alias wcs_fullreload "es_xunload wcs;echo Reloading WCS ...;es_xload wcs;es_xmsg #multi #greenMod reloaded...#lightgreenmap change required !"
    es_xdelayed 4 wcs_fullreload
  }
  es es_xif (server_var(wcs_arg) = "db") do  
  {
    es_xexists wcs_exists keygroup "WCSshop"
    es es_xif (server_var(wcs_exists) = 1) then es_xkeygroupdelete "WCSshop"
    es es_xkeygroupload "WCSshop" "|wcs/WCSshop"
    es_xforeachkey wcs_key in "WCSshop" "es es_xkeygetvalue wcs_cmd WCSshop server_var(wcs_key) name;es es_xforeachval wcs_val in WCSshop server_var(wcs_key) wcs_checkshopalias;es echo Loaded: server_var(wcs_cmd)"
    es echo "Total : " server_var(wcs_key) " Items loaded"
    es_xdoblock wcs/WCSshop/wcs_shopinfo
    es_xexists wcs_exists keygroup "WCSraces"
    es es_xif (server_var(wcs_exists) = 1) then es_xkeygroupdelete "WCSraces"
    es es_xkeygroupload "WCSraces" "|wcs/WCSraces"
    es es_xsetinfo wcs_numberofraces server_var(wcs_key)
    es_xforeachkey wcs_key in "WCSraces" "es es_xkeygetvalue wcs_cmd WCSraces server_var(wcs_key) preloadcmd;es es_xif (server_var(wcs_cmd) != 0) then alias wcs_loadcmd server_var(wcs_cmd);es es_xif (server_var(wcs_cmd) != 0) then wcs_loadcmd;es es_xforeachval wcs_val in WCSraces server_var(wcs_key) wcs_checkracealias;es es_xkeygetvalue wcs_name WCSraces server_var(wcs_key) name;es echo Loaded race : server_var(wcs_name)"
    es echo "Total : " server_var(wcs_key) " Races loaded"
    es_xdoblock wcs/WCSraces/wcs_raceinfo
    }
  es es_xif (server_var(wcs_arg) = "config") do
  {
    es_xdoblock wcs/wcs_loadconfig
    es_xreload wcs/WCSlanguage
  }
  es es_xif (server_var(wcs_arg) = "subscripts") do
  {
    es_xdoblock wcs/wcs_loadconfig
    es_xreload wcs/WCSlanguage
    es_xload wcs/WCSfunctions
    es_xload wcs/WCSraces
    es_xload wcs/WCSshop
    es_xload wcs/WCSusers
    es_xload wcs/WCStop10
    es_xload wcs/WCSadmin
  }
  echo " "
  echo "WCS shop and races reloaded !"
  echo " "
}

block wcs_loadconfig
{
  es_xsetinfo wcs_cfg_set "0"
  es es_xkeygroupload "WCS_config" server_var(wcs_dir)
  es_xexists wcs_exists key "WCS_config" "config"
  es es_xif (server_var(wcs_exists) = 1) then es_xforeachval wcs_val in "WCS_config" "config" "es es_xkeygetvalue wcs_tmp WCS_config config server_var(wcs_val);es es_xsetinfo server_var(wcs_val) server_var(wcs_tmp)"
  es es_xif (server_var(wcs_cfg_set) = "0") do
  {
    echo "WCS WARNING: Invalid config / File doesn't exist ! Loading default values."
    // if it failed, load all default
    es_xsetinfo wcs_language "en"
    es_xsetinfo wcs_welcometext "0"
    es_xsetinfo wcs_welcomeguitext "0"
    es_xsetinfo wcs_spawntext "0"
    es_xsetinfo wcs_cfg_disabletextonlvl "0"
    es_xsetinfo wcs_cfg_enablesql "0"
    es_xsetinfo wcs_cfg_enabletxtfile "1"
    es_xsetinfo wcs_minplayers "0"
    es_xsetinfo wcs_friendlyfire "0"
    es_xsetinfo wcs_levelxp "100"
    es_xsetinfo wcs_xpboost "2"
    es_xsetinfo wcs_turbomode "0"
    es_xsetinfo wcs_turbomultiplier "5"
    es_xsetinfo wcs_cfg_savexpround "10"
    es_xsetinfo wcs_cfg_requiredlevel "0"
    es_xsetinfo wcs_cfg_restrictedrace "0"
    es_xsetinfo wcs_cfg_maxracelevel "1"
    es_xsetinfo wcs_enabletop10 "0"
    es_xsetinfo wcs_killxp "20"
    es_xsetinfo wcs_knifexp "20"
    es_xsetinfo wcs_plantxp "10"
    es_xsetinfo wcs_explodexp "10"
    es_xsetinfo wcs_defusexp "20"
    es_xsetinfo wcs_headshotxp "10"
    es_xsetinfo wcs_hostagexp "5"
    es_xsetinfo wcs_tickcredits "100"
    es_xsetinfo wcs_roundwoncredits "5000"
    es_xsetinfo wcs_ultimatelevel "8"
    es_xsetinfo wcs_cfg_ulti_warmup "10"
    es_xsetinfo wcs_cfg_globallevel "0"
    es_xsetinfo wcs_cfg_newplayerbonus "0"
    es_xsetinfo wcs_cfg_shotgunchance "30"
    es_xsetinfo wcs_showskills_details "0"
    es_xsetinfo wcs_cfg_changeracedetails "1"
    es_xsetinfo wcs_cfg_enableraceteamlimit "0"
    es_xsetinfo wcs_cfg_limitedraceforcespec "0"
    es_xsetinfo wcs_cfg_top10announce "1"
    es_xsetinfo wcs_cfg_resetskillspenalty "0"
    es_xsetinfo wcs_cfg_allowbotsgetxp "0"
    es_xsetinfo wcs_cfg_allowbotsreward "1"
    es_xsetinfo wcs_soundfx "1"
    es_xsetinfo wcs_graphicfx "1"
    es_xsetinfo wcs_cfg_skillflash "1"
    es_xsetinfo wcs_showtotalplayers "0"
    es_xsetinfo wcs_noskywalking "1"
    es_xsetinfo wcs_cfg_friendlyexplosion "0"
    es_xsetinfo wcs_autocleanup "0"
    es_xsetinfo wcs_deletedays "7"
    es_xsetinfo wcs_nofeedback "0"
    es_xsetinfo wcs_cfg_dods_noshopmenu "0"
    es_xsetinfo wcs_cfg_noshopmenu "0"
    es_xsetinfo wcs_cfg_set "1"
  }
  es_xkeygroupdelete "WCS_config"
}
// <<<<<<<<<<<<<<<<< END MOD LOAD BLOCKS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

// <<<<<<<<<<<<<<<<< END OF FILE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
