Advertisement
captmicro

Untitled

Sep 18th, 2011
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.11 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. },
  49. 'Awp3':{
  50. 'sequence':['0a0','a0a'],
  51. 'combo':['Awp4'],
  52. 'combotriggers':1,
  53. },
  54. 'Pikachu Gap':{
  55. 'sequence':['2h'],
  56. 'combo':[],
  57. 'combotriggers':0,
  58. },
  59. 'Tobe Go Home':{
  60. 'sequence':['5d09','5eac'],
  61. 'combo':[],
  62. 'combotriggers':0,
  63. },
  64. 'Deagle to awp':{
  65. 'sequence':['f0','fa'],
  66. 'combo':[],
  67. 'combotriggers':0,
  68. },
  69. 'T1000':{
  70. 'sequence':['f3'],
  71. 'combo':['T1000 to spawn','T1000 to sign'],
  72. 'combotriggers':1,
  73. },
  74. 'T1000 to spawn':{
  75. 'sequence':['f36','f37'],
  76. 'combo':[],
  77. 'combotriggers':0,
  78. },
  79. 'T1000 to sign':{
  80. 'sequence':['f34'],
  81. 'combo':[],
  82. 'combotriggers':0,
  83. },
  84. 'Awp4':{
  85. 'sequence':['a0a0','0a0a'],
  86. 'combo':[],
  87. 'combotriggers':0,
  88. },
  89. 'Main to sign':{
  90. 'sequence':['34'],
  91. 'combo':[],
  92. 'combotriggers':0,
  93. },
  94. 'Razor Gap':{
  95. 'sequence':['235'],
  96. 'combo':[],
  97. 'combotriggers':0,
  98. },
  99. 'Awp To Awp Over Main':{
  100. 'sequence':['03a','a30'],
  101. 'combo':[],
  102. 'combotriggers':0,
  103. },
  104. 'Spawn Hop Ct->T':{
  105. 'sequence':['67'],
  106. 'combo':[],
  107. 'combotriggers':0,
  108. },
  109. 'Spawn Hop T->Ct':{
  110. 'sequence':['76'],
  111. 'combo':[],
  112. 'combotriggers':0,
  113. },
  114. 'Nc Waave':{
  115. 'sequence':['63d', '73e'],
  116. 'combo':[],
  117. 'combotriggers':0,
  118. },
  119. 'Double Hop':{
  120. 'sequence':['51513'],
  121. 'combo':[],
  122. 'combotriggers':0,
  123. },
  124. 'Chrome Gap':{
  125. 'sequence':['2389', '23bc'],
  126. 'combo':[],
  127. 'combotriggers':0,
  128. }
  129. }
  130.  
  131. def load():
  132. es.regsaycmd('!point', 'surftricks/point', 'This opens the menu')
  133. es.server.queuecmd("es_load extendedevents")
  134. es.server.queuecmd("extendedevents_load player_move")
  135. es.loadevents('declare', 'addons/eventscripts/surftricks/surftricks_trick.res')
  136.  
  137. def es_map_start(e):
  138. es.loadevents('addons/eventscripts/surftricks/surftricks_trick.res')
  139.  
  140. def point():
  141. userid = es.getcmduserid()
  142. x,y,z = es.getplayerlocation(userid)
  143. es.msg(es.getplayername(userid)+' (%s, %s, %s)'%(x,y,z))
  144.  
  145. def player_spawn(ev):
  146. userid = ev['userid']
  147. tricks[ev['userid']] = {}
  148. tricks[ev['userid']]['currenttrigger'] = ''
  149. tricks[ev['userid']]['lasttriggers'] = ''
  150. tricks[ev['userid']]['lasttrick'] = ''
  151. tricks[ev['userid']]['trigerstilldelete'] = 0
  152. tricks[ev['userid']]['time'] = []
  153.  
  154. def firetrick(userid, trick, time):
  155. es.event('initalize', 'surftricks_trick')
  156. es.event('setstring', 'surftricks_trick', 'userid', userid)
  157. es.event('setstring', 'surftricks_trick', 'trick', trick)
  158. es.event('setfloat', 'surftricks_trick', 'time', time)
  159. es.event('fire', 'surftricks_trick')
  160.  
  161. def player_move(ev):
  162. userid = ev['userid']
  163. name = es.getplayername(userid)
  164. player = playerlib.getPlayer(userid)
  165. if player.attributes['isdead'] == 1:
  166. return
  167. where = vecmath.vector(es.getplayerlocation(userid))
  168. #Top Triger
  169. if vecmath.isbetweenRect(where, (-1873.38208008, 186.852890015, 7208.03125), (-2422.34472656, -210.814849854, 7386.06152344)) and tricks[userid]['currenttrigger'] != '1':
  170. tricks[userid]['lasttriggers'] += '1'
  171. tricks[userid]['currenttrigger'] = '1'
  172. tricks[userid]['time'].append(gettime())
  173. checktricks(userid)
  174. #es.msg(name+' Has gone in point 1')
  175. #Top2 Triger
  176. elif vecmath.isbetweenRect(where, (-1870.42553711, -191.403823853, 7208.03125), (-1709.19848633, 193.75177002, 7209.43017578)) and tricks[userid]['currenttrigger'] != '2':
  177. tricks[userid]['lasttriggers'] += '2'
  178. tricks[userid]['currenttrigger'] = '2'
  179. tricks[userid]['time'].append(gettime())
  180. checktricks(userid)
  181. #es.msg(name+' Has gone in point 2')
  182. #MainRamp Triger
  183. elif vecmath.isbetweenRect(where, (-1045.970215, 227.254944, 5873.747559), (2488.334717, -261.856018, 4312.144043)) and tricks[userid]['currenttrigger'] != '3':
  184. tricks[userid]['lasttriggers'] += '3'
  185. tricks[userid]['currenttrigger'] = '3'
  186. tricks[userid]['time'].append(gettime())
  187. checktricks(userid)
  188. #es.msg(name+' Has gone in point 3')
  189. #Sign Triger
  190. elif vecmath.isbetweenRect(where, (629.737793, 236.375458, 6182.140625), (536.640015, -260.946259, 6084.806152)) and tricks[userid]['currenttrigger'] != '4':
  191. tricks[userid]['lasttriggers'] += '4'
  192. tricks[userid]['currenttrigger'] = '4'
  193. tricks[userid]['time'].append(gettime())
  194. checktricks(userid)
  195. #es.msg(name+' Has gone in point 4')
  196. #pool trigger
  197. elif pointincycylinder(where, 1056, (-6496, 0, -1743.96875), 686.96875) and tricks[userid]['currenttrigger'] != '5':
  198. tricks[userid]['lasttriggers'] += '5'
  199. tricks[userid]['currenttrigger'] = '5'
  200. tricks[userid]['time'].append(gettime())
  201. checktricks(userid)
  202. #Ct Triger
  203. elif vecmath.isbetweenRect(where, (-1711.96875, 207.96875, 5888.03125), (-1033.29418945, -5.25913906097, 5920.03125)) and tricks[userid]['currenttrigger'] != '6':
  204. tricks[userid]['lasttriggers'] += '6'
  205. tricks[userid]['currenttrigger'] = '6'
  206. tricks[userid]['time'].append(gettime())
  207. checktricks(userid)
  208. #es.msg(name+' Has gone in point 6')
  209. #T Triger
  210. elif vecmath.isbetweenRect(where, (-1711.99975586, -207.96875, 5888.03125), (-1037.74841309, -9.07034873962, 5920.03125)) and tricks[userid]['currenttrigger'] != '7':
  211. tricks[userid]['lasttriggers'] += '7'
  212. tricks[userid]['currenttrigger'] = '7'
  213. tricks[userid]['time'].append(gettime())
  214. checktricks(userid)
  215. #es.msg(name+' Has gone in point 7')
  216. #AWP pool T SIDE Triger
  217. elif vecmath.isbetweenRect(where, (2463.97387695, -4352.03125, 1888.03125), (1824.92590332, -4791.74902344, 2016.03125)) and tricks[userid]['currenttrigger'] != '8':
  218. tricks[userid]['lasttriggers'] += '8'
  219. tricks[userid]['currenttrigger'] = '8'
  220. tricks[userid]['time'].append(gettime())
  221. checktricks(userid)
  222. #es.msg(name+' Has gone in point 8')
  223. #AWP BOX T SIDE Triger
  224. elif vecmath.isbetweenRect(where, (-495.999664307, -8336.03125, -1599.96875), (148.405853271, -8776.38183594, -1471.96875)) and tricks[userid]['currenttrigger'] != '9':
  225. tricks[userid]['lasttriggers'] += '9'
  226. tricks[userid]['currenttrigger'] = '9'
  227. tricks[userid]['time'].append(gettime())
  228. checktricks(userid)
  229. #es.msg(name+' Has gone in point 9')
  230. #AWP ramp T SIDE Triger
  231. elif vecmath.isbetweenRect(where, (1819.20593262, -4322.34521484, 1888.03125), (-1642.31286621, -4803.55712891, 488.915740967)) and tricks[userid]['currenttrigger'] != '0':
  232. tricks[userid]['lasttriggers'] += '0'
  233. tricks[userid]['currenttrigger'] = '0'
  234. tricks[userid]['time'].append(gettime())
  235. checktricks(userid)
  236. #es.msg(name+' Has gone in point 0')
  237. #AWP ramp cT SIDE Triger
  238. elif vecmath.isbetweenRect(where, (-1632.60754395, 4288.19091797, -46.4395980835), (1823.96875, 4789.06591797, 1888.03125)) and tricks[userid]['currenttrigger'] != 'a':
  239. tricks[userid]['lasttriggers'] += 'a'
  240. tricks[userid]['currenttrigger'] = 'a'
  241. tricks[userid]['time'].append(gettime())
  242. checktricks(userid)
  243. #es.msg(name+' Has gone in point a')
  244. #AWP pool cT SIDE Triger
  245. elif vecmath.isbetweenRect(where, (2463.96875, 4767.96875, 1888.03125), (1845.4967041, 4328.50830078, 2016.03125)) and tricks[userid]['currenttrigger'] != 'b':
  246. tricks[userid]['lasttriggers'] += 'b'
  247. tricks[userid]['currenttrigger'] = 'b'
  248. tricks[userid]['time'].append(gettime())
  249. checktricks(userid)
  250. #es.msg(name+' Has gone in point b')
  251. #AWP box cT SIDE Triger
  252. elif vecmath.isbetweenRect(where, (-495.96875, 8751.98828125, -1599.96875), (147.067382813, 8311.66015625, -1471.96875)) and tricks[userid]['currenttrigger'] != 'c':
  253. tricks[userid]['lasttriggers'] += 'c'
  254. tricks[userid]['currenttrigger'] = 'c'
  255. tricks[userid]['time'].append(gettime())
  256. checktricks(userid)
  257. #es.msg(name+' Has gone in point c')
  258. #Triangles T SIDE Triger
  259. elif vecmath.isbetweenRect(where, (-2385.15722656, -3643.68798828, 688.03125), (-4883.10546875, -2420.86962891, -882.885742188)) and tricks[userid]['currenttrigger'] != 'd':
  260. tricks[userid]['lasttriggers'] += 'd'
  261. tricks[userid]['currenttrigger'] = 'd'
  262. tricks[userid]['time'].append(gettime())
  263. checktricks(userid)
  264. #es.msg(name+' Has gone in point d')
  265. #Triangles CT SIDE Triger
  266. elif vecmath.isbetweenRect(where, (-4866.59521484, 2435.82836914, -884.956970215), (-2389.23266602, 3641.50830078, 688.03125)) and tricks[userid]['currenttrigger'] != 'e':
  267. tricks[userid]['lasttriggers'] += 'e'
  268. tricks[userid]['currenttrigger'] = 'e'
  269. tricks[userid]['time'].append(gettime())
  270. checktricks(userid)
  271. #es.msg(name+' Has gone in point e')
  272. #deagle
  273. elif vecmath.isbetweenRect(where, (4524.40625, -447.232879639, 3494.28540039), (4024.60351563, 466.086273193, 3956.45458984)) and tricks[userid]['currenttrigger'] != 'f':
  274. tricks[userid]['lasttriggers'] += 'f'
  275. tricks[userid]['currenttrigger'] = 'f'
  276. tricks[userid]['time'].append(gettime())
  277. checktricks(userid)
  278. #es.msg(name+' Has gone in point f')
  279. #main triangle
  280. elif vecmath.isbetweenRect(where, (4565.15966797, -529.114379883, 5046.30761719), (3751.39990234, 548.926452637, 4113.79101563)) and tricks[userid]['currenttrigger'] != 'g':
  281. tricks[userid]['lasttriggers'] += 'g'
  282. tricks[userid]['currenttrigger'] = 'g'
  283. tricks[userid]['time'].append(gettime())
  284. checktricks(userid)
  285. #es.msg(name+' Has gone in point g')
  286. #pikachu
  287. elif vecmath.isbetweenRect(where, (-1132.33898926, 21.160577774, 6016.03125), (-1720.8840332, -19.4523143768, 6161.13330078)) and tricks[userid]['currenttrigger'] != 'h':
  288. tricks[userid]['lasttriggers'] += 'h'
  289. tricks[userid]['currenttrigger'] = 'h'
  290. tricks[userid]['time'].append(gettime())
  291. checktricks(userid)
  292. #es.msg(name+' Has gone in point h')
  293. def checktricks(userid):
  294. global tricks_races
  295. name = es.getplayername(userid)
  296. lasttrick = tricks[userid]['lasttrick']
  297. if tricks[userid]['trigerstilldelete'] > 0:
  298. tricks[userid]['trigerstilldelete'] -= 1
  299. trickdone = 0
  300. for trick in tricklist[lasttrick]['combo']:
  301. for sequence in tricklist[trick]['sequence']:
  302. if sequence in tricks[userid]['lasttriggers']:
  303. timelen = len(tricks[userid]['time'])-1
  304. time = tricks[userid]['time'][-1] - tricks[userid]['time'][timelen-(len(sequence)-1)]
  305. 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)))
  306. #EDIT BY CAPT MICRO
  307. firetrick(userid, trick, time)
  308. #EDIT BY CAPT MICRO
  309. tricks[userid]['lasttrick'] = trick
  310. tricks[userid]['trigerstilldelete'] = tricklist[trick]['combotriggers']
  311. trickdone = 1
  312. break
  313. if trickdone == 1:
  314. break
  315. if tricks[userid]['trigerstilldelete'] == 0:
  316. tricks[userid]['lasttriggers'] = ''
  317. return
  318. for trick in tricklist:
  319. for sequence in tricklist[trick]['sequence']:
  320. if sequence in tricks[userid]['lasttriggers']:
  321. tricks[userid]['lasttrick'] = trick
  322. tricks[userid]['trigerstilldelete'] = tricklist[trick]['combotriggers']
  323. timelen = len(tricks[userid]['time'])-1
  324. time = tricks[userid]['time'][-1] - tricks[userid]['time'][timelen-(len(sequence)-1)]
  325. 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)))
  326. #EDIT BY CAPT MICRO
  327. firetrick(userid, trick, time)
  328. #EDIT BY CAPT MICRO
  329. if tricks[userid]['trigerstilldelete'] == 0:
  330. tricks[userid]['lasttriggers'] = ''
  331. tricks[userid]['lasttriggers'] += tricks[userid]['currenttrigger']
  332. break
  333. def pointincycylinder(pointtocheck, radius, bottomcenterpoint, height):
  334. x, y, z = pointtocheck
  335. a, b, c = bottomcenterpoint
  336. if ((x-a)**2)+((y-b)**2)<=radius**2:
  337. if c < z < c+height:
  338. return True
  339. return False
  340.  
  341. def gettime():
  342. time_now_mic = time.time()
  343. return time_now_mic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement