Advertisement
captmicro

Untitled

Sep 18th, 2011
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.74 KB | None | 0 0
  1. import es
  2. import vecmath
  3. import playerlib
  4. import popuplib
  5. import time
  6. tricks = {}
  7.  
  8. info = es.AddonInfo()
  9. info.name = "Surf Tricks"
  10. info.version = "1.0.0"
  11. info.url = "http://addons.eventscripts.com/addons/view/SurfTricks"
  12. info.basename = "SurfTricks"
  13. info.author = "DHack"
  14. es.ServerVar('SurfTricks_Ver', info.version, 'Surf Tricks Version').makepublic()
  15.  
  16.  
  17. #1 Top
  18. #2 top2
  19. #3 Main
  20. #4 Sign
  21. #5 Pool
  22. #6 ct
  23. #7 t
  24.  
  25. #awp t side
  26. #8 pool
  27. #9 box
  28. #0 ramp
  29. #d triangles
  30.  
  31. #awp ct side
  32. #a ramp
  33. #b pool
  34. #c box
  35. #e triangles
  36.  
  37.  
  38. #f deagle
  39. #g main triangl
  40. #h pika
  41.  
  42.  
  43. tricklist = {
  44. 'Awp2Awp':{
  45. 'sequence':['0a','a0'],
  46. 'combo':['Awp3'],
  47. 'combotriggers':1,
  48. 'prize':500,
  49. },
  50. 'Awp3':{
  51. 'sequence':['0a0','a0a'],
  52. 'combo':['Awp4'],
  53. 'combotriggers':1,
  54. 'prize':500,
  55. },
  56. 'Pikachu Gap':{
  57. 'sequence':['2h'],
  58. 'combo':[],
  59. 'combotriggers':0,
  60. 'prize':500,
  61. },
  62. 'Tobe Go Home':{
  63. 'sequence':['5d09','5eac'],
  64. 'combo':[],
  65. 'combotriggers':0,
  66. 'prize':500,
  67. },
  68. 'Deagle to awp':{
  69. 'sequence':['f0','fa'],
  70. 'combo':[],
  71. 'combotriggers':0,
  72. 'prize':500,
  73. },
  74. 'T1000':{
  75. 'sequence':['f3'],
  76. 'combo':['T1000 to spawn','T1000 to sign'],
  77. 'combotriggers':1,
  78. 'prize':500,
  79. },
  80. 'T1000 to spawn':{
  81. 'sequence':['f36','f37'],
  82. 'combo':[],
  83. 'combotriggers':0,
  84. 'prize':500,
  85. },
  86. 'T1000 to sign':{
  87. 'sequence':['f34'],
  88. 'combo':[],
  89. 'combotriggers':0,
  90. 'prize':500,
  91. },
  92. 'Awp4':{
  93. 'sequence':['a0a0','0a0a'],
  94. 'combo':[],
  95. 'combotriggers':0,
  96. 'prize':500,
  97. },
  98. 'Main to sign':{
  99. 'sequence':['34'],
  100. 'combo':[],
  101. 'combotriggers':0,
  102. 'prize':500,
  103. },
  104. 'Razor Gap':{
  105. 'sequence':['235'],
  106. 'combo':[],
  107. 'combotriggers':0,
  108. 'prize':500,
  109. },
  110. 'Awp To Awp Over Main':{
  111. 'sequence':['03a','a30'],
  112. 'combo':[],
  113. 'combotriggers':0,
  114. 'prize':500,
  115. },
  116. 'Spawn Hop Ct->T':{
  117. 'sequence':['67'],
  118. 'combo':[],
  119. 'combotriggers':0,
  120. 'prize':500,
  121. },
  122. 'Spawn Hop T->Ct':{
  123. 'sequence':['76'],
  124. 'combo':[],
  125. 'combotriggers':0,
  126. 'prize':500,
  127. },
  128. 'Nc Waave':{
  129. 'sequence':['63d', '73e'],
  130. 'combo':[],
  131. 'combotriggers':0,
  132. 'prize':500,
  133. },
  134. 'Double Hop':{
  135. 'sequence':['51513'],
  136. 'combo':[],
  137. 'combotriggers':0,
  138. 'prize':500,
  139. },
  140. 'Chrome Gap':{
  141. 'sequence':['2389', '23bc'],
  142. 'combo':[],
  143. 'combotriggers':0,
  144. 'prize':500,
  145. }
  146. }
  147.  
  148. def load():
  149. es.regsaycmd('!point', 'surftricks/point', 'This opens the menu')
  150. es.server.queuecmd("es_load extendedevents")
  151. es.server.queuecmd("extendedevents_load player_move")
  152.  
  153. def point():
  154. userid = es.getcmduserid()
  155. x,y,z = es.getplayerlocation(userid)
  156. es.msg(es.getplayername(userid)+' (%s, %s, %s)'%(x,y,z))
  157.  
  158. tricks_races = {}
  159. def race_startrace(race):
  160. global tricks_races
  161. tricks_races[race]['state'] = 'racing'
  162. vs = race.split(',')
  163. opp1 = playerlib.getPlayer(vs[0])
  164. opp2 = playerlib.getPlayer(vs[1])
  165. opp1.kill()
  166. opp2.kill()
  167.  
  168. def race_trick_handler(userid, choice, menuname):
  169. global tricks_races
  170. ply = playerlib.getPlayer(e['userid'])
  171. myrace = ""
  172. for race in tricks_races:
  173. vs = race.split(',')
  174. if (vs[0] == ply.userid):
  175. myrace = race
  176. if (len(myrace) == 0): return False
  177. tricks_races[myrace]['trick'] = choice
  178.  
  179. def race_name_handler(userid, choice, menuname):
  180. global tricks_races
  181. ply = playerlib.getPlayer(e['userid'])
  182. opp = playerlib.getPlayer(choice)
  183. for race in tricks_races:
  184. vs = race.split(',')
  185. if (vs[0] == str(opp.userid) or vs[1] == str(opp.userid)):
  186. es.tell(ply.userid, "#multi", "#default[#lightgreenSurf Tricks Racing#default] #greenPlayer #default%s#green is already in a race!"%opp.name)
  187. return False
  188. es.tell(opp.userid, "#multi", "#default[#lightgreenSurf Tricks Racing#default] #greenPlayer #default%s#green has challenged you to a race!"%ply.name)
  189. tricks_races[str(ply.userid)+','+str(opp.userid)] = {
  190. "state": "waiting", "trick": "unknown", "bets": {},
  191. }
  192. popup = popuplib.easymenu(ply.userid, None, race_trick_handler)
  193. popup.settitle('SurfTricks Racing [PICK TRICK]')
  194. for trick in tricklist:
  195. popup.addoption(trick, trick)
  196. popup.send(ply.userid)
  197.  
  198. def es_player_chat(e):
  199. global tricks_races
  200. text = e['text']
  201. ply = playerlib.getPlayer(e['userid'])
  202. if (text[0:5] == '!race'):
  203. args = text.split(' ')
  204. if (len(x) == 1):
  205. popup = popuplib.easymenu(str(ply.userid), None, race_name_handler)
  206. popup.settitle('SurfTricks Racing [PICK PLAYER]')
  207. for player in playerlib.getPlayerList('#alive'):
  208. popup.addoption(str(player.userid), player.name)
  209. popup.send(ply.userid)
  210. elif (len(x) == 2):
  211. if (args[1] == 'accept'):
  212. for race in tricks_races:
  213. vs = race.split(',')
  214. if (vs[1] == str(ply.userid)):
  215. es.tell(vs[0], "#multi", "#default[#lightgreenSurf Tricks Racing#default] #greenPlayer #default%s#green has accepted your challenge!"%ply.name)
  216. gamethread.delayed(10, race_startrace, race)
  217. opp = playerlib.getPlayer(vs[0])
  218. es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] #default%s#green vs #default%s#green on #lightgreen%s!#green STARTING IN 10 SECONDS!"%(opp.name,ply.name,choice))
  219. elif (args[1] == 'decline'):
  220. delrace = ""
  221. for race in tricks_races:
  222. vs = race.split(',')
  223. if (vs[1] == str(ply.userid)):
  224. es.tell(vs[0], "#multi", "#default[#lightgreenSurf Tricks Racing#default] #greenPlayer #default%s#green has declined the challenge!"%ply.name)
  225. delrace = race
  226. if (len(delrace) > 0):
  227. del tricks_races[delrace]
  228.  
  229. def player_spawn(ev):
  230. userid = ev['userid']
  231. tricks[ev['userid']] = {}
  232. tricks[ev['userid']]['currenttrigger'] = ''
  233. tricks[ev['userid']]['lasttriggers'] = ''
  234. tricks[ev['userid']]['lasttrick'] = ''
  235. tricks[ev['userid']]['trigerstilldelete'] = 0
  236. tricks[ev['userid']]['time'] = []
  237.  
  238. def player_move(ev):
  239. userid = ev['userid']
  240. name = es.getplayername(userid)
  241. player = playerlib.getPlayer(userid)
  242. if player.attributes['isdead'] == 1:
  243. return
  244. where = vecmath.vector(es.getplayerlocation(userid))
  245. #Top Triger
  246. if vecmath.isbetweenRect(where, (-1873.38208008, 186.852890015, 7208.03125), (-2422.34472656, -210.814849854, 7386.06152344)) and tricks[userid]['currenttrigger'] != '1':
  247. tricks[userid]['lasttriggers'] += '1'
  248. tricks[userid]['currenttrigger'] = '1'
  249. tricks[userid]['time'].append(gettime())
  250. checktricks(userid)
  251. #es.msg(name+' Has gone in point 1')
  252. #Top2 Triger
  253. elif vecmath.isbetweenRect(where, (-1870.42553711, -191.403823853, 7208.03125), (-1709.19848633, 193.75177002, 7209.43017578)) and tricks[userid]['currenttrigger'] != '2':
  254. tricks[userid]['lasttriggers'] += '2'
  255. tricks[userid]['currenttrigger'] = '2'
  256. tricks[userid]['time'].append(gettime())
  257. checktricks(userid)
  258. #es.msg(name+' Has gone in point 2')
  259. #MainRamp Triger
  260. elif vecmath.isbetweenRect(where, (-1045.970215, 227.254944, 5873.747559), (2488.334717, -261.856018, 4312.144043)) and tricks[userid]['currenttrigger'] != '3':
  261. tricks[userid]['lasttriggers'] += '3'
  262. tricks[userid]['currenttrigger'] = '3'
  263. tricks[userid]['time'].append(gettime())
  264. checktricks(userid)
  265. #es.msg(name+' Has gone in point 3')
  266. #Sign Triger
  267. elif vecmath.isbetweenRect(where, (629.737793, 236.375458, 6182.140625), (536.640015, -260.946259, 6084.806152)) and tricks[userid]['currenttrigger'] != '4':
  268. tricks[userid]['lasttriggers'] += '4'
  269. tricks[userid]['currenttrigger'] = '4'
  270. tricks[userid]['time'].append(gettime())
  271. checktricks(userid)
  272. #es.msg(name+' Has gone in point 4')
  273. #pool trigger
  274. elif pointincycylinder(where, 1056, (-6496, 0, -1743.96875), 686.96875) and tricks[userid]['currenttrigger'] != '5':
  275. tricks[userid]['lasttriggers'] += '5'
  276. tricks[userid]['currenttrigger'] = '5'
  277. tricks[userid]['time'].append(gettime())
  278. checktricks(userid)
  279. #Ct Triger
  280. elif vecmath.isbetweenRect(where, (-1711.96875, 207.96875, 5888.03125), (-1033.29418945, -5.25913906097, 5920.03125)) and tricks[userid]['currenttrigger'] != '6':
  281. tricks[userid]['lasttriggers'] += '6'
  282. tricks[userid]['currenttrigger'] = '6'
  283. tricks[userid]['time'].append(gettime())
  284. checktricks(userid)
  285. #es.msg(name+' Has gone in point 6')
  286. #T Triger
  287. elif vecmath.isbetweenRect(where, (-1711.99975586, -207.96875, 5888.03125), (-1037.74841309, -9.07034873962, 5920.03125)) and tricks[userid]['currenttrigger'] != '7':
  288. tricks[userid]['lasttriggers'] += '7'
  289. tricks[userid]['currenttrigger'] = '7'
  290. tricks[userid]['time'].append(gettime())
  291. checktricks(userid)
  292. #es.msg(name+' Has gone in point 7')
  293. #AWP pool T SIDE Triger
  294. elif vecmath.isbetweenRect(where, (2463.97387695, -4352.03125, 1888.03125), (1824.92590332, -4791.74902344, 2016.03125)) and tricks[userid]['currenttrigger'] != '8':
  295. tricks[userid]['lasttriggers'] += '8'
  296. tricks[userid]['currenttrigger'] = '8'
  297. tricks[userid]['time'].append(gettime())
  298. checktricks(userid)
  299. #es.msg(name+' Has gone in point 8')
  300. #AWP BOX T SIDE Triger
  301. elif vecmath.isbetweenRect(where, (-495.999664307, -8336.03125, -1599.96875), (148.405853271, -8776.38183594, -1471.96875)) and tricks[userid]['currenttrigger'] != '9':
  302. tricks[userid]['lasttriggers'] += '9'
  303. tricks[userid]['currenttrigger'] = '9'
  304. tricks[userid]['time'].append(gettime())
  305. checktricks(userid)
  306. #es.msg(name+' Has gone in point 9')
  307. #AWP ramp T SIDE Triger
  308. elif vecmath.isbetweenRect(where, (1819.20593262, -4322.34521484, 1888.03125), (-1642.31286621, -4803.55712891, 488.915740967)) and tricks[userid]['currenttrigger'] != '0':
  309. tricks[userid]['lasttriggers'] += '0'
  310. tricks[userid]['currenttrigger'] = '0'
  311. tricks[userid]['time'].append(gettime())
  312. checktricks(userid)
  313. #es.msg(name+' Has gone in point 0')
  314. #AWP ramp cT SIDE Triger
  315. elif vecmath.isbetweenRect(where, (-1632.60754395, 4288.19091797, -46.4395980835), (1823.96875, 4789.06591797, 1888.03125)) and tricks[userid]['currenttrigger'] != 'a':
  316. tricks[userid]['lasttriggers'] += 'a'
  317. tricks[userid]['currenttrigger'] = 'a'
  318. tricks[userid]['time'].append(gettime())
  319. checktricks(userid)
  320. #es.msg(name+' Has gone in point a')
  321. #AWP pool cT SIDE Triger
  322. elif vecmath.isbetweenRect(where, (2463.96875, 4767.96875, 1888.03125), (1845.4967041, 4328.50830078, 2016.03125)) and tricks[userid]['currenttrigger'] != 'b':
  323. tricks[userid]['lasttriggers'] += 'b'
  324. tricks[userid]['currenttrigger'] = 'b'
  325. tricks[userid]['time'].append(gettime())
  326. checktricks(userid)
  327. #es.msg(name+' Has gone in point b')
  328. #AWP box cT SIDE Triger
  329. elif vecmath.isbetweenRect(where, (-495.96875, 8751.98828125, -1599.96875), (147.067382813, 8311.66015625, -1471.96875)) and tricks[userid]['currenttrigger'] != 'c':
  330. tricks[userid]['lasttriggers'] += 'c'
  331. tricks[userid]['currenttrigger'] = 'c'
  332. tricks[userid]['time'].append(gettime())
  333. checktricks(userid)
  334. #es.msg(name+' Has gone in point c')
  335. #Triangles T SIDE Triger
  336. elif vecmath.isbetweenRect(where, (-2385.15722656, -3643.68798828, 688.03125), (-4883.10546875, -2420.86962891, -882.885742188)) and tricks[userid]['currenttrigger'] != 'd':
  337. tricks[userid]['lasttriggers'] += 'd'
  338. tricks[userid]['currenttrigger'] = 'd'
  339. tricks[userid]['time'].append(gettime())
  340. checktricks(userid)
  341. #es.msg(name+' Has gone in point d')
  342. #Triangles CT SIDE Triger
  343. elif vecmath.isbetweenRect(where, (-4866.59521484, 2435.82836914, -884.956970215), (-2389.23266602, 3641.50830078, 688.03125)) and tricks[userid]['currenttrigger'] != 'e':
  344. tricks[userid]['lasttriggers'] += 'e'
  345. tricks[userid]['currenttrigger'] = 'e'
  346. tricks[userid]['time'].append(gettime())
  347. checktricks(userid)
  348. #es.msg(name+' Has gone in point e')
  349. #deagle
  350. elif vecmath.isbetweenRect(where, (4524.40625, -447.232879639, 3494.28540039), (4024.60351563, 466.086273193, 3956.45458984)) and tricks[userid]['currenttrigger'] != 'f':
  351. tricks[userid]['lasttriggers'] += 'f'
  352. tricks[userid]['currenttrigger'] = 'f'
  353. tricks[userid]['time'].append(gettime())
  354. checktricks(userid)
  355. #es.msg(name+' Has gone in point f')
  356. #main triangle
  357. elif vecmath.isbetweenRect(where, (4565.15966797, -529.114379883, 5046.30761719), (3751.39990234, 548.926452637, 4113.79101563)) and tricks[userid]['currenttrigger'] != 'g':
  358. tricks[userid]['lasttriggers'] += 'g'
  359. tricks[userid]['currenttrigger'] = 'g'
  360. tricks[userid]['time'].append(gettime())
  361. checktricks(userid)
  362. #es.msg(name+' Has gone in point g')
  363. #pikachu
  364. elif vecmath.isbetweenRect(where, (-1132.33898926, 21.160577774, 6016.03125), (-1720.8840332, -19.4523143768, 6161.13330078)) and tricks[userid]['currenttrigger'] != 'h':
  365. tricks[userid]['lasttriggers'] += 'h'
  366. tricks[userid]['currenttrigger'] = 'h'
  367. tricks[userid]['time'].append(gettime())
  368. checktricks(userid)
  369. #es.msg(name+' Has gone in point h')
  370. def checktricks(userid):
  371. global tricks_races
  372. name = es.getplayername(userid)
  373. lasttrick = tricks[userid]['lasttrick']
  374. if tricks[userid]['trigerstilldelete'] > 0:
  375. tricks[userid]['trigerstilldelete'] -= 1
  376. trickdone = 0
  377. for trick in tricklist[lasttrick]['combo']:
  378. for sequence in tricklist[trick]['sequence']:
  379. if sequence in tricks[userid]['lasttriggers']:
  380. timelen = len(tricks[userid]['time'])-1
  381. time = tricks[userid]['time'][-1] - tricks[userid]['time'][timelen-(len(sequence)-1)]
  382. es.msg("#multi", "#default[#lightgreenSurf Tricks#default] #greenPlayer #default%s#green has done the trick #lightgreen%s #greenin #default%s #greenseconds!"%(name, trick, round(time, 2)))
  383. #EDIT BY CAPT MICRO
  384. ply = playerlib.getPlayer(userid)
  385. ply.cash += tricklist[trick]['prize']
  386. delrace = ""
  387. for race in tricks_races:
  388. if (tricks_races[race]['trick'] == trick):
  389. vs = race.split(',')
  390. if (vs[0] == ply.userid or vs[1] == ply.userid):
  391. if (tricks_races[race]['state'] == 'racing'):
  392. es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] #greenPlayer #default%s#green won the race!"%ply.name)
  393. tricks_races[race]['state'] = 'finished'
  394. delrace = race
  395. if (len(delrace) > 0): del tricks_races[delrace]
  396. #EDIT BY CAPT MICRO
  397. tricks[userid]['lasttrick'] = trick
  398. tricks[userid]['trigerstilldelete'] = tricklist[trick]['combotriggers']
  399. trickdone = 1
  400. break
  401. if trickdone == 1:
  402. break
  403. if tricks[userid]['trigerstilldelete'] == 0:
  404. tricks[userid]['lasttriggers'] = ''
  405. return
  406. for trick in tricklist:
  407. for sequence in tricklist[trick]['sequence']:
  408. if sequence in tricks[userid]['lasttriggers']:
  409. tricks[userid]['lasttrick'] = trick
  410. tricks[userid]['trigerstilldelete'] = tricklist[trick]['combotriggers']
  411. timelen = len(tricks[userid]['time'])-1
  412. time = tricks[userid]['time'][-1] - tricks[userid]['time'][timelen-(len(sequence)-1)]
  413. es.msg("#multi", "#default[#lightgreenSurf Tricks#default] #greenPlayer #default%s#green has done the trick #lightgreen%s #greenin #default%s #greenseconds!"%(name, trick, round(time, 2)))
  414. #EDIT BY CAPT MICRO
  415. ply = playerlib.getPlayer(userid)
  416. ply.cash += tricklist[trick]['prize']
  417. delrace = ""
  418. for race in tricks_races:
  419. if (tricks_races[race]['trick'] == trick):
  420. vs = race.split(',')
  421. if (vs[0] == ply.userid or vs[1] == ply.userid):
  422. if (tricks_races[race]['state'] == 'racing'):
  423. es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] #greenPlayer #default%s#green won the race!"%ply.name)
  424. tricks_races[race]['state'] = 'finished'
  425. delrace = race
  426. if (len(delrace) > 0): del tricks_races[delrace]
  427. #EDIT BY CAPT MICRO
  428. if tricks[userid]['trigerstilldelete'] == 0:
  429. tricks[userid]['lasttriggers'] = ''
  430. tricks[userid]['lasttriggers'] += tricks[userid]['currenttrigger']
  431. break
  432. def pointincycylinder(pointtocheck, radius, bottomcenterpoint, height):
  433. x, y, z = pointtocheck
  434. a, b, c = bottomcenterpoint
  435. if ((x-a)**2)+((y-b)**2)<=radius**2:
  436. if c < z < c+height:
  437. return True
  438. return False
  439.  
  440. def gettime():
  441. time_now_mic = time.time()
  442. return time_now_mic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement