Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import es, playerlib, popuplib, gamethread
- import urllib2, urllib
- from threading import Thread
- START_POS = "top" #top, default (spawns), or pikachu (middle of spawns)
- info = es.AddonInfo()
- info.name = "SurfTricks Extended"
- info.basename = "surftricks_ext"
- info.version = "HERPDERPDURR"
- info.url = "microvnet.info"
- info.description= "SUP3R L33T SURFTR1CKK5 3XT3ND3D"
- info.author = "Capt. Micro"
- info.contact = "arrowflyer@gmail.com"
- info.tags = "surf,tricks,surftricks,race,money"
- sql_url = "http://microvnet.info/fullsteel/motd.php"
- tricklist = {
- 'Awp2Awp':{
- 'racable':True,
- 'prize':500,
- },
- 'Awp3':{
- 'racable':True,
- 'prize':500,
- },
- 'Pikachu Gap':{
- 'racable':True,
- 'prize':500,
- },
- 'Tobe Go Home':{
- 'racable':True,
- 'prize':500,
- },
- 'Deagle to awp':{
- 'racable':True,
- 'prize':500,
- },
- 'T1000':{
- 'racable':True,
- 'prize':500,
- },
- 'T1000 to spawn':{
- 'racable':True,
- 'prize':500,
- },
- 'T1000 to sign':{
- 'racable':True,
- 'prize':500,
- },
- 'Awp4':{
- 'racable':True,
- 'prize':500,
- },
- 'Main to sign':{
- 'racable':True,
- 'prize':500,
- },
- 'Razor Gap':{
- 'racable':True,
- 'prize':500,
- },
- 'Awp To Awp Over Main':{
- 'racable':True,
- 'prize':500,
- },
- 'Spawn Hop Ct->T':{
- 'racable':True,
- 'prize':500,
- },
- 'Spawn Hop T->Ct':{
- 'racable':True,
- 'prize':500,
- },
- 'Nc Waave':{
- 'racable':True,
- 'prize':500,
- },
- 'Double Hop':{
- 'racable':True,
- 'prize':500,
- },
- 'Chrome Gap':{
- 'racable':True,
- 'prize':500,
- }
- }
- race_start_positions = {
- 'default': {
- 'player1': (-1073, 232, 6080),
- 'player2': (-1073, -232, 6080)
- },
- 'pikachu': {
- 'player1': (-1040, 8.0, 6080.093750),
- 'player2': (-1040, -7.9, 6080.093750)
- },
- 'top': {
- 'player1': (-1952, 150, 7272.093750),
- 'player2': (-1952, -150, 7272.093750)
- },
- }
- race_start_pos = race_start_positions[START_POS]
- race_winner_prize = 1500
- race_races = []
- race_playerselect = None
- race_trickselect = None
- race_menutmp = {}
- def race_newrace(userid1, userid2, trick):
- global race_races
- race_races += [{
- 'userid1': str(userid1),
- 'userid2': str(userid2),
- 'trick': trick,
- 'status': 'WAIT'
- }]
- ply1 = playerlib.getPlayer(userid1)
- ply2 = playerlib.getPlayer(userid2)
- es.tell(ply2.userid, "#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
- "[#lightgreen%s vs #lightgreen%s#default] #green%s #defaulthas challenged you to race #green%s #default!"
- %(ply1.name,ply2.name,ply1.name,trick))
- es.tell(ply2.userid, "#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
- "[#lightgreen%s vs #lightgreen%s#default] type \"!race accept\" to accept the challenge."
- %(ply1.name,ply2.name))
- def race_startrace(raceindex):
- global race_races
- ply1 = playerlib.getPlayer(race_races[raceindex]['userid1'])
- ply2 = playerlib.getPlayer(race_races[raceindex]['userid2'])
- #this resets both players tricks (kinda hacky yo)
- ply1.kill()
- ply2.kill()
- gamethread.delayed(1, ply1.freeze, 1)
- gamethread.delayed(1, ply2.freeze, 1)
- #move players to start positions
- ply1.setLocation(race_start_pos['player1'])
- ply2.setLocation(race_start_pos['player2'])
- gamethread.delayed(5, ply1.freeze, 0)
- gamethread.delayed(5, ply2.freeze, 0)
- #FIRE THE BOOLET
- race_races[raceindex]['status'] = 'RACE'
- es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
- "[#lightgreen%s vs #lightgreen%s#default] #default RACE STARTED!"
- %(ply1.name,ply2.name))
- def race_endrace(raceindex, winner):
- global race_races
- ply1 = playerlib.getPlayer(race_races[raceindex]['userid1'])
- ply2 = playerlib.getPlayer(race_races[raceindex]['userid2'])
- pwinner = playerlib.getPlayer(winner)
- es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
- "[#lightgreen%s vs #lightgreen%s#default] #green%s #default has won the race!"
- %(ply1.name,ply2.name,pwinner.name))
- pwinner.cash += race_winner_prize
- del race_races[raceindex]
- def playermenu_handler(userid, choice, menuname):
- global race_trickselect
- global race_menutmp
- race_menutmp[userid] = choice
- race_trickselect.send(userid)
- def trickmenu_handler(userid, choice, menuname):
- global race_menutmp
- opp = race_menutmp[userid]
- del race_menutmp[userid]
- race_newrace(userid, opp, choice)
- def load():
- #RACE trick selection menu
- global race_trickselect
- if (race_trickselect != None): race_trickselect.delete()
- race_trickselect = popuplib.easymenu('trickselect', None, trickmenu_handler)
- race_trickselect.settitle("[RACE] Trick Select")
- for trickname in tricklist:
- if (tricklist[trickname]['racable']):
- race_trickselect.addoption(trickname, trickname)
- #RACE player selection menu
- global race_playerselect
- if (race_playerselect != None): race_playerselect.delete()
- race_playerselect = popuplib.easymenu('playerselect', None, playermenu_handler)
- race_playerselect.settitle("[RACE] Player Select")
- for player in playerlib.getPlayerList('#human'):
- race_playerselect.addoption(player.userid, player.name)
- def unload():
- global race_playerselect
- if (race_playerselect != None): race_playerselect.delete()
- global race_trickselect
- if (race_trickselect != None): race_trickselect.delete()
- pass
- def player_activate(e):
- #RACE player selection menu
- global race_playerselect
- if (race_playerselect != None): race_playerselect.delete()
- race_playerselect = popuplib.easymenu('playerselect', None, playermenu_handler)
- race_playerselect.settitle("[RACE] Player Select")
- for player in playerlib.getPlayerList('#human'):
- race_playerselect.addoption(player.userid, player.name)
- def player_disconnect(e):
- #RACE player selection menu
- global race_playerselect
- if (race_playerselect != None): race_playerselect.delete()
- race_playerselect = popuplib.easymenu('playerselect', None, playermenu_handler)
- race_playerselect.settitle("[RACE] Player Select")
- for player in playerlib.getPlayerList('#human'):
- race_playerselect.addoption(player.userid, player.name)
- def es_player_chat(e):
- text = e['text']
- ply = playerlib.getPlayer(e['userid'])
- if (text[0:5] == '!race'):
- args = text.split(' ')
- if (len(args) == 1):
- global race_playerselect
- race_playerselect.send(ply.userid)
- elif (len(args) == 2):
- if (args[1] == 'accept'):
- global race_races
- for race in race_races:
- if (race['userid2'] == str(ply.userid)):
- ply1 = playerlib.getPlayer(race['userid1'])
- ply2 = playerlib.getPlayer(race['userid2'])
- es.msg("#multi", "#default[#lightgreenSurf Tricks Racing#default] " +
- "[#lightgreen%s vs #lightgreen%s#default]#green #default%s has accepted the race!"
- %(ply1.name,ply2.name,ply.name))
- race_startrace(race_races.index(race))
- class SqlRequestAgent(Thread):
- def __init__(self, url1, url2, url3):
- Thread.__init__(self)
- self.url1 = url1
- self.url2 = url2
- self.url3 = url3
- def run(self):
- urllib2.urlopen(urllib.quote(self.url1)).read()
- urllib2.urlopen(urllib.quote(self.url2)).read()
- urllib2.urlopen(urllib.quote(self.url3)).read()
- def surftricks_trick(e):
- ply = playerlib.getPlayer(e['userid'])
- #update SQL aww yeah
- sra = SqlRequestAgent(sql_url+'?dbedit=sidlookup'+'&steamid='+ply.steamid+'&name='+ply.name
- ,sql_url+'?dbedit=tricks'+'&steamid='+ply.steamid+'&trick='+e['trick']+'&time='+str(e['time'])
- ,sql_url+'?dbedit=rank'+'&steamid='+ply.steamid+'&rank='+str(tricklist[e['trick']]['prize'])
- )
- sra.start()
- #Cash money prize
- ply = playerlib.getPlayer(e['userid'])
- ply.cash += tricklist[e['trick']]['prize']
- #Racing stuffffff
- global race_races
- for race in race_races:
- if (race['trick'] == e['trick'] and race['status'] == 'RACE'):
- if (race['userid1'] == str(ply.userid) or race['userid2'] == str(ply.userid)):
- race_endrace(race_races.index(race), str(ply.userid))
- race['status'] = 'OVER'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement