Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var psm = "Cups: %cups | Drunk: %drank | Funds: %money";
- var payment = 10000;
- var price = 1;
- var your_money = 500;
- var show_in_psm = true;
- var cups_drank = 0;
- var cups_owned = 0;
- var toast = true;
- var notify_contact = true;
- var Wnd;
- var total_length = 0;
- var total_messages = 0;
- var flood = false;
- var cups_bought = 0;
- var type = "coffee";
- var unlocked_hc = false;
- var espresso = 0;
- var mocha = 0;
- var hc = 0;
- var coffee = 0;
- var tea = 0;
- function OnEvent_Initialize(){
- if(Messenger.MyStatus > 1){
- OnEvent_SigninReady(Messenger.MyEmail);
- }
- }
- function OnEvent_SigninReady(email){
- if(get("!")===-1){
- _save();
- }
- _load();
- MsgPlus.AddTimer("Save_Statistics",180000);
- MsgPlus.AddTimer("Update_PSM",10000);
- if(show_in_psm===-1||show_in_psm===true){
- Messenger.MyPersonalMessage = "Plus! Café - Mocha: "+mocha+" | Tea: "+tea+" | HChocolate: "+hc+" | Espresso: "+espresso+" | "+ _parse(psm);
- }
- }
- function OnEvent_Uninitialize(){
- _save();
- }
- function parse_txt(){
- var s = "Plus! Café - Statistics\n\n";
- s += "Sent Messages: " + get("total_messages") + "\n";
- s += "Total Length Of Messages: " + get("total_length") + "\n";
- s += "Average Length Of Messages: " + Math.floor((get("total_length")*1)/(get("total_messages")*1)) + "\n";
- s += "Funds: $" + _calc(get("your_money")) + "\n";
- s += "Cups Bought: " + ((get("cups_owned")*1)+(get("cups_drank")*1)) + "\n";
- s += "Cups Drank: " + get("cups_drank") + "\n";
- s += "Statistics Collected Since: " + new Date(get("!")).toGMTString() + "\n";
- return s;
- }
- function parse_xml(){
- var s = "<Statistics>\n\n";
- s += " <Sent_Messages>" + get("total_messages") + "</Sent_Messages>\n";
- s += " <Total_Length_Of_Messages>" + get("total_length") + "</Total_Length_Of_Messages>\n";
- s += " <Average_Length_Of_Messages>" + Math.floor((get("total_length")*1)/(get("total_messages")*1)) + "</Average_Length_Of_Messages>\n";
- s += " <Cups_Owned>" + ((get("cups_owned")*1)+(get("cups_drank")*1)) + "</Cups_Owned>\n";
- s += " <Cups_Drank>" + get("cups_drank") + "</Cups_Drank>\n";
- s += " <Installed>" + new Date(get("!")).toGMTString() + "</Installed>\n</Statistics>";
- return s;
- }
- function SaveToFile(sText){
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var FileObject = fso.OpenTextFile(MsgPlus.ScriptFilesPath+"\\Stats.txt", 2, true,0);
- FileObject.write(sText);
- FileObject.close();
- return true;
- }
- function SaveToXMLFile(sText){
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var FileObject = fso.OpenTextFile(MsgPlus.ScriptFilesPath+"\\Stats.xml", 2, true,0);
- FileObject.write(sText);
- FileObject.close();
- return true;
- }
- function OnEvent_Timer(TimerId){
- if(TimerId==="Save_Statistics"){
- _save();
- MsgPlus.AddTimer("Save_Statistics",180000);
- }
- if(TimerId==="Flood"){
- flood = !flood;
- }
- if(TimerId==="Update_PSM"){
- if(show_in_psm===-1||show_in_psm===true){
- Messenger.MyPersonalMessage = "Plus! Café - Mocha: "+mocha+" | Tea: "+tea+" | HChocolate: "+hc+" | Espresso: "+espresso+" | "+ _parse(psm);
- MsgPlus.AddTimer("Update_PSM",10000);
- }
- }
- }
- function OpenSettings(){
- Wnd = MsgPlus.CreateWnd("gui.xml","WndSettings");
- Wnd.SetControlText("txt_string",psm);
- Wnd.Button_SetCheckState("chk_psm",new Boolean(show_in_psm*-1));
- Wnd.Button_SetCheckState("chk_toast",new Boolean(toast*-1));
- Wnd.Button_SetCheckState("chk_notify",new Boolean(notify_contact*-1));
- }
- function OnWndSettingsEvent_CtrlClicked(PlusWnd, ControlId){
- if(ControlId==="BtnOk"){
- show_in_psm = PlusWnd.Button_IsChecked("chk_psm");
- toast = PlusWnd.Button_IsChecked("chk_toast");
- notify_contact = PlusWnd.Button_IsChecked("chk_notify");
- psm = PlusWnd.GetControlText("txt_string");
- _save();
- PlusWnd.Close(1);
- if(toast===-1||toast===true){
- MsgPlus.DisplayToastContact("Plus! Café","[b]Saved![/b]","Your settings have been saved");
- }
- }
- }
- function _save(){
- set("your_money",your_money);
- set("show_in_psm",show_in_psm);
- set("cups_drank",cups_drank);
- set("cups_owned",cups_owned);
- set("cups_bought",cups_bought);
- set("toast",toast);
- set("notify_contact",notify_contact);
- set("psm",psm);
- set("total_length",total_length);
- set("total_messages",total_messages);
- var d = new Date();
- set("last_saved",d.getDate() + "/" + (d.getMonth()+1) + "/" + d.getYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds());
- }
- function _load(){
- your_money = get("your_money")*1;
- show_in_psm = (get("show_in_psm")*-1)>0;
- cups_drank = get("cups_drank")*1;
- cups_owned = get("cups_owned")*1;
- toast = (get("toast")*-1)>0;
- cups_bought = get("cups_bought")*1;
- notify_contact = (get("notify_contact")*-1)>0;
- psm = get("psm");
- total_length = get("total_length")*1;
- total_messages = get("total_messages")*1;
- }
- function _calc(x){
- x = x/100;
- x = x.toString();
- try{
- x = x.split(".");
- if(x[1].length<2){
- x[1] = x[1]+"0";
- }
- if(x.length>2){
- x[1] = x[1].substr(0,2);
- }
- return x[0]+"."+x[1];
- }catch(e){
- return x;
- }
- }
- function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MsgKind){
- if(Origin!==Messenger.MyName){
- if(Message.search("!cafestats_msg")!==-1&&Message.search("_txt")===-1&&Message.search("_xml")===-1){
- OnEvent_ChatWndSendMessage(ChatWnd, "/cafestats_msg");
- return "Sending Stats";
- }
- if(Message.search("!cafestats_txt")!==-1){
- OnEvent_ChatWndSendMessage(ChatWnd, "/cafestats_txt");
- return "Sending Stats";
- }
- if(Message.search("!cafestats_xml")!==-1){
- OnEvent_ChatWndSendMessage(ChatWnd, "/cafestats_xml");
- return "Sending Stats";
- }
- }
- }
- function OnEvent_ChatWndSendMessage(ChatWnd, Message){
- if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(Message) !== null) {
- var command = RegExp.$1.toLowerCase();
- var parameter = RegExp.$2;
- switch (command) {
- case 'cafestats_msg':
- ChatWnd.SendMessage(parse_txt());
- return "";
- case 'cafestats_txt':
- if(SaveToFile(parse_txt())===true){ChatWnd.SendMessage("/sendfile "+MsgPlus.ScriptFilesPath + "\\" + "stats.txt");}
- return "";
- case 'cafestats_xml':
- if(SaveToXMLFile(parse_xml())===true){ChatWnd.SendMessage("/sendfile "+MsgPlus.ScriptFilesPath + "\\" + "stats.xml");}
- return "";
- case 'dcoffee':
- if(parameter.search(/max/i)!==-1){paramater=1000;}
- if((parameter*1)>=1){
- b_toast = toast;
- b_notify_contact = notify_contact;
- DrinkCoffee(ChatWnd,(parameter*1));
- toast = b_toast;
- notify_contact = b_notify_contact;
- }else{
- ChatWnd.SendMessage("/me has drunk a "+type+"!");
- cups_drunk++;
- }
- return "";
- case 'bcoffee':
- if(parameter.search(/max/i)!==-1){paramater=1000;}
- if((parameter*1)>=1){
- b_toast = toast;
- b_notify_contact = notify_contact;
- BuyCoffee(ChatWnd,(parameter*1));
- toast = b_toast;
- notify_contact = b_notify_contact;
- }else{
- ChatWnd.SendMessage("/me has bought a "+type+"!");
- cups_owned++;
- }
- return "";
- case 'scoffee':
- if(parameter.search(/max/i)!==-1){paramater=1000;}
- if((parameter*1)>=1){
- ChatWnd.SendMessage("/me sold "+parameter+" "+type+"!")
- cups_owned= cups_owned - parameter
- your_money += (parameter*100)
- }else{
- ChatWnd.SendMessage("/me sold a "+type+"!")
- cups_owned= cups_owned - 1
- your_money += 100
- }
- return "";
- case 'throw':
- if(parameter.search(/max/i)!==-1){paramater=1000;}
- if((parameter*1)>=1){
- ChatWnd.SendMessage("/me threw "+parameter+" "+type+"!")
- cups_owned= cups_owned - parameter
- }else{
- ChatWnd.SendMessage("/me threw a "+type+" away!")
- cups_owned= cups_owned - 1
- }
- return "";
- case 'reset':
- cups_owned = 0;
- your_money = 0;
- cups_drank = 0;
- return "";
- case 'demontears':
- ChatWnd.SendMessage("/me drank Demon Tears. Dark Powers surged through his veins.")
- your_money+=1000000
- return "";
- case 'getcoffee':
- if(parameter=="hotchocolate") {
- if(your_money>1000){
- your_money=your_money-1000
- ChatWnd.SendMessage("/me unlocked Hot Chocolate for $10!")
- unlocked_hc = true;
- }
- }
- return "";
- case 'type':
- if(parameter.search(/max/i)!==-1){paramater=1000;}
- if(parameter=="hotchocolate") {
- if(unlocked_hc==true) {
- ChatWnd.SendMessage("/me is now using hot chocolate! It is $2.50 per cup.")
- price = 250;
- type="hot chocolate";
- }
- }
- if(parameter=="mocha") {
- ChatWnd.SendMessage("/me is now using mocha! It is $1 per cup.")
- price = 100;
- type="mocha";
- }
- if(parameter=="espresso") {
- ChatWnd.SendMessage("/me is now using espresso! It is $0.15 per cup.")
- price = 15;
- type="espresso";
- }
- if(parameter=="coffee") {
- ChatWnd.SendMessage("/me is now using coffee! It is $0.20 per cup.")
- price = 20;
- type="coffee";
- }
- if(parameter=="tea") {
- ChatWnd.SendMessage("/me is now using tea! It is $0.10 per cup.")
- price = 10;
- type="tea";
- }
- if(!parameter=="tea"&&!parameter=="espresso"&&!parameter=="coffee"&&!parameter=="mocha") {
- ChatWnd.SendMessage("Type not identified!")
- }
- return "";
- case 'cafestats':
- OnEvent_MenuClicked("stats");
- return "";
- case 'cafeabout':
- OnEvent_MenuClicked("about");
- return "";
- }
- }else{
- if(flood===false){
- your_money += payment;
- total_length += Message.length;
- total_messages++;
- flood = !flood;
- MsgPlus.AddTimer("Flood",5000);
- }
- }
- if(show_in_psm===-1||show_in_psm===true){
- Messenger.MyPersonalMessage = "Plus! Café - Mocha: "+mocha+" | Tea: "+tea+" | HChocolate: "+hc+" | Espresso: "+espresso+" | "+ _parse(psm);
- }
- return _parse(Message);
- }
- function _parse(x){
- x = x.replace(/%cups/gi,cups_owned).replace(/%drank/gi,cups_drank).replace(/%money/gi,"$"+_calc(your_money));
- return x;
- }
- function DrinkCoffee(x,y){
- cups_drank+=y;
- if(type=="coffee") {
- coffee=coffee-y;
- }
- if(type=="hot chocolate") {
- hc=hc-y;
- }
- if(type=="tea") {
- tea=tea-y;
- }
- if(type=="mocha") {
- mocha=mocha-y;
- }
- if(type=="espresso") {
- espresso=espresso-y;
- }
- if(notify_contact===true||notify_contact===-1){
- if(typeof(y)!=="undefined"){
- x.SendMessage("/me has drank "+y+" cups of "+ type +"!");
- }else{
- x.SendMessage("/me has drank a cup of "+ type +"!");
- }
- }
- if(typeof(y)!=="undefined"){
- x.DisplayInfoMessage(Messenger.MyName + " has drank "+y+" cups of "+ type +"!");
- }else{
- x.DisplayInfoMessage(Messenger.MyName + " has drank a cup of "+ type +"!");
- }
- if(toast===-1||toast===true){
- if(typeof(y)!=="undefined"){
- MsgPlus.DisplayToastContact("Plus! Café","·$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just drank "+y+" cups of " + type + "!");
- }else{
- MsgPlus.DisplayToastContact("Plus! Café","·$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just drank a cup of" + type + "!");
- }
- }
- if(show_in_psm===-1||show_in_psm===true){
- Messenger.MyPersonalMessage = "Plus! Café - Mocha: "+mocha+" | Tea: "+tea+" | HChocolate: "+hc+" | Espresso: "+espresso+" | "+ _parse(psm);
- }
- }
- function BuyCoffee(x,y){
- cups_owned+=y;
- your_money=your_money-(price*y);
- if(type=="coffee") {
- coffee+=y;
- }
- if(type=="hot chocolate") {
- hc+=y;
- }
- if(type=="tea") {
- tea+=y;
- }
- if(type=="mocha") {
- mocha+=y;
- }
- if(type=="espresso") {
- espresso+=y;
- }
- if(notify_contact===true||notify_contact===-1){
- if(typeof(y)!=="undefined"){
- x.SendMessage("/me has bought "+y+" cups of "+ type +"!");
- }else{
- x.SendMessage("/me has bought a cup of "+ type +"!");
- }
- }
- if(typeof(y)!=="undefined"){
- x.DisplayInfoMessage(Messenger.MyName + " has bought "+y+" cups of "+ type +"!");
- }else{
- x.DisplayInfoMessage(Messenger.MyName + " has bought a cup of "+ type +"!");
- }
- if(toast===-1||toast===true){
- if(typeof(y)!=="undefined"){
- MsgPlus.DisplayToastContact("Plus! Café","·$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just bought "+y+" cups of " + type + "!");
- }else{
- MsgPlus.DisplayToastContact("Plus! Café","·$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just bought a cup of " + type + "!");
- }
- }
- if(show_in_psm===-1||show_in_psm===true){
- Messenger.MyPersonalMessage = "Plus! Café - Mocha: "+mocha+" | Tea: "+tea+" | HChocolate: "+hc+" | Espresso: "+espresso+" | "+ _parse(psm);
- }
- }
- function set(key, value){
- try{
- return new ActiveXObject("WScript.Shell").RegWrite(MsgPlus.ScriptRegPath + Messenger.MyUserID + "\\" + key, value, "REG_SZ");
- }catch(e){}
- }
- function get(key){
- try{
- return new ActiveXObject("WScript.Shell").RegRead(MsgPlus.ScriptRegPath + Messenger.MyUserID + "\\" + key);
- }catch(e){
- if(key==="!"){
- MsgPlus.DisplayToastContact("Plus! Café","[b]Thank you![/b]", "for downloading Plus! Café\nplease enjoy");
- set("!",new Date());
- return -1
- }else{
- return false;
- }
- }
- }
- function OnGetScriptMenu(nLocation) {
- var s = "<ScriptMenu>";
- s += "<MenuEntry Id='settings'>Settings</MenuEntry>";
- s += "<MenuEntry Id='stats'>Statistics</MenuEntry>";
- s += "<Separator/>";
- s += "<MenuEntry Id='about'>About</MenuEntry>";
- s += "</ScriptMenu>";
- return s;
- }
- function OnEvent_MenuClicked(sMenuItemId, nLocation, OriginWnd) {
- if(sMenuItemId === "settings") {
- OpenSettings();
- }
- if(sMenuItemId === "stats"){
- var stats = MsgPlus.CreateWnd("gui.xml", "WndStats");
- stats.SetControlText("txt_1","[c=4]"+total_messages+"[/c]");
- stats.SetControlText("txt_2","[c=4]"+total_length+"[/c]");
- stats.SetControlText("txt_3","[c=4]"+Math.floor(total_length/total_messages)+"[/c]");
- stats.SetControlText("txt_4","[c=4]"+cups_owned+"[/c]");
- stats.SetControlText("txt_5","[c=4]"+cups_drank+"[/c]");
- stats.SetControlText("txt_6","[c=4]$"+_calc(your_money)+"[/c]");
- var dat = get("!");
- dat = dat.split(" ");
- dat = dat[2]+"/"+dat[1]+"/"+dat[5]
- stats.SetControlText("imp","[c=4]Since: "+dat+"[/c]");
- }
- if(sMenuItemId === "about") {
- MsgPlus.CreateWnd("gui.xml", "WndAbout");
- }
- }
- function OnGetScriptCommands(){
- var commands = '<ScriptCommands>';
- commands+='<Command>';
- commands+='<Name>bcoffee</Name>';
- commands+='<Description>Buy a cup of coffee</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>scoffee</Name>';
- commands+='<Description>Sell a cup of coffee</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>dcoffee</Name>';
- commands+='<Description>Drink a cup of coffee</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>cafestats</Name>';
- commands+='<Description>Stats from Plus! Café</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>cafeabout</Name>';
- commands+='<Description>About Plus! Café</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>cafestats_msg</Name>';
- commands+='<Description>Send Plus! Café statistics to a contact as a MESSAGE</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>cafestats_txt</Name>';
- commands+='<Description>Send Plus! Café statistics to a contact as a TXT FILE</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>cafestats_xml</Name>';
- commands+='<Description>Send Plus! Café statistics to a contact as an XML FILE</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>reset</Name>';
- commands+='<Description>Reset the stats.</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>type</Name>';
- commands+='<Description>Change the cup type.</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>throw</Name>';
- commands+='<Description>Throw the cup away.</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>demontears</Name>';
- commands+='<Description>A powerful substance found in a rare cave within the shadow realm.</Description>';
- commands+='</Command>';
- commands+='<Command>';
- commands+='<Name>getcoffee</Name>';
- commands+='<Description>Unlock a specific coffee.</Description>';
- commands+='</Command>';
- commands+='</ScriptCommands>';
- return commands;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement