Advertisement
Rio6

istrolid title script

Jul 29th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. var title = title || {};
  2.  
  3. title.title = null;
  4.  
  5. title.getValue = function(team) {
  6. var rst = 0;
  7. for(var player of intp.players) {
  8. if(player.side === team) {
  9. rst += player.money;
  10. for(var i in intp.things) {
  11. var thing = intp.things[i];
  12. if(thing.unit && thing.owner === player.number) {
  13. rst += thing.cost;
  14. }
  15. }
  16. }
  17. }
  18. return rst;
  19. }
  20.  
  21. title.setTitle = function(t) {
  22. if(typeof(t) === "string" && t !== commander.faction) {
  23. commander.faction = t;
  24. account.rootRealSave();
  25. }
  26. }
  27.  
  28. if(title.timer) {
  29. clearInterval(title.timer);
  30. }
  31.  
  32. title.timer = setInterval(function() {
  33.  
  34. if(!commander) return;
  35.  
  36. if(title.title) {
  37. title.setTitle(title.title);
  38. return;
  39. }
  40.  
  41. if((commander.side === "alpha" || commander.side === "beta") &&
  42. sim.state === "running" && !sim.local) {
  43.  
  44. var myValue = title.getValue(commander.side);
  45. var enemyValue = title.getValue(commander.side === "alpha" ? "beta" : "alpha");
  46.  
  47. var diff = myValue - enemyValue;
  48. if(diff > 0) {
  49. title.setTitle("WIN");
  50. } else if(diff < 0) {
  51. title.setTitle("LOSE");
  52. } else {
  53. title.setTitle("TIED");
  54. }
  55. } else {
  56. title.setTitle("R26");
  57. }
  58. }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement