Advertisement
captmicro

Untitled

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