def map_check(mapname): if mapname in gDefaultMaps or os.path.isfile(xa.gamedir() + "/maps/%s.bsp" % mapname): return True else: if not mapname.startswith("//") and mapname != "": es.dbgmsg(0, "XAMapManagement: Unable to find map: %s." % mapname) return False
def makedownloadable(skinfile,skingroup): """ This function reads each model/material list files and makes them downloadable if cvar set. Also returns model name """ strPath = xaskins_skinfiles_path + skingroup + "/" + skinfile if not os.path.isfile(strPath): xaskins.logging.log("Cannot find the text file which contains all the download files for skin %s"%skingroup) return None sp = open(xaskins_skinfiles_path + skingroup + "/" + skinfile, "r") for line in sp: line = line.strip() if not line.startswith('//') and bool(line): if not line.count("."): """ Allow users to just give us folder names """ directory = os.path.join(xa.gamedir(), line ) if os.path.isdir(directory): for fileName in os.listdir(directory): if skins_downloadable == 1: es.stringtable("downloadables", line + "/" + fileName) if fileName.endswith('.mdl'): model = line + "/" + fileName else: if skins_downloadable == 1: es.stringtable("downloadables", line) if line.endswith('.mdl'): model = line return model
def map_check(mapname): if mapname in gDefaultMaps or os.path.isfile(xa.gamedir() + '/maps/%s.bsp' % mapname): return True else: if not mapname.startswith('//') and mapname != '': es.dbgmsg(0, 'XAMapManagement: Unable to find map: %s.' % mapname) return False
def makedownloadable(skinfile, skingroup): """ This function reads each model/material list files and makes them downloadable if cvar set. Also returns model name """ strPath = xaskins_skinfiles_path + skingroup + "/" + skinfile if not os.path.isfile(strPath): xaskins.logging.log( "Cannot find the text file which contains all the download files for skin %s" % skingroup) return None sp = open(xaskins_skinfiles_path + skingroup + "/" + skinfile, "r") for line in sp: line = line.strip() if not line.startswith('//') and bool(line): if not line.count("."): """ Allow users to just give us folder names """ directory = os.path.join(xa.gamedir(), line) if os.path.isdir(directory): for fileName in os.listdir(directory): if skins_downloadable == 1: es.stringtable("downloadables", line + "/" + fileName) if fileName.endswith('.mdl'): model = line + "/" + fileName else: if skins_downloadable == 1: es.stringtable("downloadables", line) if line.endswith('.mdl'): model = line return model
def map_cycle(): global gMapCycle gMapCycle = [] mapcycle_path = xa.gamedir() + '/' + str(es.ServerVar('mapcyclefile')) if os.path.isfile(mapcycle_path): mapfile = open(mapcycle_path, 'r') gMapCycle = filter(map_check, map(string.strip, mapfile.readlines())) mapfile.close() else: gMapCycle = [es.ServerVar('eventscripts_currentmap')]
def map_cycle(): global gMapCycle gMapCycle = [] mapcycle_path = xa.gamedir() + "/" + str(es.ServerVar("mapcyclefile")) if os.path.isfile(mapcycle_path): mapfile = open(mapcycle_path, "r") gMapCycle = filter(map_check, map(string.strip, mapfile.readlines())) mapfile.close() else: gMapCycle = [es.ServerVar("eventscripts_currentmap")]
def load(): """ Ensures the .cfg directories exist Loads the path to the .cfg directory in str_dir """ global str_dir # Ensures .cfg directories exist str_dir = xa.gamedir() + '/cfg/xa' _check_directory(str_dir) str_dir += '/prefixexec' _check_directory(str_dir) """ If XA is loaded whilst a map is loaded, run the map start event """ mapName = str(es.ServerVar('eventscripts_currentmap')) if mapName != "": es_map_start({'mapname': mapName})
def load(): """ Ensures the .cfg directories exist Loads the path to the .cfg directory in str_dir """ global str_dir # Ensures .cfg directories exist str_dir = xa.gamedir() + '/cfg/xa' _check_directory(str_dir) str_dir += '/prefixexec' _check_directory(str_dir) """ If XA is loaded whilst a map is loaded, run the map start event """ mapName = str(es.ServerVar('eventscripts_currentmap')) if mapName != "": es_map_start({'mapname':mapName})
def map_menu(): if popuplib.exists('xamapmenu'): popuplib.delete('xamapmenu') maplist_path = xa.gamedir() + '/maplist.txt' if os.path.isfile(maplist_path): mapfile = open(maplist_path, 'r') maplist = filter(map_check, map(string.strip, mapfile.readlines())) mapfile.close() if 'test_speakers' in maplist: maplist.remove('test_speakers') if 'test_hardware' in maplist: maplist.remove('test_hardware') maplist = sorted(maplist, key=lambda x: str(x).lower()) else: maplist = gDefaultMaps xamapmenu = popuplib.easymenu('xamapmenu', None, mapmenu_handler) xamapmenu.settitle('Choose a map:') xamapmenu.submenu(10, 'xamapmainmenu') for mapname in maplist: xamapmenu.addoption(mapname, mapname)
def map_menu(): if popuplib.exists("xamapmenu"): popuplib.delete("xamapmenu") maplist_path = xa.gamedir() + "/maplist.txt" if os.path.isfile(maplist_path): mapfile = open(maplist_path, "r") maplist = filter(map_check, map(string.strip, mapfile.readlines())) mapfile.close() if "test_speakers" in maplist: maplist.remove("test_speakers") if "test_hardware" in maplist: maplist.remove("test_hardware") maplist = sorted(maplist, key=lambda x: str(x).lower()) else: maplist = gDefaultMaps xamapmenu = popuplib.easymenu("xamapmenu", None, mapmenu_handler) xamapmenu.settitle("Choose a map:") xamapmenu.submenu(10, "xamapmainmenu") for mapname in maplist: xamapmenu.addoption(mapname, mapname)
def map_menu(): if popuplib.exists('xamapmenu'): popuplib.delete('xamapmenu') maplist_path = xa.gamedir() + '/maplist.txt' if os.path.isfile(maplist_path): mapfile = open(maplist_path, 'r') maplist = filter(map_check,map(string.strip,mapfile.readlines())) mapfile.close() if 'test_speakers' in maplist: maplist.remove('test_speakers') if 'test_hardware' in maplist: maplist.remove('test_hardware') maplist = sorted(maplist, key=lambda x: str(x).lower()) else: maplist = gDefaultMaps xamapmenu = popuplib.easymenu('xamapmenu',None,mapmenu_handler) xamapmenu.settitle('Choose a map:') xamapmenu.submenu(10, 'xamapmainmenu') for mapname in maplist: xamapmenu.addoption(mapname,mapname)
info.basename = "xaskins" skinmenu = [ 'Admin T', 'Admin CT', 'Public T', 'Public CT', 'Reserved T', 'Reserved CT', 'Misc' ] skinnames = [ 'admin_t', 'admin_ct', 'public_t', 'public_ct', 'reserved_t', 'reserved_ct', 'misc' ] skinlist = {} playermenu = {} skins_downloadable = 1 if xa.isManiMode(): xaskins_skinfiles_path = xa.gamedir() + "/cfg/mani_admin_plugin/skins/" else: xaskins_skinfiles_path = xa.gamedir() + "/cfg/xa/skins/" ############### ### GLOBALS ### ############### xaskins = xa.register(info.basename) xalanguage = xaskins.language.getLanguage() players = {} players['exists'] = xaskins.playerdata.createUserSetting("exists") players['admin_t'] = xaskins.playerdata.createUserSetting("admin_t") players['admin_ct'] = xaskins.playerdata.createUserSetting("admin_ct") players['reserved_t'] = xaskins.playerdata.createUserSetting("reserved_t")
def check_if_files_exist(): if not os.path.isdir(xa.gamedir() + "/cfg/xa"): os.mkdir(xa.gamedir() + "/cfg/xa") if not os.path.isdir(xaskins_skinfiles_path): os.mkdir(xaskins_skinfiles_path) for fileName in skinnames: if not os.path.isfile(xaskins_skinfiles_path + fileName + ".txt"): open(xaskins_skinfiles_path + fileName + ".txt", 'w').close() if not os.path.isdir(xaskins_skinfiles_path + fileName): os.mkdir(xaskins_skinfiles_path + fileName) installationFilePath = xaskins_skinfiles_path + "_INSTALLATION.txt" if not os.path.isfile(installationFilePath): fileStream = open(installationFilePath, 'w') fileStream.write("""\ -------------- XASkins by Don ../cfg/xa/skins/_INSTALLATION.txt -------------- Skins is an eXtensible Admin module created by Don. This installation file will help you set up custom skins for your server. To first enable skins, you need to open your xa.cfg found in ../cfg/ and remove the "//" at the start of the following line: // xa load xaskins xaskins will now load as a default module whenever the server starts. If you ave reached this file, in the same directory as this (../cfg/xa/skins) you should see several text files and several folders. --------------- Adding skins to the menu --------------- The basic principle of setting up skins is as follows: 1. Set it up so the server adds the skins into the menu. 2. Make sure that the server knows the correct model paths to your models and materials. We are going to discuss option 1 in this section. The basic overview of XASkins is to allow several user groups to have individual skins, and it gives them the choice of which skin to pick. The skins are based on their powers and team. Each "power" has two teams, (t and ct). This allows each user group (or power) to have seperate models available dependant on which team they are in. Lets take an example, consider a user having the power level of administration. They have 2 files assosiated to the admin power: o admin_t - the models available to terrorist admins o admin_ct - the models available to counter-terrorist admins Within each of these files, you can place a model on each line. The correct syntax of the line should be as follows: "Model Name As Shown On Popup" file_to_show_downloads.txt Now, there are two parts of this line. The first part is the name which will be showed to all users. E.g. If we had "Terrorist Admin Skin" then when the user brings up the menu, "Terrorist Admin Skin" will be displayed there. This name must be enclosed in quotation marks (""). The second part is the file assosiated with model. This part is just a file name. The location of this file should be in the following directory: o ../cfg/xa/skins/<power_team>/ For example, if this skin is for the power group "admin" and for "terrorists", the file must be places within: o ../cfg/xa/skins/admin_t/ The next section will help you set up the downloads. If you want to know what the powers mean, scroll to the end of this installation file which will tell you what each power group means. --------------- Setting up the model paths --------------- As I stated in the previous section, the server must know where to get your models from. The way we do this is by creating a .txt file in the folder directory of ../cfg/xa/skins/<power_team>/. In the previous part, we added a skin to the menu by opening: o ../cfg/xa/skins/admin_t.txt and adding the line: o "My Model Name" modeldownloads.txt As I have said, the second part will tell the server which file to read the downloads from. Because we are working on "admin_t" this file must be located within: o ../cfg/xa/skins/admin_t/ So, create a new file in that directory and name it "modeldownloads.txt". The directory of the file should be as follows: o ../cfg/xa/skins/admin_t/modeldownloads.txt Open the file in notepad. We now have to write our model locations on a new line. You have two choices here: 1. Name every specific model / material 2. Only give the folder path to the models and materials I will be working on the latter option since it's simpler. Lets imagine the path to the models from the ../cstrike/ directory is as follows: o models/player/ics/admin_skin Imagine that within that folder, it should contain all the models and files related to your admin model you wish to use (generally there are 6 files; .dx80.vtx, .dx90.vtx, .mdl, .phy, .sw.vtx and .vvd). Rather than specifying each individual file, just put the following line in: models/player/ics/admin_skin and every file within that folder will be added to the download list and all clients who join your server will download that file. Also, just a reminder, you have to do the same for your materials. The materials location is USUALLY in the exact same location as your "models", except it starts with materials first. So in this case, the material directory would be as follows: materials/models/player/ics/admin_skin Just to reiterate, you can give the exact path to your model or material, so the following is also legal: models/player/ics/admin_skin/admin_skin.mdl If you have followed this correctly, you should have a file in: o ../cfg/xa/skins/admin_t/modeldownloads.txt With the following in between the lines within that file: -------------------------------------- models/player/ics/admin_skin material/smodels/player/ics/admin_skin -------------------------------------- To get the file to be recognised, just restart your server and you'll be able to access your skins by sayig "xa" in chat and going to: Player Settings > Skins That is all, thank you for reading. --------------- Power List --------------- The following list is a definition of each of the powers: o admin - Administrator. If you are using capibilities (such as group auth) then the admins must have the power "skin_admin" o reserved - This power is generally assosiated with players who donate to your server for example. They don't have true power, yet they have additional services which the generic public don't get. They must be a "POWERUSER" and have the right "skin_reserved" o public - This usergroup is for anyone joining your server. Everybody who joins instantly gets this capability. o misc - Stands for "miscelaneous". The reason this doesn't have a team is because it will not show up in the menu and thus users can't choose skins from the ones you right in this text file. The only reason this is here is to allow others to download scripts. This will only be used by people who force a skin by other means (such as another mod.) The only thing putting skins in this file will do is download them. ---------------- Additional reads: ---------------- o http://eventscripts.com/pages/Authorization_FAQ An FAQ regarding authorization rights. It also tells you what POWERUSER and ADMIN mean.""") fileStream.close()
def _freeze_loop(userid): for soundfile in os.listdir('%s/sound/player/footsteps/' % xa.gamedir()): es.server.queuecmd('es_xstopsound %d "player/footsteps/%s"' % (userid, soundfile))
from xa import xa info = es.AddonInfo() info.name = "Skins" info.version = "0.5" info.author = "Don" info.basename = "xaskins" skinmenu = ['Admin T', 'Admin CT', 'Public T', 'Public CT', 'Reserved T', 'Reserved CT', 'Misc'] skinnames = ['admin_t', 'admin_ct', 'public_t', 'public_ct', 'reserved_t', 'reserved_ct', 'misc'] skinlist = {} playermenu = {} skins_downloadable = 1 if xa.isManiMode(): xaskins_skinfiles_path = xa.gamedir() + "/cfg/mani_admin_plugin/skins/" else: xaskins_skinfiles_path = xa.gamedir() + "/cfg/xa/skins/" ############### ### GLOBALS ### ############### xaskins = xa.register(info.basename) xalanguage = xaskins.language.getLanguage() players = {} players['exists'] = xaskins.playerdata.createUserSetting("exists") players['admin_t'] = xaskins.playerdata.createUserSetting("admin_t") players['admin_ct'] = xaskins.playerdata.createUserSetting("admin_ct") players['reserved_t'] = xaskins.playerdata.createUserSetting("reserved_t")