Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.23 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import es
  4. import playerlib
  5. import cmdlib
  6. import popuplib
  7. import gamethread
  8. import cfglib
  9.  
  10. sourcepython = False
  11. native = False
  12.  
  13. try:
  14.     from spe.games import cstrike
  15.     sourcepython = True
  16. except:
  17.     try:
  18.         import nativetools as nt
  19.         native = True
  20.     except:
  21.         raise ImportError
  22.  
  23. # === DO NOT EDIT THIS FILE !!! ===
  24. # === EDIT THE CONFIG.CFG !!! ===
  25.  
  26. info = es.AddonInfo()
  27. info.name = 'Trikz'
  28. info.version = '1.1'
  29. info.basename = 'crazytrikz'
  30. info.author = 'Craziest'
  31. info.description = 'A plugin to handle trikz_ maps'
  32.  
  33. es.ServerVar('trikz_version', info.version).makepublic()
  34.  
  35. cfg = cfglib.AddonCFG(es.getAddonPath("crazytrikz") + "/config/config.cfg")
  36.  
  37. cfg.text('************************')
  38. cfg.text('*** TRIKZ MAP PLUGIN ***')
  39. cfg.text('************************')
  40. cfg.text('')
  41. cfg.text('You can load this file with:')
  42. cfg.text('- es_load crazytrikz')
  43. cfg.text('')
  44. cfg.text('Avaliable client commands:')
  45. cfg.text('!switch -  To switch between blocking and unblocking mod')
  46. cfg.text('!trikz - To open the scripts main menu (configurable below)')
  47. cfg.text('')
  48. cfg.text('************************')
  49. cfg.text('***** CONFIGURATION ****')
  50. cfg.text('************************')
  51. cfg.text('')
  52. cfg.text('Edit the following settings to your needs')
  53. cfg.text('')
  54. menuCommand = cfg.cvar('trikz_menu_command', "!ilovenoblish", 'The command to open the main menu')
  55. switchCommand = cfg.cvar('trikt_switch_command', "!switch", "The command to switch between block and noblock")
  56. enableGhost = cfg.cvar('trikz_enable_ghost', 1, 'Enable ghosting/noghosting option to players')
  57. enableUnliHealth = cfg.cvar('trikz_unlimited_health', 1, 'Enable unlimited health (so players can die from damage)')
  58. enableUnliFlash = cfg.cvar('trikz_unlimited_flash', 1, 'Enable the unlimited flash option')
  59. autoRespawn = cfg.cvar('trikz_auto_respawn', 1, 'Enable auto-respawning in the case the player dies')
  60. serverConfig = cfg.cvar('trikz_server_config', 1, 'Set the server variables needed to play trikz_ on map start')
  61. cfg.text('')
  62. cfg.text('If you have any suggetions/problems please post on the forums')
  63. cfg.text('')
  64. cfg.text('Other option of contact: craziest994 - Steam Name')
  65. cfg.text('')
  66. cfg.text('Coded by .craziesT')
  67.  
  68. cfg.write()
  69.  
  70. # === Load / Unload ===
  71.  
  72. def load():
  73.     rules()
  74.     es.msg('#multi', '#green[#lightgreenInsane Info#green] #defaultTrikz Menu #greenloaded')
  75.     global userDict
  76.     userDict = {}
  77.     cmdlib.registerSayCommand(menuCommand, trikzCmd, "Trikz Menu Command")
  78.     cmdlib.registerSayCommand(switchCommand, switchCmd, "Trikz Switch Command")
  79.     es.set('eventscripts_noisy', 1)
  80.     for x in es.getUseridList():
  81.         uid = es.getplayersteamid(x)
  82.         if uid not in userDict:
  83.             userDict[uid] = {}
  84.             userDict[uid]['flash'] = 0
  85.             if enableGhost:
  86.                 userDict[uid]['ghost'] = 1
  87.             else:
  88.                 userDict[uid]['ghost'] = 0
  89.             userDict[uid]['checkpoints'] = {}
  90.             userDict[uid]['checkpoints']['1st'] = 0, 0, 0
  91.             userDict[uid]['checkpoints']['2nd'] = 0, 0, 0
  92.     if str(es.ServerVar('eventscripts_currentmap')).startswith('trikz_'):
  93.         ff = es.ServerVar('mp_friendlyfire')
  94.         lim = es.ServerVar('mp_limitteams')
  95.         grav = es.ServerVar('sv_gravity')
  96.         acc = es.ServerVar('sv_airaccelerate')
  97.         if serverConfig:
  98.             ff.set(0)
  99.             grav.set(800)
  100.             acc.set(15000)
  101.             lim.set(0)
  102.     cfg.execute()
  103.    
  104. def unload():
  105.     es.msg('#multi', '#green[#lightgreenInsane Info#green] #defaultTrikz Menu #greenunloaded')
  106.     global userDict
  107.     cmdlib.unregisterSayCommand(menuCommand)
  108.     cmdlib.unregisterSayCommand(switchCommand)
  109.     es.set('eventscripts_noisy', 0)
  110.        
  111. # === Wrappers ===
  112.  
  113. def tell(userid, text):
  114.     es.tell(userid, '#multi', '#green[#lightgreenInsane Info#green] #default#green ' + text)
  115.  
  116. # === Events ===
  117.  
  118. def es_map_start(ev):
  119.     ff = es.ServerVar('mp_friendlyfire')
  120.     lim = es.ServerVar('mp_limitteams')
  121.     grav = es.ServerVar('sv_gravity')
  122.     acc = es.ServerVar('sv_airaccelerate')
  123.     if serverConfig:
  124.         ff.set(0)
  125.         grav.set(800)
  126.         acc.set(15000)
  127.         lim.set(0)
  128.     for x in userDict:
  129.         userDict[x]['checkpoints']['1st'] = 0, 0, 0
  130.         userDict[x]['checkpoints']['2nd'] = 0, 0, 0
  131.  
  132. def player_activate(ev):
  133.     global userDict
  134.     userid = int(ev['userid'])
  135.     uid = es.getplayersteamid(userid)
  136.     if uid not in userDict:
  137.         userDict[uid] = {}
  138.         userDict[uid]['flash'] = 0
  139.         if enableGhost:
  140.             userDict[uid]['ghost'] = 1
  141.         else:
  142.             userDict[uid]['ghost'] = 0
  143.         userDict[uid]['checkpoints'] = {}
  144.         userDict[uid]['checkpoints']['1st'] = 0, 0, 0
  145.         userDict[uid]['checkpoints']['2nd'] = 0, 0, 0
  146.     tell(userid, 'Type #lightgreen%s#green to open the Trikz menu.' % menuCommand)
  147.  
  148. def player_spawn(ev):
  149.     userid = int(ev['userid'])
  150.     uid = es.getplayersteamid(userid)
  151.     player = playerlib.getPlayer(userid)
  152.    
  153.     if enableGhost:
  154.         if userDict[uid]['ghost'] == 1:
  155.             player.setColor(255, 255, 255, 100)
  156.             es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2)
  157.     if enableUnliHealth:
  158.         es.setplayerprop(userid, "CBasePlayer.m_iHealth", 1000)
  159.    
  160. def player_hurt(ev):
  161.     if enableUnliHealth:
  162.         es.setplayerprop(ev['userid'], "CBasePlayer.m_iHealth", 1000)
  163.        
  164. def player_death(ev):
  165.     if autoRespawn:
  166.         if sourcepython:
  167.             cstrike.respawn(userid)
  168.         elif native:
  169.             nt.spawnPlayer(userid)
  170.         tell(ev['userid'], 'You have respawned.')
  171.    
  172. def weapon_fire(ev):
  173.     uid = es.getplayersteamid(ev['userid'])
  174.    
  175.     if ev['weapon'] == 'flashbang':
  176.         if enableUnliFlash:
  177.             if userDict[uid]['flash'] == 1:
  178.                 es.server.queuecmd('es_xgive %s weapon_flashbang' % ev['userid'])
  179.         es.delayed(1.45, 'es_xremove flashbang_projectile')
  180.        
  181. def flashbang_detonate(ev):
  182.     for x in es.getUseridList():
  183.         es.setplayerprop(x, "CCSPlayer.m_flFlashDuration", (0, 8))
  184.        
  185. # === Commands ===
  186.        
  187. def trikzCmd(userid, args):
  188.     uid = es.getplayersteamid(userid)
  189.    
  190.     menu = popuplib.create('user_menu')
  191.     menu.addline('Insane Trikz - TRIKZ MENU')
  192.     menu.addline('--------------------------------')
  193.     menu.addline('->1. Give Flash [2]')
  194.     menu.addline('->2. Toggle Auto-Flash')
  195.     menu.addline('->3. Toggle Blocking')
  196.     menu.addline('--------------------------------')
  197.     menu.addline('->4. Trikz Timer')
  198.     menu.addline('->5. Server Rules')
  199.     menu.addline('->6. Info')
  200.     menu.addline('--------------------------------')
  201.     menu.addline('0. Close')
  202.    
  203.     menu.send(userid)
  204.     menu.menuselect = mainSelect
  205.    
  206. def mainSelect(userid, choice, popupid):
  207.     global userDict
  208.     player = playerlib.getPlayer(userid)
  209.     uid = es.getplayersteamid(userid)
  210.     if choice == 1:
  211.         if player.getFB() in (0, 1):
  212.             es.server.queuecmd('es_xgive %s weapon_flashbang '% userid)
  213.             tell(userid, '#green+2 #defaultFlashbangs.')
  214.         else:
  215.             tell(userid, '#defaultMaximun Flashbangs Reached.')
  216.         popuplib.send('user_menu', userid)
  217.     elif choice == 2:
  218.         if enableUnliFlash:
  219.             if userDict[uid]['flash'] == 0:
  220.                 userDict[uid]['flash'] = 1
  221.                 tell(userid, '#defaultUnlimited Flash #greenON')
  222.             else:
  223.                 userDict[uid]['flash'] = 0
  224.                 tell(userid, '#defaultUnlimited Flash #greenOFF')
  225.         else:
  226.             tell(userid, 'This server has turned off this feature.')
  227.         popuplib.send('user_menu', userid)
  228.     elif choice == 3:
  229.         if userDict[uid]['ghost'] == 1:
  230.             userDict[uid]['ghost'] = 0
  231.             es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 0)
  232.             player.setColor(255, 255, 255, 255)
  233.             tell(userid, '#defaultYou are #greenBlocked')
  234.         else:
  235.             if enableGhost:
  236.                 userDict[uid]['ghost'] = 1
  237.                 es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2)
  238.                 player.setColor(255, 255, 255, 100)
  239.                 tell(userid, '#defaultYou are #greenGhost')
  240.             else:
  241.                 tell(userid, 'This server has turned off ghosting.')
  242.         popuplib.send('user_menu', userid)
  243.  
  244. def cpSelect(userid, choice, popupid):
  245.     global userDict
  246.     uid = es.getplayersteamid(userid)
  247.    
  248.     if choice == 1:
  249.         if es.getplayerprop(userid, "CCSPlayer.baseclass.localdata.m_hGroundEntity") != -1:
  250.             userDict[uid]['checkpoints']['1st'] = es.getplayerlocation(userid)
  251.             tell(userid, 'You have saved your #lightgreen1st#green checkpoint.')
  252.         else:
  253.             tell(userid, 'You have to be standing on the ground.')
  254.         popuplib.send('checkpoints', userid)
  255.     elif choice == 2:
  256.         if userDict[uid]['checkpoints']['1st'] != (0, 0, 0):
  257.             location = userDict[uid]['checkpoints']['1st']
  258.             es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))
  259.         else:
  260.             tell(userid, 'You have not set your 1st checkpoint.')
  261.         popuplib.send('checkpoints', userid)
  262.     elif choice == 3:
  263.         if es.getplayerprop(userid, "CCSPlayer.baseclass.localdata.m_hGroundEntity") != -1:
  264.             userDict[uid]['checkpoints']['2nd'] = es.getplayerlocation(userid)
  265.             tell(userid, 'You have saved your #lightgreen2nd#green checkpoint.')
  266.         else:
  267.             tell(userid, 'You have to be standing on the ground.')
  268.         popuplib.send('checkpoints', userid)
  269.     elif choice == 4:
  270.         if userDict[uid]['checkpoints']['2nd'] != (0, 0, 0):
  271.             location = userDict[uid]['checkpoints']['2nd']
  272.             es.server.queuecmd('es_setpos %s %s %s %s' % (userid, location[0], location[1], location[2]))
  273.         else:
  274.             tell(userid, 'You have not set your 2nd checkpoint.')
  275.         popuplib.send('checkpoints', userid)
  276.     elif choice in (5, 6, 7, 8):
  277.         popuplib.send('checkpoints', userid)
  278.     elif choice == 4:
  279.         es.sexec (userid, "say !top")
  280.     elif choice == 5:
  281.         popuplib.send('rules', userid)
  282.  
  283.     if choice == 9:
  284.         popuplib.send('user_menu', userid)
  285.  
  286.     elif choice == 6:
  287.         tell(userid, '#greenby #defaultNoblish. #green Contact: #defaultnoblishhh')
  288.            
  289. def switchCmd(userid, args):
  290.     uid = es.getplayersteamid(userid)
  291.     player = playerlib.getPlayer(userid)
  292.    
  293.     if userDict[uid]['ghost'] == 1:
  294.         userDict[uid]['ghost'] = 0
  295.         es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 0)
  296.         player.setColor(255, 255, 255, 255)
  297.         tell(userid, '#defaultYou are #greenBlocked')
  298.     else:
  299.         if enableGhost:
  300.             userDict[uid]['ghost'] = 1
  301.             es.setplayerprop(userid, "CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_CollisionGroup", 2)
  302.             player.setColor(255, 255, 255, 100)
  303.             tell(userid, '#defaultYou are #greenGhost')
  304.         else:
  305.             tell(userid, 'This server has turned off ghosting.')
  306.            
  307. def rules():
  308.  
  309.     rulesPopup = popuplib.create("rules")
  310.     rulesPopup.addline('Insane Rulez!')
  311.     rulesPopup.addline('------------------------------------')
  312.     rulesPopup.addline('->1.No Racism! = Kick')
  313.     rulesPopup.addline('->2.No Hack/Bhop Hack! = Ban')
  314.     rulesPopup.addline('->3.Dont Advertise! = Permenant Ban')
  315.     rulesPopup.addline('->4.Dont Block Others! = Ban')
  316.     rulesPopup.addline('->5.Dont Spamm! = Kick/Ban')
  317.     rulesPopup.addline('->6.No Exploits/Server Hacks = Ban')
  318.     rulesPopup.addline('------------------------------------')
  319.     rulesPopup.addline('->9. Back')
  320.     rulesPopup.addline("0. Close")
  321.    
  322.     rulesPopup.menuselect = rulesmenuselect
  323.    
  324. def rulesmenuselect(userid, choice, rules):
  325.  
  326.     if choice == 9:
  327.        popuplib.send("user_menu", userid)
  328.  
  329. # === CODED BY CRAZIEST - DO NOT EDIT WITHOUT ASKING FIRST ===
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement