Advertisement
captmicro

Untitled

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