Raised This Month: $32 Target: $400
 8% 

[HELP] Maps.ini (like amxmod 2006.3)


  
 
 
Thread Tools Display Modes
Author Message
H(x)m3m do S@c0
Member
Join Date: Feb 2007
Old 04-10-2007 , 09:20   [HELP] Maps.ini (like amxmod 2006.3)
#1

Hi,

I need to know if its possible to have a maps.ini like in amxmod2006.3
Like this when votemap appears we can see maps type.
It works in amxmod2006.3, but not seams to work in amxmodx 1.76d

Like this:

Code:
aim_ak-colt    "Ak-Colt - Aim/Skill"
cspaintball1    "Paintball - Aim/Skill"
cs_neighbours    "Neighbours - Aim/Skill"
aim_aztec2003    "Aztec2003 - Aim/Skill"
ka_colosseum    "Colosseum - Knives/Arena"
de_minidust2    "MiniDust2 - Aim/Skill/Bomb/Defuse"
de_dust2_long    "Dust2 Long - Aim/Skill/Bomb/Defuse"
de_winterdust    "Winterdust - Bomb/Defuse"     
de_aztec_cz     "Aztec - Bomb/Defuse"
awp_map         "Awp Map - Aim/Skill"
de_cbble_cz     "Cbble - Bomb/Defuse"
de_chateau_cz   "Chateau - Bomb/Defuse"
de_dust_cz      "Dust - Bomb/Defuse"
de_dust2_cz     "Dust II - Bomb/Defuse"
duel_sniperarenax  "Sniper ArenaX - Aim/Skill"
de_inferno_cz   "Inferno - Bomb/Defuse"
cs_blitztowers    "Blitztowers - Aim/Skill" 
de_nuke      "Nuke - Bomb/Defuse"
de_piranesi_cz  "Piranesi - Bomb/Defuse"
de_prodigy_cz   "Prodigy - Bomb/Defuse"
de_storm_cz     "Storm - Bomb/Defuse"
de_survivor  "Survivor - Bomb/Defuse"
de_torn_cz      "Torn - Bomb/Defuse"
de_train     "Trainyard - Bomb/Defuse"
de_vertigo   "Vertigo - Bomb/Defuse"
cs_747       "747 Hijack - Hostage Rescue"
cs_assault   "Assault - Hostage Rescue"
cs_backalley "Alleyway - Hostage Rescue"
cs_estate    "Zaphod's Estate - Hostage Rescue"
cs_havana_cz    "Havana - Hostage Rescue"
cs_italy_cz     "Italy - Hostage Rescue"
cs_militia_cz   "Militia - Hostage Rescue"
cs_office_cz    "The Office Complex - Hostage Rescue"
cs_siege     "Canyon Siege - Hostage Rescue"
as_oilrig    "OilRig - Assassination"
de_airstrip_cz  "Airstrip - Bomb/Defuse"
de_stadium_cz    "Stadium - Bomb/Defuse"
de_tides_cz    "Tides - Bomb/Defuse"
de_fastline_cz    "Fastline - Bomb/Defuse"
de_chateau_cz    "Chateau - Bomb/Defuse"
cs_downed_cz    "Downed - Hostage Rescue"
This is not possible in amxmodx because mapsmenu.sma is diferent from mapsmenu.sma from amxmo2006.3
So here is the code from mapsmenu.sma (amxmod2006.3)

Code:
/*
 * Copyright (c) 2002-2006 - Aleksander Naszko, Julien Laurent
 *
 *    This file is part of AMX Mod.
 *
 *    AMX Mod is free software; you can redistribute it and/or modify it
 *    under the terms of the GNU General Public License as published by the
 *    Free Software Foundation; either version 2 of the License, or (at
 *    your option) any later version.
 *
 *    AMX Mod is distributed in the hope that it will be useful, but
 *    WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with AMX Mod; if not, write to the Free Software Foundation,
 *    Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *    In addition, as a special exception, the author gives permission to
 *    link the code of this program with the Half-Life Game Engine ("HL
 *    Engine") and Modified Game Libraries ("MODs") developed by Valve,
 *    L.L.C ("Valve").  You must obey the GNU General Public License in all
 *    respects for all of the code used other than the HL Engine and MODs
 *    from Valve.  If you modify this file, you may extend this exception
 *    to your version of the file, but you are not obligated to do so.  If
 *    you do not wish to do so, delete this exception statement from your
 *    version.
 *
 */

/*
 *
 * Content for configuration copied from ClanMod cfg. file.
 *
 * Admin commands:
 * amx_mapmenu - displays maps menu
 * amx_votemapmenu - displays votemap menu
 *
 * Example configuration in addons/amx/config/maps.ini

de_airstrip  "Airstrip - Bomb/Defuse"
de_aztec     "Aztec - Bomb/Defuse"
de_cbble     "Cobble - Bomb/Defuse"
de_chateau   "Chateau - Bomb/Defuse"
de_dust      "Dust - Bomb/Defuse"
de_dust2     "Dust II - Bomb/Defuse"
de_inferno   "Inferno - Bomb/Defuse"
de_nuke      "Nuke - Bomb/Defuse"
de_piranesi  "Piranesi - Bomb/Defuse"
de_prodigy   "Prodigy - Bomb/Defuse"
de_storm     "Storm - Bomb/Defuse"
de_survivor  "Survivor - Bomb/Defuse"
de_torn      "Torn - Bomb/Defuse"
de_train     "Trainyard - Bomb/Defuse"
de_vegas     "Vegas - Bomb/Defuse"
de_vertigo   "Vertigo - Bomb/Defuse"
cs_747       "747 Hijack - Hostage Rescue"
cs_assault   "Assault - Hostage Rescue"
cs_backalley "Alleyway - Hostage Rescue"
cs_estate    "Zaphod's Estate - Hostage Rescue"
cs_havana    "Havana - Hostage Rescue"
cs_italy     "Italy - Hostage Rescue"
cs_militia   "Militia - Hostage Rescue"
cs_office    "The Office Complex - Hostage Rescue"
cs_siege     "Canyon Siege - Hostage Rescue"
as_oilrig    "OilRig - Assassination"

 *
 */

/******************************************************************************/
// If you change one of the following settings, do not forget to recompile
// the plugin and to install the new .amx file on your server.
// You can find the list of admin flags in the amx/examples/include/amxconst.inc file.

#define FLAG_AMX_MAPMENU      ADMIN_MAP
#define FLAG_AMX_VOTEMAPMENU  ADMIN_VOTE

#define MAX_MAPS 256 // maximum number of maps displayed in the map/votemap menu

/******************************************************************************/

#include <translator>
#include <amxmod>
#include <amxmisc>

#define CHECK_MENU_TIME 0.5

new g_mapName_MapMenu[MAX_MAPS][32]
new g_mapDesc_MapMenu[MAX_MAPS][32]
new g_mapsNum_MapMenu
new g_mapName_VoteMapMenu[MAX_MAPS][32]
new g_mapDesc_VoteMapMenu[MAX_MAPS][32]
new g_mapsNum_VoteMapMenu
new g_menuPosition[33]
new g_logFile[16]

new g_voteCount[5]

new g_resultAck[] = "Result accepted"
new g_resultRef[] = "Result refused"

new g_voteSelected[33][4]
new g_voteSelectedNum[33]

new g_coloredMenus
new g_maxplayers

new g_yesNoVote
new g_choosed
new g_voteCaller
new bool:g_hasVoted[33]
new g_menukeys[33]
new g_menumsg[33][256]
new g_menutitle[32]

new menuid_whichmap, menuid_changemap

public plugin_init() {
  if(cvar_exists("amxmodx_version")) load_module("error")
  load_translations("mapsmenu")
  register_plugin(_T("Maps Menu"),AMX_VERSION,"AMX Team")
  register_clcmd("amx_mapmenu","cmdMapsMenu",FLAG_AMX_MAPMENU,_T("- displays changelevel menu"))
  register_clcmd("amx_votemapmenu","cmdVoteMapMenu",FLAG_AMX_VOTEMAPMENU,_T("- displays votemap menu"))
  register_cvar("amx_mapmenu_mapsloc","0")
  register_cvar("amx_votemapmenu_mapsloc","0")
  register_menucmd(register_menuid("Changelevel Menu"),1023,"actionMapsMenu")
  menuid_whichmap = register_menuid("Which map do you want?")
  menuid_changemap = register_menuid("Change map to")
  register_menucmd(menuid_whichmap,783,"voteCount")
  register_menucmd(menuid_changemap,515,"voteCount")
  register_menucmd(register_menuid("Votemap Menu"),1023,"actionVoteMapMenu")
  register_menucmd(register_menuid("The winner: "),3,"actionResult")

  get_logfile(g_logFile, 15)
  g_coloredMenus = colored_menus()
  g_maxplayers = get_maxplayers()
}

public plugin_cfg() {
  new filename[64]
  
  new mapsloc = get_cvar_num("amx_mapmenu_mapsloc")
  //MAPMENU
  if(mapsloc == 0) {
    build_path(filename, 63, "$configdir/maps.ini")
    if(loadSettings_MapMenu(filename)) {
      log_to_file(g_logFile,_T("Maps Menu: maps.ini succesfully loaded. (amx_mapmenu_mapsloc)"))
    }
    else {
      log_to_file(g_logFile,_T("Maps Menu: Failed to load maps.ini or no maps inside the file. Trying to load mapcycle. (amx_mapmenu_mapsloc)"))
      get_cvar_string("mapcyclefile", filename, 63)
      if(loadSettings_MapMenu(filename)) {
        log_to_file(g_logFile,_T("Maps Menu: mapcycle succesfully loaded. (amx_mapmenu_mapsloc)"))
      }
      else {
        log_to_file(g_logFile,_T("Maps Menu: Failed to load mapcycle or no maps inside the file. Trying to load maps folder. (amx_mapmenu_mapsloc)"))
        if(loadMapsFolder_MapMenu()) {
          log_to_file(g_logFile,_T("Maps Menu: maps folder succesfully loaded. (amx_mapmenu_mapsloc)"))
        }
        else {
          log_to_file(g_logFile,_T("Maps Menu: Failed to load maps folder. No maps loaded. (amx_mapmenu_mapsloc)"))
        }
      }
    }
  }
  else if(mapsloc == 1) {
    get_cvar_string("mapcyclefile", filename, 63)
    if(loadSettings_MapMenu(filename)) {
      log_to_file(g_logFile,_T("Maps Menu: mapcycle succesfully loaded. (amx_mapmenu_mapsloc)"))
    }
    else {
      log_to_file(g_logFile,_T("Maps Menu: Failed to load mapcycle or no maps inside the file. Trying to load maps folder. (amx_mapmenu_mapsloc)"))
      if(loadMapsFolder_MapMenu()) {
        log_to_file(g_logFile,_T("Maps Menu: maps folder succesfully loaded. (amx_mapmenu_mapsloc)"))
      }
      else {
        log_to_file(g_logFile,_T("Maps Menu: Failed to load maps folder. No maps loaded. (amx_mapmenu_mapsloc)"))
      }
    }
  }
  else if(mapsloc == 2) {
    set_cvar_num("amx_nominfromfile", 0)
    if(loadMapsFolder_MapMenu()) {
      log_to_file(g_logFile,_T("Maps Menu: maps folder succesfully loaded. (amx_mapmenu_mapsloc)"))
    }
    else {
      log_to_file(g_logFile,_T("Maps Menu: Failed to load maps folder. No maps loaded. (amx_mapmenu_mapsloc)"))
    }
  }
  //VOTEMAPMENU
  if(mapsloc == 0) {
    filename[0] = '^0'
    build_path(filename, 63, "$configdir/maps.ini")
    if(loadSettings_VoteMapMenu(filename)) {
      log_to_file(g_logFile,_T("Maps Menu: maps.ini succesfully loaded. (amx_votemapmenu_mapsloc)"))
    }
    else {
      log_to_file(g_logFile,_T("Maps Menu: Failed to load maps.ini or no maps inside the file. Trying to load mapcycle. (amx_votemapmenu_mapsloc)"))
      get_cvar_string("mapcyclefile", filename, 63)
      if(loadSettings_VoteMapMenu(filename)) {
        log_to_file(g_logFile,_T("Maps Menu: mapcycle succesfully loaded. (amx_votemapmenu_mapsloc)"))
      }
      else {
        log_to_file(g_logFile,_T("Maps Menu: Failed to load mapcycle or no maps inside the file. Trying to load maps folder. (amx_votemapmenu_mapsloc)"))
        if(loadMapsFolder_VoteMapMenu()) {
          log_to_file(g_logFile,_T("Maps Menu: maps folder succesfully loaded. (amx_votemapmenu_mapsloc)"))
        }
        else {
          log_to_file(g_logFile,_T("Maps Menu: Failed to load maps folder. No maps loaded. (amx_votemapmenu_mapsloc)"))
        }
      }
    }
  }
  else if(mapsloc == 1) {
    get_cvar_string("mapcyclefile", filename, 63)
    if(loadSettings_VoteMapMenu(filename)) {
      log_to_file(g_logFile,_T("Maps Menu: mapcycle succesfully loaded. (amx_votemapmenu_mapsloc)"))
    }
    else {
      log_to_file(g_logFile,_T("Maps Menu: Failed to load mapcycle or no maps inside the file. Trying to load maps folder. (amx_votemapmenu_mapsloc)"))
      if(loadMapsFolder_VoteMapMenu()) {
        log_to_file(g_logFile,_T("Maps Menu: maps folder succesfully loaded. (amx_votemapmenu_mapsloc)"))
      }
      else {
        log_to_file(g_logFile,_T("Maps Menu: Failed to load maps folder. No maps loaded. (amx_votemapmenu_mapsloc)"))
      }
    }
  }
  else if(mapsloc == 2) {
    set_cvar_num("amx_nominfromfile", 0)
    if(loadMapsFolder_VoteMapMenu()) {
      log_to_file(g_logFile,_T("Maps Menu: maps folder succesfully loaded. (amx_votemapmenu_mapsloc)"))
    }
    else {
      log_to_file(g_logFile,_T("Maps Menu: Failed to load maps folder. No maps loaded. (amx_votemapmenu_mapsloc)"))
    }
  }
}

public check_menu(param[]) {
  new iter = param[0]
  new Float:vote_time = float(param[2]) + 2.0 - (iter * CHECK_MENU_TIME)
  new menutime = floatround(vote_time, floatround_floor)
  if(menutime > 0) {
    new players[32], numplayers, player
    new menuid, keys
    get_players(players, numplayers, "c")
    for(numplayers--; numplayers >= 0; numplayers--) {
      player = players[numplayers]
      if(g_hasVoted[player]) continue
      get_user_menu(player, menuid, keys)
      if(keys == 0 || menuid < 0) {
        show_menu(player, g_menukeys[player], g_menumsg[player], menutime, g_menutitle)
      }
      else {
        if(menuid != param[1]) {
          if(menutime <= 6) {
            show_menu(player, g_menukeys[player], g_menumsg[player], menutime, g_menutitle)
          }
        }
        else if(player == g_voteCaller) {
          show_menu(player, g_menukeys[player], g_menumsg[player], menutime, g_menutitle)
        }
      }
    }
    ++param[0]
    set_task(CHECK_MENU_TIME, "check_menu", 1467852, param, 3)
  }
}

public autoRefuse() {
  log_to_file(g_logFile,"Vote: %s",g_resultRef)
  client_print(0, print_chat, _T(g_resultRef))
}

public actionResult(id,key) {
  remove_task(4545454)
  switch(key) {
    case 0: {
      new modName[8]
      get_modname(modName, 7)
      if(!equal(modName, "zp")) {
        message_begin(MSG_ALL, SVC_INTERMISSION)
        message_end()
      }
      set_task(2.0, "delayedChange", 33119977, g_mapName_VoteMapMenu[g_choosed], strlen(g_mapName_VoteMapMenu[g_choosed]) + 1)
      log_to_file(g_logFile,"Vote: %s",g_resultAck)
      client_print(0, print_chat, _T(g_resultAck))
    }
    case 1:
      autoRefuse()
  }
  return PLUGIN_HANDLED
}

new g_voteSuccess[] = "Voting successful. Map will be changed to"
new g_VoteFailed[] = "Voting failed"

public checkVotes(id) {
  remove_task(1467852)
  for(new i = 1; i <= g_maxplayers; ++i) {
    g_hasVoted[i] = true
  }

  id -= 34567
  new num, ppl[32], a = 0
  get_players(ppl, num, "c")
  if(num == 0) num = 1
  g_choosed = -1
  for(new i = 0; i < g_voteSelectedNum[id]; ++i) {
    if(g_voteCount[a] < g_voteCount[i]) {
      a = i
    }
  }

  new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3] + g_voteCount[4]
  new iRatio = votesNum ? floatround(get_cvar_float("amx_votemap_ratio") * float(votesNum), floatround_ceil) : 1
  new iResult = g_voteCount[a]
  
  if(iResult >= iRatio) {
    g_choosed = g_voteSelected[id][a]
    client_print(0, print_chat, "%s %s", _T(g_voteSuccess), g_mapName_VoteMapMenu[g_choosed])
    log_to_file(g_logFile,"Vote: %s %s",g_voteSuccess,g_mapName_VoteMapMenu[g_choosed])
  }
  if(g_choosed != -1) {
    if(is_user_connected(id)) {
      new menuBody[512]
      new len = format(menuBody, 511, g_coloredMenus ? _T("\yThe winner: \w%s^n^n",id) : _T("The winner: %s^n^n",id), g_mapName_VoteMapMenu[g_choosed])
      len += copy(menuBody[len], 511 - len, g_coloredMenus ? _T("\yDo you want to continue?^n\w",id) : _T("Do you want to continue?^n",id))
      copy(menuBody[len], 511 - len, _T("^n1. Yes^n2. No",id))
      show_menu(id, 0x03, menuBody, 10, "The winner: ")
      set_task(10.0, "autoRefuse", 4545454)
    }
    else {
      new modName[8]
      get_modname(modName, 7)
      if(!equal(modName, "zp")) {
        message_begin(MSG_ALL, SVC_INTERMISSION)
        message_end()
      }
      set_task(2.0, "delayedChange", 33119988, g_mapName_VoteMapMenu[g_choosed], strlen(g_mapName_VoteMapMenu[g_choosed]) + 1)
    }
  }
  else {
    client_print(0, print_chat, _T(g_VoteFailed))
    log_to_file(g_logFile,"Vote: %s",g_VoteFailed)
  }
  remove_task(34567 + id)
}

public voteCount(id,key) {
  if(g_hasVoted[id]) {
    return PLUGIN_HANDLED
  }
  g_hasVoted[id] = true
  if(key == 8) {
    return PLUGIN_HANDLED
  }
  if(key == 9) {
    client_print(0, print_chat, _T("Voting has been canceled"))
    remove_task(34567+id)
    remove_task(1467852)
    new menuid, keys
    for(new i = 1; i <= g_maxplayers; ++i) {
      g_hasVoted[i] = true
      if(!is_user_connected(i)) continue
      get_user_menu(i, menuid, keys)
      if(menuid == menuid_whichmap || menuid == menuid_changemap) {
        show_menu(i, 0, "NULL", 0, "NULL")
      }
    }
    set_cvar_float("amx_last_voting", get_gametime())
    log_to_file(g_logFile,"Vote: Cancel vote session")
    return PLUGIN_HANDLED
  }
  if(get_cvar_float("amx_vote_answers")) {
    new name[32]
    get_user_name(id, name, 31)
    if(g_yesNoVote)
      client_print(0, print_chat, _T("%s voted %s"), name, key ? _T("against") : _T("for"))
    else
      client_print(0, print_chat, _T("%s voted for %s"), name, g_mapName_VoteMapMenu[g_voteSelected[g_voteCaller][key]])
  }
  ++g_voteCount[key]
  return PLUGIN_HANDLED
}

isMapSelected(id,pos) {
  for(new a = 0; a < g_voteSelectedNum[id]; ++a) {
    if(g_voteSelected[id][a] == pos) {
      return 1
    }
  }
  return 0
}

displayVoteMapsMenu(id,pos) {
  if(pos < 0)
    return

  new menuBody[512], b = 0, start = pos * 7

  if(start >= g_mapsNum_VoteMapMenu) {
    start = pos = g_menuPosition[id] = 0
  }

  new len = format(menuBody, 511, g_coloredMenus ?
    _T("\yVotemap Menu\R%d/%d^n\w^n",id) : _T("Votemap Menu %d/%d^n^n",id),
    pos+1, (g_mapsNum_VoteMapMenu / 7 + (( g_mapsNum_VoteMapMenu % 7) ? 1 : 0)))

  new end = start + 7, keys = (1<<9)

  if(end > g_mapsNum_VoteMapMenu) {
    end = g_mapsNum_VoteMapMenu
  }

  for(new a = start; a < end; ++a) {
    if(g_voteSelectedNum[id] == 4 || isMapSelected(id, pos * 7 + b)) {
      ++b
      if(g_coloredMenus)
        len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_mapDesc_VoteMapMenu[a])
      else
        len += format(menuBody[len], 511-len, "#. %s^n", g_mapDesc_VoteMapMenu[a])
    }
    else {
      keys |= (1<<b)
      len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_mapDesc_VoteMapMenu[a])
    }
  }

  if(g_voteSelectedNum[id]) {
    keys |= (1<<7)
    len += format(menuBody[len], 511-len, _T("^n8. Start Voting^n",id))
  }
  else
    len += format(menuBody[len], 511-len, g_coloredMenus ?
      _T("^n\d8. Start Voting^n\w",id) : _T("^n#. Start Voting^n",id))

  if(end != g_mapsNum_VoteMapMenu) {
    len += format(menuBody[len], 511-len, _T("^n9. More...^n0. %s^n",id), pos ? _T("Back",id) : _T("Exit",id))
    keys |= (1<<8)
  }
  else
    len += format(menuBody[len], 511-len, "^n0. %s^n", pos ? _T("Back",id) : _T("Exit",id))

  len += format(menuBody[len], 511-len, g_voteSelectedNum[id] ?
    (g_coloredMenus ? _T("^n\ySelected Maps:^n\w",id) : _T("^nSelected Maps:^n",id)) : _T("^n^n",id))

  for(new c = 0; c < 4; ++c) {
    if(c < g_voteSelectedNum[id])
      len += format(menuBody[len], 511-len, "%s^n", g_mapDesc_VoteMapMenu[g_voteSelected[id][c]])
    else
      len += format(menuBody[len], 511-len, "^n" )
  }

  show_menu(id, keys, menuBody, -1, "Votemap Menu")
}

public cmdVoteMapMenu(id,level,cid) {
  if(!cmd_access(id,level,cid,1))
    return PLUGIN_HANDLED

  if(get_cvar_float("amx_last_voting") > get_gametime()) {
    client_print(id, print_chat, _T("There is already one voting..."))
    return PLUGIN_HANDLED
  }

  g_voteSelectedNum[id] = 0

  if(g_mapsNum_VoteMapMenu) {
    displayVoteMapsMenu(id, g_menuPosition[id] = 0)
  }
  else {
    console_print(id, _T("There are no maps in menu"))
    client_print(id, print_chat, _T("There are no maps in menu"))
  }

  return PLUGIN_HANDLED
}

public cmdMapsMenu(id,level,cid) {
  if(!cmd_access(id,level,cid,1))
    return PLUGIN_HANDLED

  if(g_mapsNum_MapMenu) {
    displayMapsMenu(id, g_menuPosition[id] = 0)
  }
  else {
    console_print(id, _T("There are no maps in menu"))
    client_print(id, print_chat, _T("There are no maps in menu"))
  }

  return PLUGIN_HANDLED
}

public delayedChange(mapname[]) {
  server_cmd("changelevel %s", mapname)
}

public actionVoteMapMenu(id,key) {
  switch(key) {
    case 7: {
      new Float:voting = get_cvar_float("amx_last_voting")
      if(voting > get_gametime()) {
        client_print(id, print_chat, _T("There is already one voting..."))
        return PLUGIN_HANDLED
      }
      if(voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
        client_print(id, print_chat, _T("Voting not allowed at this time"))
        return PLUGIN_HANDLED
      }

      g_voteCount = {0, 0, 0, 0, 0}

      new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
      set_cvar_float("amx_last_voting", get_gametime() + vote_time)
      new iVoteTime = floatround(vote_time)

      set_task(vote_time, "checkVotes", 34567 + id)
      g_voteCaller = id
      
      for(new i = 1; i <= g_maxplayers; ++i) {
        g_hasVoted[i] = false
      }

      new menuBody[256]
      new players[32], player
      new pnum, keys, len
      new menuid, tempkeys
      
      get_players(players, pnum, "c")
      for(new b = 0; b < pnum; ++b) {
        player = players[b]
        keys = 0
        if(g_voteSelectedNum[id] > 1) {
          len = format(menuBody, 255, g_coloredMenus ?
            _T("\yWhich map do you want?^n\w^n",player) : _T("Which map do you want?^n^n",player))
          for(new c = 0; c < g_voteSelectedNum[id]; ++c) {
            len += format(menuBody[len], 255-len, "%d. %s^n", c + 1, g_mapDesc_MapMenu[g_voteSelected[id][c]])
            keys |= (1<<c)
          }
          keys |= (1<<8)
          len += format(menuBody[len], 255-len, _T("^n9. None^n",player))
        }
        else {
          len = format(menuBody, 255, g_coloredMenus ? _T("\yChange map to^n%s?^n\w^n1. Yes^n2. No^n",player)
            : _T("Change map to^n%s?^n^n1. Yes^n2. No^n", player), g_mapDesc_MapMenu[g_voteSelected[id][0]])
          keys = (1<<0)|(1<<1)
        }
        if(player != id) {
          get_user_menu(player, menuid, tempkeys)
          if(tempkeys == 0 || menuid < 0) {
            show_menu(player, keys, menuBody, iVoteTime, g_voteSelectedNum[id] > 1 ? "Which map do you want?" : "Change map to")
          }
          g_menukeys[player] = keys
          g_menumsg[player][0] = '^0'
          copy(g_menumsg[player], 255, menuBody)
        }
        else {
          format(menuBody[len], 511, _T("^n0. Cancel Vote",id))
          keys |= (1<<9)
          show_menu(id, keys, menuBody, iVoteTime, g_voteSelectedNum[id] > 1 ? "Which map do you want?" : "Change map to")
          g_menukeys[player] = keys
          g_menumsg[player][0] = '^0'
          copy(g_menumsg[player], 255, menuBody)
        }
      }
    
      g_yesNoVote = g_voteSelectedNum[id] > 1 ? 0 : 1
      g_menutitle[0] = '^0'
      copy(g_menutitle, 31, g_voteSelectedNum[id] > 1 ? "Which map do you want?" : "Change map to")
      remove_task(1467852)
      new param[3]
      param[0] = 1
      param[1] = g_voteSelectedNum[id] > 1 ? menuid_whichmap : menuid_changemap
      param[2] = get_cvar_num("amx_vote_time")
      set_task(CHECK_MENU_TIME, "check_menu", 1467852, param, 3)

      new authid[32], name[32], ipaddress[24]
      get_user_authid(id, authid, 31)
      get_user_name(id, name, 31)
      get_user_ip(id, ipaddress, 23, 1)

      switch(get_cvar_num("amx_show_activity")) {
        case 3: print_to_admins("acdefghijklmnopqrstuvw", print_chat, _T("ADMIN %s: vote map(s)"), name)
        case 2: client_print(0, print_chat, _T("ADMIN %s: vote map(s)"), name)
        case 1: client_print(0, print_chat, _T("ADMIN: vote map(s)"))
      }

      log_to_file(g_logFile,"Vote: ^"%s<%d><%s><%s>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
        name,get_user_userid(id),authid,ipaddress,
        g_voteSelectedNum[id] > 0 ? g_mapName_MapMenu[g_voteSelected[id][0]] : "",
        g_voteSelectedNum[id] > 1 ? g_mapName_MapMenu[g_voteSelected[id][1]] : "",
        g_voteSelectedNum[id] > 2 ? g_mapName_MapMenu[g_voteSelected[id][2]] : "",
        g_voteSelectedNum[id] > 3 ? g_mapName_MapMenu[g_voteSelected[id][3]] : "")
    }
    case 8: displayVoteMapsMenu(id, ++g_menuPosition[id])
    case 9: displayVoteMapsMenu(id, --g_menuPosition[id])
    default: {
      g_voteSelected[id][g_voteSelectedNum[id]++] = g_menuPosition[id] * 7 + key
      displayVoteMapsMenu(id, g_menuPosition[id])
    }
  }
  return PLUGIN_HANDLED
}

public actionMapsMenu(id,key) {
  switch(key) {
    case 8: displayMapsMenu(id, ++g_menuPosition[id])
    case 9: displayMapsMenu(id, --g_menuPosition[id])
    default: {
      new a = g_menuPosition[id] * 8 + key

      new modName[8]
      get_modname(modName, 7)
      if(!equal(modName, "zp")) {
        message_begin(MSG_ALL, SVC_INTERMISSION)
        message_end()
      }

      new authid[32], name[32], ipaddress[24]
      get_user_authid(id, authid, 31)
      get_user_name(id, name, 31)
      get_user_ip(id, ipaddress, 23, 1)

      switch(get_cvar_num("amx_show_activity")) {
        case 3: print_to_admins("acdefghijklmnopqrstuvw", print_chat, _T("ADMIN %s: changelevel %s"), name, g_mapName_MapMenu[a])
        case 2: client_print(0, print_chat, _T("ADMIN %s: changelevel %s"), name, g_mapName_MapMenu[a])
        case 1: client_print(0, print_chat, _T("ADMIN: changelevel %s"), g_mapName_MapMenu[a])
      }

      log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><%s>^" changelevel ^"%s^"",
        name,get_user_userid(id),authid,ipaddress,g_mapName_MapMenu[a])

      set_task(2.0, "delayedChange", 33119955, g_mapName_MapMenu[a], strlen(g_mapName_MapMenu[a]) + 1)
    }
  }
  return PLUGIN_HANDLED
}

displayMapsMenu(id,pos) {
  if(pos < 0)
    return

  new menuBody[512]
  new start = pos * 8
  new b = 0

  if(start >= g_mapsNum_MapMenu)
    start = pos = g_menuPosition[id] = 0

  new len = format(menuBody, 511, g_coloredMenus ?
    _T("\yChangelevel Menu\R%d/%d^n\w^n",id) : _T("Changelevel Menu %d/%d^n^n",id),
    pos+1, (g_mapsNum_MapMenu / 8 + (( g_mapsNum_MapMenu % 8) ? 1 : 0)))

  new end = start + 8
  new keys = (1<<9)

  if(end > g_mapsNum_MapMenu)
    end = g_mapsNum_MapMenu

  for(new a = start; a < end; ++a) {
    keys |= (1<<b)
    len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_mapDesc_MapMenu[a])
  }

  if(end != g_mapsNum_MapMenu) {
    format(menuBody[len], 511-len, _T("^n9. More...^n0. %s",id), pos ? _T("Back",id) : _T("Exit",id))
    keys |= (1<<8)
  }
  else format(menuBody[len], 511-len, "^n0. %s", pos ? _T("Back",id) : _T("Exit",id))

  show_menu(id, keys, menuBody, -1, "Changelevel Menu")
}

loadSettings_MapMenu(filename[]) {
  if(!file_exists(filename))
    return 0

  g_mapsNum_MapMenu = 0

  new text[256], szDesc[48]
  new a, pos = 0

  while(g_mapsNum_MapMenu < MAX_MAPS && (pos = read_file(filename, pos, text, 255, a))) {
    if(!a || text[0] == ';' || text[0] == '/') continue

    parse(text, g_mapName_MapMenu[g_mapsNum_MapMenu], 31, szDesc, 47)

    replace_all(g_mapName_MapMenu[g_mapsNum_MapMenu], 31, " ", "")
    replace_all(g_mapName_MapMenu[g_mapsNum_MapMenu], 31, ".bsp", "")

    if(!is_map_valid(g_mapName_MapMenu[g_mapsNum_MapMenu])) continue

    if(strlen(szDesc) > 31) {
      copy(g_mapDesc_MapMenu[g_mapsNum_MapMenu], 28, szDesc)
      g_mapDesc_MapMenu[g_mapsNum_MapMenu][28] = g_mapDesc_MapMenu[g_mapsNum_MapMenu][29] = g_mapDesc_MapMenu[g_mapsNum_MapMenu][30] = '.'
      g_mapDesc_MapMenu[g_mapsNum_MapMenu][31] = 0
    }
    else {
      if(szDesc[0]) copy(g_mapDesc_MapMenu[g_mapsNum_MapMenu], 31, szDesc)
      else copy(g_mapDesc_MapMenu[g_mapsNum_MapMenu], 31, g_mapName_MapMenu[g_mapsNum_MapMenu])
    }

    ++g_mapsNum_MapMenu
  }

  return g_mapsNum_MapMenu
}

loadSettings_VoteMapMenu(filename[]) {
  if(!file_exists(filename))
    return 0

  g_mapsNum_VoteMapMenu = 0

  new text[256], szDesc[48]
  new a, pos = 0

  while(g_mapsNum_VoteMapMenu < MAX_MAPS && (pos = read_file(filename, pos, text, 255, a))) {
    if(!a || text[0] == ';' || text[0] == '/') continue

    parse(text, g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu], 31, szDesc, 47)

    replace_all(g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu], 31, " ", "")
    replace_all(g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu], 31, ".bsp", "")

    if(!is_map_valid(g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu])) continue

    if(strlen(szDesc) > 31) {
      copy(g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu], 28, szDesc)
      g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu][28] = g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu][29] = g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu][30] = '.'
      g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu][31] = 0
    }
    else {
      if(szDesc[0]) copy(g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu], 31, szDesc)
      else copy(g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu], 31, g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu])
    }

    ++g_mapsNum_VoteMapMenu
  }

  return g_mapsNum_VoteMapMenu
}

loadMapsFolder_MapMenu() {
  g_mapsNum_MapMenu = 0

  new len, pos = 2
  new currentMap[32]
  get_mapname(currentMap, 31)

  while(g_mapsNum_MapMenu < MAX_MAPS && (pos = read_dir("maps", pos, g_mapName_MapMenu[g_mapsNum_MapMenu], 31, len))) {
    if(len <= 4 || (len > 4 && !equali(g_mapName_MapMenu[g_mapsNum_MapMenu][len-4], ".bsp", 4))) continue

    g_mapName_MapMenu[g_mapsNum_MapMenu][len-4] = '^0'
    if(!is_map_valid(g_mapName_MapMenu[g_mapsNum_MapMenu])) continue

    copy(g_mapDesc_MapMenu[g_mapsNum_MapMenu], 31, g_mapName_MapMenu[g_mapsNum_MapMenu])

    ++g_mapsNum_MapMenu
  }

  return g_mapsNum_MapMenu
}

loadMapsFolder_VoteMapMenu() {
  g_mapsNum_VoteMapMenu = 0

  new len, pos = 2
  new currentMap[32]
  get_mapname(currentMap, 31)

  while(g_mapsNum_VoteMapMenu < MAX_MAPS && (pos = read_dir("maps", pos, g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu], 31, len))) {
    if(len <= 4 || (len > 4 && !equali(g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu][len-4], ".bsp", 4))) continue

    g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu][len-4] = '^0'
    if(!is_map_valid(g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu])) continue

    copy(g_mapDesc_VoteMapMenu[g_mapsNum_VoteMapMenu], 31, g_mapName_VoteMapMenu[g_mapsNum_VoteMapMenu])

    ++g_mapsNum_VoteMapMenu
  }

  return g_mapsNum_VoteMapMenu
}
This are my errors when compiling with amxmodx compiler

Code:
//// mapsmenu.sma
// C:\Valve\Steam\steamapps\myaccount\condition zero\czero\addons\amxmo
dx\scripting\mapsmenu.sma(121) : error 017: undefined symbol "load_module"
// C:\Valve\Steam\steamapps\myaccount\condition zero\czero\addons\amxmo
dx\scripting\mapsmenu.sma(587) : error 017: undefined symbol "print_to_admins"
// C:\Valve\Steam\steamapps\myaccount\condition zero\czero\addons\amxmo
dx\scripting\mapsmenu.sma(629) : error 017: undefined symbol "print_to_admins"
//
// 3 Errors.
// Could not locate output file compiled\mapsmenu.amx (compile failed).
//
// Compilation Time: 1.02 sec
// ----------------------------------------
I can fix first error by coment this line

Code:
 
if(cvar_exists("amxmodx_version")) load_module("error")
But i can´t fix others because i´m a noob in amx script
and as i say i don´t know if its possible, as this code is part of amxmod2006.3

Please HELP!
Thanks
__________________
[T(x)Ps] ToP OperATions CLaN ®
............................................

Last edited by H(x)m3m do S@c0; 04-10-2007 at 16:55. Reason: Decide to put all code so you can help me.
H(x)m3m do S@c0 is offline
Thaniominator
Junior Member
Join Date: Apr 2007
Old 04-26-2007 , 15:57   Re: [HELP] Maps.ini (like amxmod 2006.3)
#2

Try remove the: "Read Functionallity Symbols".
Remove the "TEXT"
Thaniominator is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 04-26-2007 , 17:36   Re: [HELP] Maps.ini (like amxmod 2006.3)
#3

Why was Krotal so lame, I mean he copy pastes amxmodx development into the latest amxmod then does all this kinda stuff to break plugins from working with amxmodx:
if(cvar_exists("amxmodx_version")) load_module("error")

Why should it matter if a user wanted to use amx plugins on amxmodx, it's not like he had to be bothered to make it compatible. Instead he goes out of his way to try and break things.
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
H(x)m3m do S@c0
Member
Join Date: Feb 2007
Old 04-27-2007 , 22:07   Re: [HELP] Maps.ini (like amxmod 2006.3)
#4

Quote:
Copyright (c) 2002-2006 - Aleksander Naszko, Julien Laurent
Witch one is KroT@L?

Normally he signs KroT@L

and btw i think there are a few plugins to amxmodx that do the same trick...

Thanks Thaniominator, i´m gonna try that.
__________________
[T(x)Ps] ToP OperATions CLaN ®
............................................
H(x)m3m do S@c0 is offline
H(x)m3m do S@c0
Member
Join Date: Feb 2007
Old 04-27-2007 , 22:49   Re: [HELP] Maps.ini (like amxmod 2006.3)
#5

No way don´t seams to work.
What should i do, this are the lines (case 3)

Code:
switch(get_cvar_num("amx_show_activity")) {
        case 3: print_to_admins("acdefghijklmnopqrstu", print_chat, _T("ADMIN %s: vote map(s)"), name)
        case 2: client_print(0, print_chat, _T("ADMIN %s: vote map(s)"), name)
        case 1: client_print(0, print_chat, _T("ADMIN: vote map(s)"))
__________________
[T(x)Ps] ToP OperATions CLaN ®
............................................
H(x)m3m do S@c0 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-27-2007 , 23:00   Re: [HELP] Maps.ini (like amxmod 2006.3)
#6

You can remove the line case 3. Since print_to_admins is an AMX Mod core native.

Or if you want I can convert that to pawn itself.

Choose one or the other. The simplest would be just to remove that option.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 04-30-2007 , 05:20   Re: [HELP] Maps.ini (like amxmod 2006.3)
#7

Quote:
Originally Posted by H(x)m3m do S@c0 View Post
Witch one is KroT@L?

Normally he signs KroT@L

and btw i think there are a few plugins to amxmodx that do the same trick...

Thanks Thaniominator, i´m gonna try that.
Aleksander Naszko = OLO
Julien Laurent = KRoT@L

he (KRoT@L) was the only one really developing amx in it's final hour, he was the one that added that code...
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 04-30-2007 , 05:35   Re: [HELP] Maps.ini (like amxmod 2006.3)
#8

Quote:
Originally Posted by vittu View Post
Julien Laurent = KRoT@L
Not quite ;p

Julien Laurent is dJeyL.

Krotal just never added himself to that copyright notice.
sawce is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-30-2007 , 10:56   Re: [HELP] Maps.ini (like amxmod 2006.3)
#9

is_user_admin is just a stock from amxmisc.inc :

Code:
stock is_user_admin(id) {
  new flags = get_user_flags(id)
  return (flags > 0 && !(flags & ADMIN_USER))
}
So i guess you can just add those lines in the plugin or in amxmisc.inc if you want to use it in ithers plugins.
ConnorMcLeod is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode