Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import es
- import playerlib
- import cmdlib
- import popuplib
- import gamethread
- import cfglib
- sourcepython = False
- native = False
- try:
- from spe.games import cstrike
- sourcepython = True
- except:
- try:
- import nativetools as nt
- native = True
- except:
- raise ImportError
- # === DO NOT EDIT THIS FILE !!! ===
- # === EDIT THE CONFIG.CFG !!! ===
- info = es.AddonInfo()
- info.name = 'Trikz'
- info.version = '1.1'
- info.basename = 'crazytrikz'
- info.author = 'Craziest'
- info.description = 'A plugin to handle trikz_ maps'
- es.ServerVar('trikz_version', info.version).makepublic()
- cfg = cfglib.AddonCFG(es.getAddonPath("crazytrikz") + "/config/config.cfg")
- cfg.text('************************')
- cfg.text('*** TRIKZ MAP PLUGIN ***')
- cfg.text('************************')
- cfg.text('')
- cfg.text('You can load this file with:')
- cfg.text('- es_load crazytrikz')
- cfg.text('')
- cfg.text('Avaliable client commands:')
- cfg.text('!switch - To switch between blocking and unblocking mod')
- cfg.text('!trikz - To open the scripts main menu (configurable below)')
- cfg.text('')
- cfg.text('************************')
- cfg.text('***** CONFIGURATION ****')
- cfg.text('************************')
- cfg.text('')
- cfg.text('Edit the following settings to your needs')
- cfg.text('')
- menuCommand = cfg.cvar('trikz_menu_command', "!ilovenoblish", 'The command to open the main menu')
- switchCommand = cfg.cvar('trikt_switch_command', "!switch", "The command to switch between block and noblock")
- enableGhost = cfg.cvar('trikz_enable_ghost', 1, 'Enable ghosting/noghosting option to players')
- enableUnliHealth = cfg.cvar('trikz_unlimited_health', 1, 'Enable unlimited health (so players can die from damage)')
- enableUnliFlash = cfg.cvar('trikz_unlimited_flash', 1, 'Enable the unlimited flash option')
- autoRespawn = cfg.cvar('trikz_auto_respawn', 1, 'Enable auto-respawning in the case the player dies')
- serverConfig = cfg.cvar('trikz_server_config', 1, 'Set the server variables needed to play trikz_ on map start')
- cfg.text('')
- cfg.text('If you have any suggetions/problems please post on the forums')
- cfg.text('')
- cfg.text('Other option of contact: craziest994 - Steam Name')
- cfg.text('')
- cfg.text('Coded by .craziesT')
- cfg.write()
- # === Load / Unload ===
- def load():
- rules()
- es.msg('#multi', '#green[#lightgreenInsane Info#green] #defaultTrikz Menu #greenloaded')
- global userDict
- userDict = {}
- cmdlib.registerSayCommand(menuCommand, trikzCmd, "Trikz Menu Command")
- cmdlib.registerSayCommand(switchCommand, switchCmd, "Trikz Switch Command")
- es.set('eventscripts_noisy', 1)
- for x in es.getUseridList():
- uid = es.getplayersteamid(x)
- if uid not in userDict:
- userDict[uid] = {}
- userDict[uid]['flash'] = 0
- if enableGhost:
- userDict[uid]['ghost'] = 1
- else:
- userDict[uid]['ghost'] = 0
- userDict[uid]['checkpoints'] = {}
- userDict[uid]['checkpoints']['1st'] = 0, 0, 0
- userDict[uid]['checkpoints']['2nd'] = 0, 0, 0
- if str(es.ServerVar('eventscripts_currentmap')).startswith('trikz_'):
- ff = es.ServerVar('mp_friendlyfire')
- lim = es.ServerVar('mp_limitteams')
- grav = es.ServerVar('sv_gravity')
- acc = es.ServerVar('sv_airaccelerate')
- if serverConfig:
- ff.set(0)
- grav.set(800)
- acc.set(15000)
- lim.set(0)
- cfg.execute()
- def unload():
- es.msg('#multi', '#green[#lightgreenInsane Info#green] #defaultTrikz Menu #greenunloaded')
- global userDict
- cmdlib.unregisterSayCommand(menuCommand)
- cmdlib.unregisterSayCommand(switchCommand)
- es.set('eventscripts_noisy', 0)
- # === Wrappers ===
- def tell(userid, text):
- es.tell(userid, '#multi', '#green[#lightgreenInsane Info#green] #default#green ' + text)
- # === Events ===
- def es_map_start(ev):
- ff = es.ServerVar('mp_friendlyfire')
- lim = es.ServerVar('mp_limitteams')
- grav = es.ServerVar('sv_gravity')
- acc = es.ServerVar('sv_airaccelerate')
- if serverConfig:
- ff.set(0)
- grav.set(800)
- acc.set(15000)
- lim.set(0)
- for x in userDict:
- userDict[x]['checkpoints']['1st'] = 0, 0, 0
- userDict[x]['checkpoints']['2nd'] = 0, 0, 0
- def player_activate(ev):
- global userDict
- userid = int(ev['userid'])
- uid = es.getplayersteamid(userid)
- if uid not in userDict:
- userDict[uid] = {}
- userDict[uid]['flash'] = 0
- if enableGhost:
- userDict[uid]['ghost'] = 1
- else:
- userDict[uid]['ghost'] = 0
- userDict[uid]['checkpoints'] = {}
- userDict[uid]['checkpoints']['1st'] = 0, 0, 0
- userDict[uid]['checkpoints']['2nd'] = 0, 0, 0
- tell(userid, 'Type #lightgreen%s#green to open the Trikz menu.' % menuCommand)
- def player_spawn(ev):
- userid = int(ev['userid'])
- uid = es.getplayersteamid(userid)
- player = playerlib.getPlayer(userid)
- if enableGhost:
- if userDict[uid]['ghost'] == 1:
- player.setColor(255, 255, 255, 100)
- es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2)
- if enableUnliHealth:
- es.setplayerprop(userid, "CBasePlayer.m_iHealth", 1000)
- def player_hurt(ev):
- if enableUnliHealth:
- es.setplayerprop(ev['userid'], "CBasePlayer.m_iHealth", 1000)
- def player_death(ev):
- if autoRespawn:
- if sourcepython:
- cstrike.respawn(userid)
- elif native:
- nt.spawnPlayer(userid)
- tell(ev['userid'], 'You have respawned.')
- def weapon_fire(ev):
- uid = es.getplayersteamid(ev['userid'])
- if ev['weapon'] == 'flashbang':
- if enableUnliFlash:
- if userDict[uid]['flash'] == 1:
- es.server.queuecmd('es_xgive %s weapon_flashbang' % ev['userid'])
- es.delayed(1.45, 'es_xremove flashbang_projectile')
- def flashbang_detonate(ev):
- for x in es.getUseridList():
- es.setplayerprop(x, "CCSPlayer.m_flFlashDuration", (0, 8))
- # === Commands ===
- def trikzCmd(userid, args):
- uid = es.getplayersteamid(userid)
- menu = popuplib.create('user_menu')
- menu.addline('Insane Trikz - TRIKZ MENU')
- menu.addline('--------------------------------')
- menu.addline('->1. Give Flash [2]')
- menu.addline('->2. Toggle Auto-Flash')
- menu.addline('->3. Toggle Blocking')
- menu.addline('--------------------------------')
- menu.addline('->4. Trikz Timer')
- menu.addline('->5. Server Rules')
- menu.addline('->6. Info')
- menu.addline('--------------------------------')
- menu.addline('0. Close')
- menu.send(userid)
- menu.menuselect = mainSelect
- def mainSelect(userid, choice, popupid):
- global userDict
- player = playerlib.getPlayer(userid)
- uid = es.getplayersteamid(userid)
- if choice == 1:
- if player.getFB() in (0, 1):
- es.server.queuecmd('es_xgive %s weapon_flashbang '% userid)
- tell(userid, '#green+2 #defaultFlashbangs.')
- else:
- tell(userid, '#defaultMaximun Flashbangs Reached.')
- popuplib.send('user_menu', userid)
- elif choice == 2:
- if enableUnliFlash:
- if userDict[uid]['flash'] == 0:
- userDict[uid]['flash'] = 1
- tell(userid, '#defaultUnlimited Flash #greenON')
- else:
- userDict[uid]['flash'] = 0
- tell(userid, '#defaultUnlimited Flash #greenOFF')
- else:
- tell(userid, 'This server has turned off this feature.')
- popuplib.send('user_menu', userid)
- elif choice == 3:
- if userDict[uid]['ghost'] == 1:
- userDict[uid]['ghost'] = 0
- es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 0)
- player.setColor(255, 255, 255, 255)
- tell(userid, '#defaultYou are #greenBlocked')
- else:
- if enableGhost:
- userDict[uid]['ghost'] = 1
- es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2)
- player.setColor(255, 255, 255, 100)
- tell(userid, '#defaultYou are #greenGhost')
- else:
- tell(userid, 'This server has turned off ghosting.')
- popuplib.send('user_menu', userid)
- def cpSelect(userid, choice, popupid):
- global userDict
- uid = es.getplayersteamid(userid)
- if choice == 1:
- if es.getplayerprop(userid, "CCSPlayer.baseclass.localdata.m_hGroundEntity") != -1:
- userDict[uid]['checkpoints']['1st'] = es.getplayerlocation(userid)
- tell(userid, 'You have saved your #lightgreen1st#green checkpoint.')
- else:
- tell(userid, 'You have to be standing on the ground.')
- popuplib.send('checkpoints', userid)
- elif choice == 2:
- if userDict[uid]['checkpoints']['1st'] != (0, 0, 0):
- location = userDict[uid]['checkpoints']['1st']
- es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))
- else:
- tell(userid, 'You have not set your 1st checkpoint.')
- popuplib.send('checkpoints', userid)
- elif choice == 3:
- if es.getplayerprop(userid, "CCSPlayer.baseclass.localdata.m_hGroundEntity") != -1:
- userDict[uid]['checkpoints']['2nd'] = es.getplayerlocation(userid)
- tell(userid, 'You have saved your #lightgreen2nd#green checkpoint.')
- else:
- tell(userid, 'You have to be standing on the ground.')
- popuplib.send('checkpoints', userid)
- elif choice == 4:
- if userDict[uid]['checkpoints']['2nd'] != (0, 0, 0):
- location = userDict[uid]['checkpoints']['2nd']
- es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))
- else:
- tell(userid, 'You have not set your 2nd checkpoint.')
- popuplib.send('checkpoints', userid)
- elif choice in (5, 6, 7, 8):
- popuplib.send('checkpoints', userid)
- elif choice == 4:
- es.sexec (userid, "say !top")
- elif choice == 5:
- popuplib.send('rules', userid)
- if choice == 9:
- popuplib.send('user_menu', userid)
- elif choice == 6:
- tell(userid, '#greenby #defaultNoblish. #green Contact: #defaultnoblishhh')
- def switchCmd(userid, args):
- uid = es.getplayersteamid(userid)
- player = playerlib.getPlayer(userid)
- if userDict[uid]['ghost'] == 1:
- userDict[uid]['ghost'] = 0
- es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 0)
- player.setColor(255, 255, 255, 255)
- tell(userid, '#defaultYou are #greenBlocked')
- else:
- if enableGhost:
- userDict[uid]['ghost'] = 1
- es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2)
- player.setColor(255, 255, 255, 100)
- tell(userid, '#defaultYou are #greenGhost')
- else:
- tell(userid, 'This server has turned off ghosting.')
- def rules():
- rulesPopup = popuplib.create("rules")
- rulesPopup.addline('Insane Rulez!')
- rulesPopup.addline('------------------------------------')
- rulesPopup.addline('->1.No Racism! = Kick')
- rulesPopup.addline('->2.No Hack/Bhop Hack! = Ban')
- rulesPopup.addline('->3.Dont Advertise! = Permenant Ban')
- rulesPopup.addline('->4.Dont Block Others! = Ban')
- rulesPopup.addline('->5.Dont Spamm! = Kick/Ban')
- rulesPopup.addline('->6.No Exploits/Server Hacks = Ban')
- rulesPopup.addline('------------------------------------')
- rulesPopup.addline('->9. Back')
- rulesPopup.addline("0. Close")
- rulesPopup.menuselect = rulesmenuselect
- def rulesmenuselect(userid, choice, rules):
- if choice == 9:
- popuplib.send("user_menu", userid)
- # === CODED BY CRAZIEST - DO NOT EDIT WITHOUT ASKING FIRST ===
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement