Advertisement
Guest User

Untitled

a guest
Sep 16th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. tagpro.ready(function() {
  2.  
  3. // Set names here:
  4. var names = [
  5. "HappyGilmore",
  6. "@@@@@@@@@@@@",
  7. ];
  8.  
  9. // Set trigger key code here - you can find key mappings here: https://css-tricks.com/snippets/javascript/javascript-keycodes/
  10. var triggerKeyCode = 78; //trigger is the "n" key
  11.  
  12. var i = localStorage.getItem("indexForName") || 0;
  13. function switchName() {
  14. i = (i >= names.length) ? 0 : i;
  15. var newName = names[i] || 'error';
  16. tagpro.socket.emit('name', newName);
  17. i++;
  18. localStorage.setItem("indexForName", i);
  19. }
  20.  
  21. document.onkeyup = function(e) {
  22. if (tagpro.disableControls || tagpro.spectator) {
  23. return;
  24. }
  25. if (e.keyCode === triggerKeyCode) {
  26. switchName();
  27. }
  28. };
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement