#!/usr/bin/env python import playerlib import string import usermsg import es import keyvalues import gamethread import popuplib import psyco psyco.full() PlayerData = {} es.ServerVar("qcp_ver", 2.7, "qcp Version").makepublic() def saytext2(userid,index,msg,arg1="",arg2="",arg3="",arg4=""): if es.exists('userid',userid): es.usermsg('create','saytext2','SayText2') es.usermsg('write','byte','saytext2',index) es.usermsg('write','byte','saytext2',True) es.usermsg('write','string','saytext2',msg) es.usermsg('write','string','saytext2','') es.usermsg('write','string','saytext2','') es.usermsg('write','string','saytext2','') es.usermsg('write','string','saytext2','') es.usermsg('send','saytext2',userid) es.usermsg('delete','saytext2') else: es.dbgmsg(0,"usermsg.py: saytext2: Player: \""+userid+"\" was not found on the server.") #Load when the script is started es.forcevalue('mp_limitteams',0) es.forcevalue('mp_autoteambalance',0) es.forcevalue('mp_falldamage',0) def load(): es.regclientcmd("saveloc",'checkpoint/savepos',"Saves users current location, and veiw angle.") es.regclientcmd("cp",'checkpoint/teleport',"Teleports the player to a saved location") es.regclientcmd("cp_menu",'checkpoint/menu',"CheckPoint Menu") es.regsaycmd("!save",'checkpoint/savepos',"Saves users current location, and veiw angle.") es.regsaycmd("!cp",'checkpoint/teleport',"Teleports the player to a saved location") es.regsaycmd("!help",'checkpoint/help',"Displays a help menu") es.regsaycmd("!menu",'checkpoint/menu',"CheckPoint Menu") es.regsaycmd("!block",'checkpoint/Collision',"Toggles a players CollisionGroup") es.server.cmd('est_RegEventBlock player_falldamage "es_xdoblock checkpoint/hook_hurt"') es.doblock('corelib/noisy_on') def unload(): es.server.cmd('est_UnRegEventBlock player_falldamage "es_xdoblock checkpoint/hook_hurt"') def menu(): pl = es.getcmduserid() menu = popuplib.create('cp_menu') menu.addline('Quick Teleporting Menu:') menu.addline(' ') menu.addline('-> 1. Save Location') menu.addline('-> 2. Teleport') menu.addline(' ------- ') menu.addline(' ') menu.addline('->7. Other Options') menu.menuselect = MenuSelect popuplib.send('cp_menu', pl) def MenuSelect(pl, choice, id): if choice == 1: savepos2(pl) popuplib.send('cp_menu', pl) if choice == 2: teleport2(pl) popuplib.send('cp_menu', pl) if choice == 7: menu2 = popuplib.create('cp_menu2') menu2.addline('Other Options Menu:') menu2.addline(' ') menu2.addline('-> 1. Turn On/Off Blocking') menu2.addline('-> 2. Clear CheckPoints/Start Over') menu2.addline(' ------- ') menu2.addline(' ') menu2.addline('->7. Back') menu2.menuselect = MenuSelect2 popuplib.send('cp_menu2', pl) def MenuSelect2(pl, choice, id): if choice == 1: Collision2(pl) popuplib.send('cp_menu2', pl) if choice == 2: Restart(pl) popuplib.send('cp_menu2', pl) if choice == 7: popuplib.send('cp_menu', pl) def hook_hurt(): pl = es.ServerVar("fall_userid", 0) es.server.cmd("est_geteventinfo fall_userid userid") health = es.getplayerprop(pl, "CBasePlayer.m_iHealth") damage = es.ServerVar("fall_damage", 0) es.server.cmd("est_geteventinfo fall_damage damage") es.setplayerprop(pl,"CBasePlayer.m_iHealth",health+damage) def help(): pl = es.getcmduserid() es.menu(60,ev['userid'],'-HaloShadow\'s Quick CheckPoints-\n \nChat Commands:\n \n !help - Displays this menu again\n !menu - Displays a checkpoint menu\n !save - Saves CheckPoint\n !cp - Teleports To Save\n !block - Toggles your solidity\n \nConsole Commands:\n \n cp_menu - Displays a checkpoint menu\n saveloc - Saves CheckPoint\n cp - Teleports To Save',0) def player_connect(ev): es.forcevalue('mp_limitteams',0) es.forcevalue('mp_autoteambalance',0) es.forcevalue('mp_falldamage',0) PlayerData[int(ev['userid'])] = {} PlayerData[int(ev['userid'])]['Saves'] = 0 PlayerData[int(ev['userid'])]['CheckPoint'] = None PlayerData[int(ev['userid'])]['VAng'] = None def player_disconnect(ev): del PlayerData[int(ev['userid'])] def player_activate(ev): if PlayerData[int(ev['userid'])]['Saves'] != 0: PlayerData[int(ev['userid'])]['Saves'] = 0 PlayerData[int(ev['userid'])]['CheckPoint'] = None PlayerData[int(ev['userid'])]['VAng'] = None def Restart(pl): PlayerData[int(pl)]['Saves'] = 0 PlayerData[int(pl)]['CheckPoint'] = None PlayerData[int(pl)]['VAng'] = None es.tell(pl,"Checkpoint Erased.") def player_spawn(ev): #Set some spawn proporties # es.server.queuecmd("est_team %s 0" % (ev['userid'])) es.menu(60,ev['userid'],'-HaloShadow\'s Quick CheckPoints-\n \nChat Commands:\n \n !help - Displays this menu again\n !menu - Displays a checkpoint menu\n !save - Saves CheckPoint\n !cp - Teleports To Save\n !block - Toggles your solidity\n \nConsole Commands:\n \n cp_menu - Displays a checkpoint menu\n saveloc - Saves CheckPoint\n cp - Teleports To Save',0) es.setplayerprop(ev['userid'],"CBaseEntity.m_CollisionGroup",2) es.setplayerprop(ev['userid'],"CBasePlayer.m_iHealth",500) es.server.cmd('est_SetPlayerColor %s 255 255 255 70 1' % (ev['userid'])) es.server.cmd('est_give %s weapon_knife' % (ev['userid'])) saytext2(ev['userid'], 0, '\1\3You have respawned!') if PlayerData[int(ev['userid'])]['CheckPoint'] != None: es.ServerCommand('es_setpos %s %s %s %s' % (ev['userid'],PlayerData[int(ev['userid'])]['CheckPoint'][0],PlayerData[int(ev['userid'])]['CheckPoint'][1],PlayerData[int(ev['userid'])]['CheckPoint'][2])) es.server.cmd('est_effect 10 #a 0 sprites/laserbeam.vmt %s %s %s 0 500 1 10 10 10 255 255 255 200 500' % (PlayerData[int(ev['userid'])]['CheckPoint'][0],PlayerData[int(ev['userid'])]['CheckPoint'][1],PlayerData[int(ev['userid'])]['CheckPoint'][2])) es.ServerCommand('es_setang %s %s %s %s' % (ev['userid'],PlayerData[int(pl)]['VAng'][0],PlayerData[int(pl)]['VAng'][1],PlayerData[int(pl)]['VAng'][2])) def player_death(ev): gamethread.delayed(1,es.ServerCommand,('est_spawn %s 1' % (ev['userid']))) gamethread.delayed(2,es.ServerCommand,('est_removeidle ragdoll')) gamethread.delayed(2,es.ServerCommand,('est_removeidle weapon')) es.server.cmd("est_removeidle item") userids_to_switch = set() def es_map_start(ev): userids_to_switch.clear() es.forcevalue('mp_limitteams',0) es.forcevalue('mp_autoteambalance',0) es.forcevalue('mp_falldamage',0) def player_team(ev): # es.server.queuecmd("est_team %s 0" % (ev['userid'])) es.server.queuecmd("est_spawn %s" % (ev['userid'])) def Collision(): pl = es.getcmduserid() if es.getplayerprop(pl,"CBaseEntity.m_CollisionGroup") == 2: es.setplayerprop(pl,"CBaseEntity.m_CollisionGroup",5) saytext2(int(pl), 0, '\1\3You are solid.') elif es.getplayerprop(pl,"CBaseEntity.m_CollisionGroup") == 5: saytext2(int(pl), 0, '\1\3You don\'t block anymore.') es.setplayerprop(pl,"CBaseEntity.m_CollisionGroup",2) else: saytext2(int(pl), 0, '\1\3Error - \1CollisionGroup Incompatible.') def Collision2(pl): if es.getplayerprop(pl,"CBaseEntity.m_CollisionGroup") == 2: es.setplayerprop(pl,"CBaseEntity.m_CollisionGroup",5) saytext2(int(pl), 0, '\1\3You are solid.') elif es.getplayerprop(pl,"CBaseEntity.m_CollisionGroup") == 5: saytext2(int(pl), 0, '\1\3You don\'t block anymore.') es.setplayerprop(pl,"CBaseEntity.m_CollisionGroup",2) else: saytext2(int(pl), 0, '\1\3Error - \1CollisionGroup Incompatible.') def savepos(): #Grab user that ran the command pl = es.getcmduserid() if es.getplayerprop(pl,"CBasePlayer.localdata.m_hGroundEntity") == -1: saytext2(int(pl), 0, '\1\3Error \4- \1Not on ground.') es.cexec(int(pl),'playgamesound Buttons.snd8') return plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] PlayerData[int(pl)]['VAng'] = plyObj.get('viewangle') PlayerData[int(pl)]['CheckPoint'] = list(es.getplayerlocation(pl)) PlayerData[int(pl)]['Saves'] = PlayerData[int(pl)]['Saves'] + 1 es.server.cmd('est_effect 10 #a 0 sprites/laserbeam.vmt %s %s %s 0 500 1 10 10 10 255 0 255 200 500' % (PlayerData[int(pl)]['CheckPoint'][0],PlayerData[int(pl)]['CheckPoint'][1],PlayerData[int(pl)]['CheckPoint'][2])) es.emitsound('player',pl,'buttons/blip1.wav',.5,.5) plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] saytext2(int(pl), index, '\1You have saved a \3checkpoint\1! [\4%s \1Saves]' % (PlayerData[int(pl)]['Saves'])) def savepos2(pl): if es.getplayerprop(pl,"CBasePlayer.localdata.m_hGroundEntity") == -1: saytext2(int(pl), 0, '\1\3Error \4- \1Not on ground.') es.cexec(int(pl),'playgamesound Buttons.snd8') return plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] PlayerData[int(pl)]['VAng'] = plyObj.get('viewangle') PlayerData[int(pl)]['CheckPoint'] = list(es.getplayerlocation(pl)) PlayerData[int(pl)]['Saves'] = PlayerData[int(pl)]['Saves'] + 1 es.server.cmd('est_effect 10 #a 0 sprites/laserbeam.vmt %s %s %s 0 500 1 10 10 10 255 0 255 200 500' % (PlayerData[int(pl)]['CheckPoint'][0],PlayerData[int(pl)]['CheckPoint'][1],PlayerData[int(pl)]['CheckPoint'][2])) es.emitsound('player',pl,'buttons/blip1.wav',.5,.5) plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] saytext2(int(pl), index, '\1You have saved a \3checkpoint\1! [\4%s \1Saves]' % (PlayerData[int(pl)]['Saves'])) def teleport(): pl = es.getcmduserid() if PlayerData[int(pl)]['CheckPoint'] != None: es.ServerCommand('es_setpos %s %s %s %s' % (pl,PlayerData[int(pl)]['CheckPoint'][0],PlayerData[int(pl)]['CheckPoint'][1],PlayerData[int(pl)]['CheckPoint'][2])) es.ServerCommand('es_setang %s %s %s %s' % (pl,PlayerData[int(pl)]['VAng'][0],PlayerData[int(pl)]['VAng'][1],PlayerData[int(pl)]['VAng'][2])) es.server.cmd('est_effect 10 #a 0 sprites/laserbeam.vmt %s %s %s 0 500 1 10 10 10 0 0 255 200 500' % (PlayerData[int(pl)]['CheckPoint'][0],PlayerData[int(pl)]['CheckPoint'][1],PlayerData[int(pl)]['CheckPoint'][2])) plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] saytext2(int(pl), index, '\1You have been \3teleported\1!') es.emitsound('player',pl,'buttons/blip1.wav',.5,.5) else: plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] saytext2(int(pl), index, '\1No \3checkpoint\1 is saved!') def teleport2(pl): if PlayerData[int(pl)]['CheckPoint'] != None: es.ServerCommand('es_setpos %s %s %s %s' % (pl,PlayerData[int(pl)]['CheckPoint'][0],PlayerData[int(pl)]['CheckPoint'][1],PlayerData[int(pl)]['CheckPoint'][2])) es.ServerCommand('es_setang %s %s %s %s' % (pl,PlayerData[int(pl)]['VAng'][0],PlayerData[int(pl)]['VAng'][1],PlayerData[int(pl)]['VAng'][2])) es.server.cmd('est_effect 10 #a 0 sprites/laserbeam.vmt %s %s %s 0 500 1 10 10 10 0 0 255 200 500' % (PlayerData[int(pl)]['CheckPoint'][0],PlayerData[int(pl)]['CheckPoint'][1],PlayerData[int(pl)]['CheckPoint'][2])) plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] saytext2(int(pl), index, '\1You have been \3teleported\1!') es.emitsound('player',pl,'buttons/blip1.wav',.5,.5) else: plyObj = playerlib.getPlayer(pl) index = plyObj.attributes['index'] saytext2(int(pl), index, '\1No \3checkpoint\1 is saved!')