daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Sep 14th, 2017 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # SetAim Command
  2. # By MiB
  3. # wcs_setaim <userid> <target> <z add>
  4. from es import getplayerlocation,getuserid,createvectorstring,createvectorfrompoints,splitvectorstring,server
  5. from playerlib import getPlayer
  6. from math import atan,degrees,sqrt,pow as powm
  7. from wcs.logging import log
  8. from cmdlib import registerServerCommand,unregisterServerCommand
  9.  
  10. def load():
  11.     registerServerCommand("wcs_setaim",Register,"")
  12.  
  13. def unload():
  14.     unregisterServerCommand("wcs_setaim")
  15.  
  16. def Exists(userid):
  17.     return getuserid(userid)
  18.  
  19. def viewCoord(userid,value):
  20.     '''Credit goes to the people who made this for playerlib, I just tweaked a few things'''
  21.     player = getPlayer(userid)
  22.     myLocation = player.getEyeLocation()
  23.     myVector = createvectorstring(myLocation[0], myLocation[1], myLocation[2])
  24.     theVector = createvectorstring(value[0], value[1], value[2])
  25.     ourVector = createvectorfrompoints(myVector, theVector)
  26.     ourVector = splitvectorstring(ourVector)
  27.     myViewAngle = player.getViewAngle()
  28.     ourAtan = degrees(atan(float(ourVector[1]) / float(ourVector[0])))
  29.     if float(ourVector[0]) < 0:
  30.         RealAngle = ourAtan + 180
  31.     elif float(ourVector[1]) < 0:
  32.         RealAngle = ourAtan + 360
  33.     else:
  34.         RealAngle = ourAtan
  35.     yAngle = RealAngle
  36.     xAngle = 0 - degrees(atan(ourVector[2] / sqrt(powm(float(ourVector[1]), 2) + powm(float(ourVector[0]), 2))))
  37.     server.queuecmd("es_xsetang %s %s %s %s"%(userid,xAngle,yAngle,myViewAngle[2]))
  38.  
  39. def Register(args):
  40.     if len(args) == 3:
  41.         if Exists(args[0]):
  42.             if not getPlayer(args[0]).isdead:
  43.                 if Exists(args[1]):
  44.                     x,y,z = getplayerlocation(args[1])
  45.                     z += float(args[2])
  46.                     viewCoord(args[0],(x,y,z))
  47.                 else:
  48.                     log("Got: wcs_setaim " + " ".join(map(str,args)) + ".")
  49.                     log("Information: Unknown target.")
  50.             else:
  51.                 log("Got: wcs_setaim " + " ".join(map(str,args)) + ".")
  52.                 log("Information: Userid is dead.")
  53.         else:
  54.             log("Got: wcs_setaim " + " ".join(map(str,args)) + ".")
  55.             log("Information: Unknown userid.")
  56.     else:
  57.         log("Got: wcs_setaim " + " ".join(map(str,args)) + ".")
  58.         log("Information: Got too many or too little arguments.")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top