Advertisement
Guest User

Untitled

a guest
Oct 9th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. var Teamspeak: TeamspeakManager;
  2.  
  3. class TeamspeakManager {
  4.  
  5. browser: BrowserMp;
  6. host: string = "http://localhost:15555";
  7. channel: string;
  8. username: string;
  9. password: string;
  10.  
  11. constructor(channel: string, username: string, password: string) {
  12. this.channel = channel;
  13. this.username = username;
  14. this.password = password;
  15. this.browser = mp.browsers.new(this.host);
  16. }
  17.  
  18. setdata(infoData: string) {
  19. if (!mp.browsers.exists(this.browser))
  20. return false;
  21.  
  22. this.browser.url = this.host + "/custom_players2/" + this.channel + "/" + this.password + "/" + this.username + "/" + infoData + "/";
  23. this.browser.active = false;
  24. }
  25. }
  26.  
  27. mp.events.add("client:InitTeamspeak", (channel: string, username: string, password: string) => {
  28. Teamspeak = new TeamspeakManager(channel, username, password);
  29. });
  30.  
  31.  
  32. setInterval(() => {
  33.  
  34. if (!Teamspeak)
  35. return false;
  36.  
  37. if (mp.players.local.getHealth() < 1)
  38. return Teamspeak.setdata("");
  39.  
  40. var playerList: string = "";
  41.  
  42. mp.players.forEachInStreamRange((element: PlayerMp) => {
  43.  
  44. if (element == mp.players.local)
  45. return false;
  46.  
  47. if (element.getHealth() < 1)
  48. return false;
  49.  
  50. var playerPosition = mp.players.local.position;
  51. var targetPosition = element.getCoords(false);
  52. var distance = Distance(playerPosition, targetPosition);
  53. var cameraRotation = mp.game.cam.getGameplayCamRot(0);
  54.  
  55. cameraRotation.z = Math.PI / 180 * (cameraRotation.z * -1)
  56.  
  57. if (distance > 15)
  58. return false;
  59.  
  60. var x = ((targetPosition.x - playerPosition.x) * Math.cos(cameraRotation.z)) - ((targetPosition.y - playerPosition.y) * Math.sin(cameraRotation.z));
  61. var y = ((targetPosition.x - playerPosition.x) * Math.sin(cameraRotation.z)) + ((targetPosition.y - playerPosition.y) * Math.cos(cameraRotation.z));
  62. var z = targetPosition.z - playerPosition.z;
  63.  
  64. x = x * 10 / 8;
  65. y = y * 10 / 8;
  66.  
  67. var teamspeak = element.getVariable("teamspeak");
  68.  
  69. if (teamspeak)
  70. playerList += teamspeak + "~" + x + "~" + y + "~" + z + "~" + 0 + ";";
  71. });
  72.  
  73. Teamspeak.setdata(playerList);
  74.  
  75. }, 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement