tok124

CB Goal Script

Oct 25th, 2021
860
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cb.settings_choices = [
  2.   {
  3.     name:"goal",
  4.     type:"str",
  5.     label:"Goal Description",
  6.     defaultValue:"Sexy Stripdance"
  7.   },
  8.   {
  9.     name:"amount",
  10.     type:"int",
  11.     label:"Goal Amount",
  12.     defaultValue:200
  13.   },
  14.   {
  15.     name:"tags",
  16.     type:"str",
  17.     label:"Room Tags",
  18.     defaultValue:"#teen #young #new"
  19.   },
  20.   {
  21.     name:'bgclr',
  22.     type:'str',
  23.     label:'Notice Background Color (Hex Color Code)',
  24.     defaultValue: '#ffccff'
  25.   },
  26.   {
  27.     name:'fgclr',
  28.     type:'str',
  29.     label:'Notice text color (Hex Color Code)',
  30.     defaultValue: '#ff66cc'
  31.   }
  32. ]
  33. let goalplus = 0,
  34. goalminus = cb.settings.amount,
  35. biggesttip = 0,
  36. lastTipper = "",
  37. message = "",
  38. sent = 0,
  39. res = "",
  40. res2 = 100 - res,
  41. myspan = "";
  42. const amount = cb.settings.amount;
  43.  
  44. myspan = "\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 0%"
  45.  
  46. cb.onStart(user => {
  47.   cb.changeRoomSubject("Goal: "+cb.settings.goal+" "+goalplus+"/"+amount+" [remaining: "+goalminus+"] "+ cb.settings.tags)
  48. })
  49.  
  50. cb.onTip(tip => {
  51.   lastTipper = tip.from_user
  52.   myspan = ""
  53.  
  54.   if(tip.amount > biggesttip) {
  55.     biggesttip = tip.amount
  56.     biggestuser = biggesttip + "tk By " + tip.from_user
  57.   }
  58.  
  59.   if(tip.amount > amount) {
  60.     goalplus = cb.settings.amount
  61.     goalminus = 0
  62.   }else{
  63.     goalplus += tip.amount
  64.     goalminus -= tip.amount
  65.   }
  66.  
  67.   if(goalplus >= amount) {
  68.     goalplus = cb.settings.amount
  69.     goalminus = 0
  70.     if(sent == 0) {
  71.       cb.changeRoomSubject("Goal: "+cb.settings.goal+" has been reached ! "+ cb.settings.tags)
  72.       cb.sendNotice("GOAL HAS BEEN REACHED !! Thanks to all tippers", "", "#F00", "#FFF", "bold");
  73.       sent = 1;
  74.     }
  75.   }else{
  76.     cb.changeRoomSubject("Goal: "+cb.settings.goal+" "+goalplus+"/"+amount+" [remaining: "+goalminus+"] "+ cb.settings.tags)
  77.   }
  78.  
  79.   res = Math.floor(goalplus / cb.settings.amount * 10) * 10;
  80.   res2 = 100 - res;
  81.  
  82.   for(let i = 0; i < res; i+=10) {
  83.     myspan += "\u2593"
  84.   }
  85.   for(let i = 0; i < res2; i+=10) {
  86.     myspan += "\u2591"
  87.   }
  88.   myspan += " "+res+"%"
  89.  
  90.   cb.drawPanel();
  91.  
  92. })
  93.  
  94. cb.onDrawPanel(function(user) {
  95.     return {
  96.         'template': '3_rows_of_labels',
  97.         'row1_label': 'Tip Received / Goal :',
  98.         'row1_value': goalplus+'/'+amount+' ['+goalminus+' left]',
  99.         'row2_label': 'Progress:',
  100.         'row2_value': myspan,
  101.         'row3_label': 'Highest Tip:',
  102.         'row3_value': biggesttip
  103.     };
  104. });
RAW Paste Data