Advertisement
captmicro

Untitled

Sep 18th, 2011
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.28 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. es.loadevents('declare', 'addons/eventscripts/surftricks/surftricks_trick.txt')
  153.  
  154. def point():
  155. userid = es.getcmduserid()
  156. x,y,z = es.getplayerlocation(userid)
  157. es.msg(es.getplayername(userid)+' (%s, %s, %s)'%(x,y,z))
  158.  
  159. def player_spawn(ev):
  160. userid = ev['userid']
  161. tricks[ev['userid']] = {}
  162. tricks[ev['userid']]['currenttrigger'] = ''
  163. tricks[ev['userid']]['lasttriggers'] = ''
  164. tricks[ev['userid']]['lasttrick'] = ''
  165. tricks[ev['userid']]['trigerstilldelete'] = 0
  166. tricks[ev['userid']]['time'] = []
  167.  
  168. def firetrick(userid, trick, time)
  169. es.event('initalize', 'surftricks_trick')
  170. es.event('setstring', 'surftricks_trick', 'userid', userid)
  171. es.event('setstring', 'surftricks_trick', 'trick', trick)
  172. es.event('setfloat', 'surftricks_trick', 'time', time)
  173. es.event('fire', 'surftricks_trick')
  174.  
  175. def player_move(ev):
  176. userid = ev['userid']
  177. name = es.getplayername(userid)
  178. player = playerlib.getPlayer(userid)
  179. if player.attributes['isdead'] == 1:
  180. return
  181. where = vecmath.vector(es.getplayerlocation(userid))
  182. #Top Triger
  183. if vecmath.isbetweenRect(where, (-1873.38208008, 186.852890015, 7208.03125), (-2422.34472656, -210.814849854, 7386.06152344)) and tricks[userid]['currenttrigger'] != '1':
  184. tricks[userid]['lasttriggers'] += '1'
  185. tricks[userid]['currenttrigger'] = '1'
  186. tricks[userid]['time'].append(gettime())
  187. checktricks(userid)
  188. #es.msg(name+' Has gone in point 1')
  189. #Top2 Triger
  190. elif vecmath.isbetweenRect(where, (-1870.42553711, -191.403823853, 7208.03125), (-1709.19848633, 193.75177002, 7209.43017578)) and tricks[userid]['currenttrigger'] != '2':
  191. tricks[userid]['lasttriggers'] += '2'
  192. tricks[userid]['currenttrigger'] = '2'
  193. tricks[userid]['time'].append(gettime())
  194. checktricks(userid)
  195. #es.msg(name+' Has gone in point 2')
  196. #MainRamp Triger
  197. elif vecmath.isbetweenRect(where, (-1045.970215, 227.254944, 5873.747559), (2488.334717, -261.856018, 4312.144043)) and tricks[userid]['currenttrigger'] != '3':
  198. tricks[userid]['lasttriggers'] += '3'
  199. tricks[userid]['currenttrigger'] = '3'
  200. tricks[userid]['time'].append(gettime())
  201. checktricks(userid)
  202. #es.msg(name+' Has gone in point 3')
  203. #Sign Triger
  204. elif vecmath.isbetweenRect(where, (629.737793, 236.375458, 6182.140625), (536.640015, -260.946259, 6084.806152)) and tricks[userid]['currenttrigger'] != '4':
  205. tricks[userid]['lasttriggers'] += '4'
  206. tricks[userid]['currenttrigger'] = '4'
  207. tricks[userid]['time'].append(gettime())
  208. checktricks(userid)
  209. #es.msg(name+' Has gone in point 4')
  210. #pool trigger
  211. elif pointincycylinder(where, 1056, (-6496, 0, -1743.96875), 686.96875) and tricks[userid]['currenttrigger'] != '5':
  212. tricks[userid]['lasttriggers'] += '5'
  213. tricks[userid]['currenttrigger'] = '5'
  214. tricks[userid]['time'].append(gettime())
  215. checktricks(userid)
  216. #Ct Triger
  217. elif vecmath.isbetweenRect(where, (-1711.96875, 207.96875, 5888.03125), (-1033.29418945, -5.25913906097, 5920.03125)) and tricks[userid]['currenttrigger'] != '6':
  218. tricks[userid]['lasttriggers'] += '6'
  219. tricks[userid]['currenttrigger'] = '6'
  220. tricks[userid]['time'].append(gettime())
  221. checktricks(userid)
  222. #es.msg(name+' Has gone in point 6')
  223. #T Triger
  224. elif vecmath.isbetweenRect(where, (-1711.99975586, -207.96875, 5888.03125), (-1037.74841309, -9.07034873962, 5920.03125)) and tricks[userid]['currenttrigger'] != '7':
  225. tricks[userid]['lasttriggers'] += '7'
  226. tricks[userid]['currenttrigger'] = '7'
  227. tricks[userid]['time'].append(gettime())
  228. checktricks(userid)
  229. #es.msg(name+' Has gone in point 7')
  230. #AWP pool T SIDE Triger
  231. elif vecmath.isbetweenRect(where, (2463.97387695, -4352.03125, 1888.03125), (1824.92590332, -4791.74902344, 2016.03125)) and tricks[userid]['currenttrigger'] != '8':
  232. tricks[userid]['lasttriggers'] += '8'
  233. tricks[userid]['currenttrigger'] = '8'
  234. tricks[userid]['time'].append(gettime())
  235. checktricks(userid)
  236. #es.msg(name+' Has gone in point 8')
  237. #AWP BOX T SIDE Triger
  238. elif vecmath.isbetweenRect(where, (-495.999664307, -8336.03125, -1599.96875), (148.405853271, -8776.38183594, -1471.96875)) and tricks[userid]['currenttrigger'] != '9':
  239. tricks[userid]['lasttriggers'] += '9'
  240. tricks[userid]['currenttrigger'] = '9'
  241. tricks[userid]['time'].append(gettime())
  242. checktricks(userid)
  243. #es.msg(name+' Has gone in point 9')
  244. #AWP ramp T SIDE Triger
  245. elif vecmath.isbetweenRect(where, (1819.20593262, -4322.34521484, 1888.03125), (-1642.31286621, -4803.55712891, 488.915740967)) and tricks[userid]['currenttrigger'] != '0':
  246. tricks[userid]['lasttriggers'] += '0'
  247. tricks[userid]['currenttrigger'] = '0'
  248. tricks[userid]['time'].append(gettime())
  249. checktricks(userid)
  250. #es.msg(name+' Has gone in point 0')
  251. #AWP ramp cT SIDE Triger
  252. elif vecmath.isbetweenRect(where, (-1632.60754395, 4288.19091797, -46.4395980835), (1823.96875, 4789.06591797, 1888.03125)) and tricks[userid]['currenttrigger'] != 'a':
  253. tricks[userid]['lasttriggers'] += 'a'
  254. tricks[userid]['currenttrigger'] = 'a'
  255. tricks[userid]['time'].append(gettime())
  256. checktricks(userid)
  257. #es.msg(name+' Has gone in point a')
  258. #AWP pool cT SIDE Triger
  259. elif vecmath.isbetweenRect(where, (2463.96875, 4767.96875, 1888.03125), (1845.4967041, 4328.50830078, 2016.03125)) and tricks[userid]['currenttrigger'] != 'b':
  260. tricks[userid]['lasttriggers'] += 'b'
  261. tricks[userid]['currenttrigger'] = 'b'
  262. tricks[userid]['time'].append(gettime())
  263. checktricks(userid)
  264. #es.msg(name+' Has gone in point b')
  265. #AWP box cT SIDE Triger
  266. elif vecmath.isbetweenRect(where, (-495.96875, 8751.98828125, -1599.96875), (147.067382813, 8311.66015625, -1471.96875)) and tricks[userid]['currenttrigger'] != 'c':
  267. tricks[userid]['lasttriggers'] += 'c'
  268. tricks[userid]['currenttrigger'] = 'c'
  269. tricks[userid]['time'].append(gettime())
  270. checktricks(userid)
  271. #es.msg(name+' Has gone in point c')
  272. #Triangles T SIDE Triger
  273. elif vecmath.isbetweenRect(where, (-2385.15722656, -3643.68798828, 688.03125), (-4883.10546875, -2420.86962891, -882.885742188)) and tricks[userid]['currenttrigger'] != 'd':
  274. tricks[userid]['lasttriggers'] += 'd'
  275. tricks[userid]['currenttrigger'] = 'd'
  276. tricks[userid]['time'].append(gettime())
  277. checktricks(userid)
  278. #es.msg(name+' Has gone in point d')
  279. #Triangles CT SIDE Triger
  280. elif vecmath.isbetweenRect(where, (-4866.59521484, 2435.82836914, -884.956970215), (-2389.23266602, 3641.50830078, 688.03125)) and tricks[userid]['currenttrigger'] != 'e':
  281. tricks[userid]['lasttriggers'] += 'e'
  282. tricks[userid]['currenttrigger'] = 'e'
  283. tricks[userid]['time'].append(gettime())
  284. checktricks(userid)
  285. #es.msg(name+' Has gone in point e')
  286. #deagle
  287. elif vecmath.isbetweenRect(where, (4524.40625, -447.232879639, 3494.28540039), (4024.60351563, 466.086273193, 3956.45458984)) and tricks[userid]['currenttrigger'] != 'f':
  288. tricks[userid]['lasttriggers'] += 'f'
  289. tricks[userid]['currenttrigger'] = 'f'
  290. tricks[userid]['time'].append(gettime())
  291. checktricks(userid)
  292. #es.msg(name+' Has gone in point f')
  293. #main triangle
  294. elif vecmath.isbetweenRect(where, (4565.15966797, -529.114379883, 5046.30761719), (3751.39990234, 548.926452637, 4113.79101563)) and tricks[userid]['currenttrigger'] != 'g':
  295. tricks[userid]['lasttriggers'] += 'g'
  296. tricks[userid]['currenttrigger'] = 'g'
  297. tricks[userid]['time'].append(gettime())
  298. checktricks(userid)
  299. #es.msg(name+' Has gone in point g')
  300. #pikachu
  301. elif vecmath.isbetweenRect(where, (-1132.33898926, 21.160577774, 6016.03125), (-1720.8840332, -19.4523143768, 6161.13330078)) and tricks[userid]['currenttrigger'] != 'h':
  302. tricks[userid]['lasttriggers'] += 'h'
  303. tricks[userid]['currenttrigger'] = 'h'
  304. tricks[userid]['time'].append(gettime())
  305. checktricks(userid)
  306. #es.msg(name+' Has gone in point h')
  307. def checktricks(userid):
  308. global tricks_races
  309. name = es.getplayername(userid)
  310. lasttrick = tricks[userid]['lasttrick']
  311. if tricks[userid]['trigerstilldelete'] > 0:
  312. tricks[userid]['trigerstilldelete'] -= 1
  313. trickdone = 0
  314. for trick in tricklist[lasttrick]['combo']:
  315. for sequence in tricklist[trick]['sequence']:
  316. if sequence in tricks[userid]['lasttriggers']:
  317. timelen = len(tricks[userid]['time'])-1
  318. time = tricks[userid]['time'][-1] - tricks[userid]['time'][timelen-(len(sequence)-1)]
  319. 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)))
  320. #EDIT BY CAPT MICRO
  321. firetrick(userid, trick, time)
  322. #EDIT BY CAPT MICRO
  323. tricks[userid]['lasttrick'] = trick
  324. tricks[userid]['trigerstilldelete'] = tricklist[trick]['combotriggers']
  325. trickdone = 1
  326. break
  327. if trickdone == 1:
  328. break
  329. if tricks[userid]['trigerstilldelete'] == 0:
  330. tricks[userid]['lasttriggers'] = ''
  331. return
  332. for trick in tricklist:
  333. for sequence in tricklist[trick]['sequence']:
  334. if sequence in tricks[userid]['lasttriggers']:
  335. tricks[userid]['lasttrick'] = trick
  336. tricks[userid]['trigerstilldelete'] = tricklist[trick]['combotriggers']
  337. timelen = len(tricks[userid]['time'])-1
  338. time = tricks[userid]['time'][-1] - tricks[userid]['time'][timelen-(len(sequence)-1)]
  339. 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)))
  340. #EDIT BY CAPT MICRO
  341. firetrick(userid, trick, time)
  342. #EDIT BY CAPT MICRO
  343. if tricks[userid]['trigerstilldelete'] == 0:
  344. tricks[userid]['lasttriggers'] = ''
  345. tricks[userid]['lasttriggers'] += tricks[userid]['currenttrigger']
  346. break
  347. def pointincycylinder(pointtocheck, radius, bottomcenterpoint, height):
  348. x, y, z = pointtocheck
  349. a, b, c = bottomcenterpoint
  350. if ((x-a)**2)+((y-b)**2)<=radius**2:
  351. if c < z < c+height:
  352. return True
  353. return False
  354.  
  355. def gettime():
  356. time_now_mic = time.time()
  357. return time_now_mic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement