Advertisement
captmicro

Untitled

Sep 28th, 2011
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. import es, playerlib, popuplib, gamethread
  2. import urllib2, threading
  3.  
  4. START_POS = "top" #top, default (spawns), or pikachu (middle of spawns)
  5.  
  6. info = es.AddonInfo()
  7. info.name = "SurfTricks Extended"
  8. info.basename = "surftricks_ext"
  9. info.version = "HERPDERPDURR"
  10. info.url = "microvnet.info"
  11. info.description= "SUP3R L33T SURFTR1CKK5 3XT3ND3D"
  12. info.author = "Capt. Micro"
  13. info.contact = "arrowflyer@gmail.com"
  14. info.tags = "surf,tricks,surftricks,race,money"
  15.  
  16. tricklist = {
  17. 'Awp2Awp':{
  18. 'racable':True,
  19. 'prize':500,
  20. },
  21. 'Awp3':{
  22. 'racable':True,
  23. 'prize':500,
  24. },
  25. 'Pikachu Gap':{
  26. 'racable':True,
  27. 'prize':500,
  28. },
  29. 'Tobe Go Home':{
  30. 'racable':True,
  31. 'prize':500,
  32. },
  33. 'Deagle to awp':{
  34. 'racable':True,
  35. 'prize':500,
  36. },
  37. 'T1000':{
  38. 'racable':True,
  39. 'prize':500,
  40. },
  41. 'T1000 to spawn':{
  42. 'racable':True,
  43. 'prize':500,
  44. },
  45. 'T1000 to sign':{
  46. 'racable':True,
  47. 'prize':500,
  48. },
  49. 'Awp4':{
  50. 'racable':True,
  51. 'prize':500,
  52. },
  53. 'Main to sign':{
  54. 'racable':True,
  55. 'prize':500,
  56. },
  57. 'Razor Gap':{
  58. 'racable':True,
  59. 'prize':500,
  60. },
  61. 'Awp To Awp Over Main':{
  62. 'racable':True,
  63. 'prize':500,
  64. },
  65. 'Spawn Hop Ct->T':{
  66. 'racable':True,
  67. 'prize':500,
  68. },
  69. 'Spawn Hop T->Ct':{
  70. 'racable':True,
  71. 'prize':500,
  72. },
  73. 'Nc Waave':{
  74. 'racable':True,
  75. 'prize':500,
  76. },
  77. 'Double Hop':{
  78. 'racable':True,
  79. 'prize':500,
  80. },
  81. 'Chrome Gap':{
  82. 'racable':True,
  83. 'prize':500,
  84. }
  85. }
  86.  
  87. race_start_positions = {
  88. 'default': {
  89. 'player1': (-1073, 232, 6080),
  90. 'player2': (-1073, -232, 6080)
  91. },
  92. 'pikachu': {
  93. 'player1': (-1040, 8.0, 6080.093750),
  94. 'player2': (-1040, -7.9, 6080.093750)
  95. },
  96. 'top': {
  97. 'player1': (-1952, 150, 7272.093750),
  98. 'player2': (-1952, -150, 7272.093750)
  99. },
  100. }
  101.  
  102. race_start_pos = race_start_positions[START_POS]
  103. race_winner_prize = 1500
  104. race_races = []
  105. race_playerselect = None
  106. race_trickselect = None
  107. race_menutmp = {}
  108.  
  109. def race_newrace(userid1, userid2, trick):
  110. global race_races
  111. race_races += [{
  112. 'userid1': str(userid1),
  113. 'userid2': str(userid2),
  114. 'trick': trick,
  115. 'status': 'WAIT'
  116. }]
  117. ply1 = playerlib.getPlayer(userid1)
  118. ply2 = playerlib.getPlayer(userid2)
  119. es.tell(ply2.userid, "#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
  120. "[#lightgreen%s vs #lightgreen%s#default] #green%s #defaulthas challenged you to race #green%s #default!"
  121. %(ply1.name,ply2.name,ply1.name,trick))
  122. es.tell(ply2.userid, "#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
  123. "[#lightgreen%s vs #lightgreen%s#default] type \"!race accept\" to accept the challenge."
  124. %(ply1.name,ply2.name))
  125.  
  126. def race_startrace(raceindex):
  127. global race_races
  128. ply1 = playerlib.getPlayer(race_races[raceindex]['userid1'])
  129. ply2 = playerlib.getPlayer(race_races[raceindex]['userid2'])
  130. #this resets both players tricks (kinda hacky yo)
  131. ply1.kill()
  132. ply2.kill()
  133. gamethread.delayed(1, ply1.freeze, 1)
  134. gamethread.delayed(1, ply2.freeze, 1)
  135. #move players to start positions
  136. ply1.setLocation(race_start_pos['player1'])
  137. ply2.setLocation(race_start_pos['player2'])
  138. gamethread.delayed(5, ply1.freeze, 0)
  139. gamethread.delayed(5, ply2.freeze, 0)
  140. #FIRE THE BOOLET
  141. race_races[raceindex]['status'] = 'RACE'
  142. es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
  143. "[#lightgreen%s vs #lightgreen%s#default] #default RACE STARTED!"
  144. %(ply1.name,ply2.name))
  145.  
  146. def race_endrace(raceindex, winner):
  147. global race_races
  148. ply1 = playerlib.getPlayer(race_races[raceindex]['userid1'])
  149. ply2 = playerlib.getPlayer(race_races[raceindex]['userid2'])
  150. pwinner = playerlib.getPlayer(winner)
  151. es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
  152. "[#lightgreen%s vs #lightgreen%s#default] #green%s #default has won the race!"
  153. %(ply1.name,ply2.name,pwinner.name))
  154. pwinner.cash += race_winner_prize
  155. del race_races[raceindex]
  156.  
  157. def playermenu_handler(userid, choice, menuname):
  158. global race_trickselect
  159. global race_menutmp
  160. race_menutmp[userid] = choice
  161. race_trickselect.send(userid)
  162.  
  163. def trickmenu_handler(userid, choice, menuname):
  164. global race_menutmp
  165. opp = race_menutmp[userid]
  166. del race_menutmp[userid]
  167. race_newrace(userid, opp, choice)
  168.  
  169. def load():
  170. #RACE trick selection menu
  171. global race_trickselect
  172. if (race_trickselect != None): race_trickselect.delete()
  173. race_trickselect = popuplib.easymenu('trickselect', None, trickmenu_handler)
  174. race_trickselect.settitle("[RACE] Trick Select")
  175. for trickname in tricklist:
  176. if (tricklist[trickname]['racable']):
  177. race_trickselect.addoption(trickname, trickname)
  178.  
  179. #RACE player selection menu
  180. global race_playerselect
  181. if (race_playerselect != None): race_playerselect.delete()
  182. race_playerselect = popuplib.easymenu('playerselect', None, playermenu_handler)
  183. race_playerselect.settitle("[RACE] Player Select")
  184. for player in playerlib.getPlayerList('#human'):
  185. race_playerselect.addoption(player.userid, player.name)
  186.  
  187. def unload():
  188. global race_playerselect
  189. if (race_playerselect != None): race_playerselect.delete()
  190. global race_trickselect
  191. if (race_trickselect != None): race_trickselect.delete()
  192. pass
  193.  
  194. def player_activate(e):
  195. #RACE player selection menu
  196. global race_playerselect
  197. if (race_playerselect != None): race_playerselect.delete()
  198. race_playerselect = popuplib.easymenu('playerselect', None, playermenu_handler)
  199. race_playerselect.settitle("[RACE] Player Select")
  200. for player in playerlib.getPlayerList('#human'):
  201. race_playerselect.addoption(player.userid, player.name)
  202.  
  203. def player_disconnect(e):
  204. #RACE player selection menu
  205. global race_playerselect
  206. if (race_playerselect != None): race_playerselect.delete()
  207. race_playerselect = popuplib.easymenu('playerselect', None, playermenu_handler)
  208. race_playerselect.settitle("[RACE] Player Select")
  209. for player in playerlib.getPlayerList('#human'):
  210. race_playerselect.addoption(player.userid, player.name)
  211.  
  212. def es_player_chat(e):
  213. text = e['text']
  214. ply = playerlib.getPlayer(e['userid'])
  215. if (text[0:5] == '!race'):
  216. args = text.split(' ')
  217. if (len(args) == 1):
  218. global race_playerselect
  219. race_playerselect.send(ply.userid)
  220. elif (len(args) == 2):
  221. if (args[1] == 'accept'):
  222. global race_races
  223. for race in race_races:
  224. if (race['userid2'] == str(ply.userid)):
  225. ply1 = playerlib.getPlayer(race['userid1'])
  226. ply2 = playerlib.getPlayer(race['userid2'])
  227. es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
  228. "[#lightgreen%s vs #lightgreen%s#default]#green #default%s has accepted the race!"
  229. %(ply1.name,ply2.name,ply.name))
  230. race_startrace(race_races.index(race))
  231.  
  232. class SQLWebHandler(urllib2.HTTPHandler):
  233. def http_response(self, req, response):
  234. print "HTTP RESPONSE:"
  235. print response[0:250]
  236. return response
  237. sqlopenner = urllib2.build_opener(MyHandler())
  238.  
  239. def surftricks_trick(e):
  240. ply = playerlib.getPlayer(e['userid'])
  241.  
  242. #update SQL aww yeah
  243. t1 = threading.Thread(target=sqlopenner.open, args=(
  244. 'http://microvnet.info/fullsteel/motd.php?dbedit=sidlookup'
  245. +'&steamid='+ply.steamid+'&name='+ply.name)
  246. t2 = threading.Thread(target=sqlopenner.open, args=(
  247. 'http://microvnet.info/fullsteel/motd.php?dbedit=tricks'
  248. +'&steamid='+ply.steamid+'&trick='+e['trick']+'&time='+str(e['time']))
  249. t3 = threading.Thread(target=sqlopenner.open, args=(
  250. 'http://microvnet.info/fullsteel/motd.php?dbedit=rank'
  251. +'&steamid='+ply.steamid+'&rank='+str(tricklist[e['trick']]['prize']))
  252. t1.start()
  253. t2.start()
  254. t3.start()
  255.  
  256. #Cash money prize
  257. ply = playerlib.getPlayer(e['userid'])
  258. ply.cash += tricklist[e['trick']]['prize']
  259.  
  260. #Racing stuffffff
  261. global race_races
  262. for race in race_races:
  263. if (race['trick'] == e['trick'] and race['status'] == 'RACE'):
  264. if (race['userid1'] == str(ply.userid) or race['userid2'] == str(ply.userid)):
  265. race_endrace(race_races.index(race), str(ply.userid))
  266. race['status'] = 'OVER'
  267.  
  268.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement