Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.18 KB | None | 0 0
  1. ######################
  2. ### Guns And Games ###
  3. ######################
  4. leg_1_location_t  = "-255.500427,-1391.077637,128.093811"
  5. leg_1_location_ct = "-1840.713745,-1004.405701,162.085236"
  6.  
  7. leg_2_location_ct = "-1840.713745,-1004.405701,162.085236"
  8.  
  9. _CMD = '!ct'
  10.  
  11. import es
  12. import psyco
  13. import random
  14. import popuplib
  15. import playerlib
  16. import gamethread
  17.  
  18. global currentGame
  19. currentGame = 0
  20.  
  21. psyco.full()
  22. Data            = {}
  23. Data['guns']    = {}
  24. def load():
  25.     global Menu_Main
  26.     Menu_Main = popuplib.easymenu('Menu_Main',None, PopupChoiceThing)
  27.     Menu_Main.settitle("- CT Menu\nPage:")
  28.     Menu_Main.addoption("gunsMenu","Våben")
  29.     Menu_Main.addoption("gamesMenu","Spil")
  30.    
  31.     global Menu_Guns
  32.     Menu_Guns = popuplib.easymenu('Menu_Guns',None, PopupChoiceThing)
  33.     Menu_Guns.submenu(10, Menu_Main)
  34.     Menu_Guns.settitle("- CT Menu\n-- Våben\nPage:")
  35.     Menu_Guns.addoption("Pistols","Pistoler")
  36.     Menu_Guns.addoption("Rifles","Geværer")
  37.     Menu_Guns.addoption("Others","Tilbehør")
  38.    
  39.     global Menu_Guns_Pistols
  40.     Menu_Guns_Pistols = popuplib.easymenu('Menu_Guns_Pistols',None, PopupChoiceThingWeapon)
  41.     Menu_Guns_Pistols.submenu(10, Menu_Guns)
  42.     Menu_Guns_Pistols.settitle("- CT Menu\n-- Våben\n--- Pistoler\nPage:")
  43.     Menu_Guns_Pistols.addoption("weapon_deagle","Deagle")
  44.     Menu_Guns_Pistols.addoption("weapon_elite","Elite")
  45.     Menu_Guns_Pistols.addoption("weapon_fiveseven","FiveSeven")
  46.     Menu_Guns_Pistols.addoption("weapon_gglock","Glock")
  47.     Menu_Guns_Pistols.addoption("weapon_p228","P228")
  48.     Menu_Guns_Pistols.addoption("weapon_usp","USP")
  49.    
  50.     global Menu_Guns_Rifles
  51.     Menu_Guns_Rifles = popuplib.easymenu('Menu_Guns_Rifles',None, PopupChoiceThingWeapon)
  52.     Menu_Guns_Rifles.submenu(10, Menu_Guns)
  53.     Menu_Guns_Rifles.settitle("- CT Menu\n-- Våben\n--- Geværer\nPage:")
  54.     Menu_Guns_Rifles.addoption("weapon_ak47", "AK47")
  55.     Menu_Guns_Rifles.addoption("weapon_aug", "AUG")
  56.     Menu_Guns_Rifles.addoption("weapon_famas", "Famas")
  57.     Menu_Guns_Rifles.addoption("weapon_galil", "Galil")
  58.     Menu_Guns_Rifles.addoption("weapon_m4a1", "M4A1")
  59.     Menu_Guns_Rifles.addoption("weapon_sg552", "SG552")
  60.    
  61.     global Menu_Guns_Others
  62.     Menu_Guns_Others = popuplib.easymenu('Menu_Guns_Others',None, PopupChoiceThingWeapon)
  63.     Menu_Guns_Others.submenu(10, Menu_Guns)
  64.     Menu_Guns_Others.settitle("- CT Menu\n-- Våben\n--- Tilbehør\nPage:")
  65.     Menu_Guns_Others.addoption("weapon_hegrenade","HE Grenade")
  66.     Menu_Guns_Others.addoption("weapon_smokegrenade","Smoke Grenade")
  67.     Menu_Guns_Others.addoption("weapon_flashbang","FlashBang")
  68.    
  69.     global Menu_Games
  70.     Menu_Games = popuplib.easymenu('Menu_Games',None, PopupChoiceThingGames)
  71.     Menu_Games.submenu(10, Menu_Main)
  72.     Menu_Games.settitle("- CT Menu\n-- Spil\nPage:")
  73.     Menu_Games.addoption("Game1|War","War")
  74.     Menu_Games.addoption("Game2|Gemmeleg","Gemmeleg")
  75.     Menu_Games.addoption("Game3|Barrel Roll","Barrel Roll")
  76.    
  77.     gamethread.delayed(.01,round_start,'lol')
  78.     global TimeLeft
  79.     TimeLeft = 0
  80.     es.server.queuecmd("mp_restartgame 1")
  81. def unload():
  82.     gamethread.cancelDelayed('TimeLeftCountDown')
  83. def PopupChoiceThingWeapon(userid,weapon,popupname):
  84.     if IsDead(userid):
  85.         es.tell(userid,'Du kan ikke få våben mens du er død!')
  86.         return
  87.     if int(userid) not in Data['guns']:
  88.         Data['guns'][int(userid)] = 0
  89.     Data['guns'][int(userid)] += 1
  90.     if Data['guns'][int(userid)] > 1:
  91.         es.tell(userid,'Du kan kun få ét våben per runde!')
  92.         return
  93.     es.server.queuecmd("es_xgive %s %s" %(userid,weapon))
  94. def PopupChoiceThingGames(userid2,game,popupname):
  95.     GameName = game.split("|")[1]
  96.     game = game.split("|")[0]
  97.     if IsDead(userid2):
  98.         es.tell(userid2,'Du kan ikke bruge denne kommando mens du er død!')
  99.         return
  100.     global currentGame
  101.     if currentGame:
  102.         es.tell(userid2,'Et spil (#%s) er allerede i gang!' %(currentGame))
  103.         return
  104.     if game == 'Game1':
  105.         for PLAYER in playerlib.getPlayerList('#t,#alive'):
  106.             es.entitysetvalue(PLAYER.index, 'origin', ' '.join(leg_1_location_t.split(',')))
  107.             PLAYER.freeze(1)
  108.         for PLAYER in playerlib.getPlayerList('#ct,#alive'):
  109.             es.entitysetvalue(PLAYER.index, 'origin', ' '.join(leg_1_location_ct.split(',')))
  110.     elif game == 'Game2':
  111.         for PLAYER in playerlib.getPlayerList('#ct,#alive'):
  112.             es.server.queuecmd("es_xgive %s %s" %(PLAYER.userid,'weapon_hegrenade'))
  113.         for PLAYER in playerlib.getPlayerList('#ct,#alive'):
  114.             es.entitysetvalue(PLAYER.index, 'origin', ' '.join(leg_2_location_ct.split(',')))
  115.             PLAYER.freeze(1)
  116.     elif game == 'Game3':
  117.         for PLAYER in playerlib.getPlayerList('#ct,#alive'):
  118.             PLAYER.freeze(1)
  119.             Strip(PLAYER.userid)
  120.             PLAYER.setModel('props/de_train/Barrel.mdl')
  121.            
  122.         es.precachemodel('models/props/de_train/Barrel.mdl')
  123.         File = open(es.getAddonPath('gunandgames')+'/%s.txt' %(es.ServerVar("eventscripts_currentmap")),'r')
  124.         for LINE in File.readlines():
  125.             if random.randint(1,3) < 3:
  126.                 INDEX = es.createentity('prop_physics')
  127.                 es.entitysetvalue(INDEX, 'model', 'models/props/de_train/Barrel.mdl')
  128.                 es.entitysetvalue(INDEX, 'solid', 6)
  129.                 es.entitysetvalue(INDEX, 'origin', LINE.replace(",","").replace("(","").replace(")",""))
  130.                 es.entitysetvalue(INDEX, "spawnflags", 8)
  131.                 es.spawnentity(INDEX)
  132.         File.close()
  133.     else:
  134.         return
  135.     currentGame = int(str(game).replace('Game',''))
  136.     for PLAYER in playerlib.getPlayerList('#alive'):
  137.         PLAYER.noblock(1)
  138.     es.msg('#multi','#darkgreen%s #greenstartede spil #darkgreen#%s#green - #darkgreen%s#green!' %(es.getplayername(userid2),currentGame,GameName))
  139. def Strip(userid):
  140.     es.give(userid, 'player_weaponstrip')
  141.     es.fire(userid, 'player_weaponstrip', 'strip')
  142.     es.fire(userid, 'player_weaponstrip', 'kill')
  143. def PopupChoiceThing(userid,choice,popupname):
  144.     if IsDead(userid):
  145.         es.tell(userid,'Du kan ikke bruge denne menu mens du er død!')
  146.         return
  147.     if choice == 'Pistols': Menu_Guns_Pistols.send(userid)
  148.     if choice == 'Rifles': Menu_Guns_Rifles.send(userid)
  149.     if choice == 'Others': Menu_Guns_Others.send(userid)
  150.     if choice == 'gamesMenu':
  151.         if currentGame:
  152.             es.tell(userid,'Et spil (#%s) er allerede i gang!' %(currentGame))
  153.             return
  154.         Menu_Games.send(userid)
  155.     if choice == 'gunsMenu':
  156.         if int(userid) not in Data['guns']:
  157.             Data['guns'][int(userid)] = 0
  158.         if Data['guns'][int(userid)] > 0:
  159.             es.tell(userid,'Du kan kun få ét våben per runde!')
  160.             return
  161.         Menu_Guns.send(userid)
  162. def player_spawn(ev):
  163.     Data['guns'][int(ev['userid'])] = 0
  164. def player_say(ev):
  165.     message = ev['text'].lower()
  166.     userid = ev['userid']
  167.     team = int(ev['es_userteam'])
  168.     if message == _CMD:
  169.         if team == 3:
  170.             if IsDead(userid):
  171.                 es.tell(userid,'Du kan ikke bruge denne menu mens du er død!')
  172.                 return
  173.             Menu_Main.send(userid)
  174.         else:
  175.             es.tell(userid,'Denne kommando er kun for CTere')
  176. def item_pickup(ev):
  177.     global currentGame
  178.     if currentGame == 2:
  179.         if int(ev['es_userteam']) == 2:
  180.             if ev['item'] != 'weapon_hegrenade':
  181.                 Strip(ev['userid'])
  182.                 es.server.queuecmd("es_xgive %s %s" %(ev['userid'],'weapon_hegrenade'))
  183.     if currentGame == 3:
  184.         if int(ev['es_userteam']) == 3:
  185.             Strip(ev['userid'])
  186. def round_start(ev):
  187.     global currentGame
  188.     currentGame = 0
  189.     global TimeLeft
  190.     TimeLeft = int(es.ServerVar("mp_roundtime")) * 60 + int(es.ServerVar("mp_freezetime"))
  191.     gamethread.cancelDelayed('TimeLeftCountDown')
  192.     gamethread.delayedname(1,'TimeLeftCountDown',TimeLeftCountDown)
  193. def TimeLeftCountDown():
  194.     global TimeLeft
  195.     gamethread.cancelDelayed('TimeLeftCountDown')
  196.     gamethread.delayedname(1,'TimeLeftCountDown',TimeLeftCountDown)
  197.     TimeLeft -= 1
  198.     if currentGame == 1:
  199.         if TimeLeft < 8 * 60 + 1:
  200.             for PLAYER in playerlib.getPlayerList('#t,#alive'):
  201.                 PLAYER.freeze(0)
  202.             gamethread.cancelDelayed('TimeLeftCountDown')
  203.     if currentGame == 2:
  204.         if TimeLeft < 8 * 60 + 1:
  205.             for PLAYER in playerlib.getPlayerList('#ct,#alive'):
  206.                 PLAYER.freeze(0)
  207.             gamethread.cancelDelayed('TimeLeftCountDown')
  208.     if currentGame == 3:
  209.         if TimeLeft < 4 * 60 + 1:
  210.             if int(es.getplayercount(3)) > 0:
  211.                 es.msg("Terroristerne nåede ikke at dræbe alle Counter-Terroristerne!")
  212.                 for PLAYER in playerlib.getPlayerList('#t,#alive'):
  213.                     PLAYER.kill()
  214.             for PLAYER in playerlib.getPlayerList('#ct,#alive'):
  215.                 PLAYER.freeze(0)
  216.             gamethread.cancelDelayed('TimeLeftCountDown')
  217. def IsDead(userid):
  218.     if not es.exists('userid',userid): return 0
  219.     if int(es.getplayerteam(userid)) not in [2,3]: return 0
  220.     return playerlib.getPlayer(userid).isdead
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement