[REQUEST]"Plus Cafe" Changing ... |
Author: |
Message: |
kyozo_43
New Member
Posts: 8
95 / /
Joined: Jun 2010
|
O.P. [REQUEST]"Plus Cafe" Changing ...
Hey All, I'm Just Wondering, Could Someone Please Tell Me How To Make The Script - Plus Cafe - And Edit It, So It Can Be - Not Sent Messages, But Received Messages ... (RECEIVE A Message And You Get 7c ... )
This post was edited on 06-30-2010 at 08:08 AM by kyozo_43.
|
|
06-30-2010 05:54 AM |
|
|
matty
Scripting Guru
Posts: 8332 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [REQUEST]"Plus Cafe" Changing ...
Have you looked at the scripting documentation at all? There are 2 functions
- OnEvent_ChatWndSendMessage
- OnEvent_ChatWndReceiveMessage
|
|
06-30-2010 01:28 PM |
|
|
kyozo_43
New Member
Posts: 8
95 / /
Joined: Jun 2010
|
O.P. RE: [REQUEST]"Plus Cafe" Changing ...
@matty OMFG THANK YOU SOOOOOO MUCH ... I REALLY APPRECIATE IT!
@matty but ... Which One(s) Do I Change?
|
|
07-01-2010 06:23 AM |
|
|
Chris4
Elite Member
Posts: 4460 Reputation: 84
33 / /
Joined: Dec 2004
|
RE: [REQUEST]"Plus Cafe" Changing ...
quote: Originally posted by matty
Have you looked at the scripting documentation at all?
|
|
07-01-2010 08:11 AM |
|
|
kyozo_43
New Member
Posts: 8
95 / /
Joined: Jun 2010
|
O.P. RE: [REQUEST]"Plus Cafe" Changing ...
YES I HAVE ... BUT I DON'T KNOW WHICH ONES TO CHANGE ... CAUSE WHEN I CHANGED THEM ALL MY MSN STUFFED UP AND WHEN I SENT A MESSAGE ALL THAT CAME UP WAS MY USERNAME ... LOL
|
|
07-01-2010 12:44 PM |
|
|
djdannyp
Elite Member
Danny <3 Sarah
Posts: 3546 Reputation: 31
38 / /
Joined: Mar 2006
|
RE: [REQUEST]"Plus Cafe" Changing ...
Please don't type in block capitals, it's considered to be shouting and therefore rude.
Look for OnEvent_ChatWndReceiveMessage in the script code (as this is what causes actions to be performed when you receive a message) and replace the relevant bits with OnEvent_ChatWndSendMessage to change it to respond when you send a message.
All you should need to change is "Receive" to "Send" as they are the same.
If it doesn't work then refer to the scripting documentation where it says what paramaters are needed for those functions and how to use them.
Or if you post the code here using [code=js]code here[/code] tags to display it, then someone may take a look at it and help you
|
|
07-01-2010 12:49 PM |
|
|
kyozo_43
New Member
Posts: 8
95 / /
Joined: Jun 2010
|
O.P. RE: [REQUEST]"Plus Cafe" Changing ...
oh sorry ... but when i change ALL the "OnEvent_ChatWndSendMessage" to "OnEvent_ChatWndRecieveMessage" my msn stuffs up - when i send a message all that comes up is my name, and when my friend sends a message, all that comes up is his name ... WIERD (oh there i go again with my caps)
|
|
07-02-2010 11:18 AM |
|
|
CookieRevised
Elite Member
Posts: 15515 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: [REQUEST]"Plus Cafe" Changing ...
Code needs to be changed too because those two functions behave in a different way. Simply changing the name of the function only very rarely works; it's bound to give you errors or unexpected behaviour.
This is especially true for the Plus Cafe script. It needs to be recoded for what you want (not to mention it is cheating).
This post was edited on 07-03-2010 at 03:33 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
07-03-2010 03:26 PM |
|
|
kyozo_43
New Member
Posts: 8
95 / /
Joined: Jun 2010
|
O.P. RE: [REQUEST]"Plus Cafe" Changing ...
Spoiler for code (click to show):
Javascript code:
var psm = "Cups: %cups | Drunk: %drank | Funds: %money";
var payment = 10;
var price = 300;
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;
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 = "The Kyozo Café - " + _parse(psm);
}
}
function OnEvent_Uninitialize(){
_save();
}
function parse_txt(){
var s = "The Kyozo 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 = "The Kyozo Café - " + _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("The Kyozo 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 'dchocolate':
if(parameter.search(/max/i)!==-1){paramater=1000;}
if((parameter*1)>=1){
b_toast = toast;
b_notify_contact = notify_contact;
for(var i = 0; i < (parameter*1); i++){
DrinkCoffee(ChatWnd,(parameter*1));
toast = false;
notify_contact = false;
}
toast = b_toast;
notify_contact = b_notify_contact;
}else{
DrinkCoffee(ChatWnd);
}
return "";
case 'bchocolate':
if(parameter.search(/max/i)!==-1){paramater=1000;}
if((parameter*1)>=1){
b_toast = toast;
b_notify_contact = notify_contact;
for(var i = 0; i < (parameter*1); i++){
BuyCoffee(ChatWnd,(parameter*1));
toast = false;
notify_contact = false;
}
toast = b_toast;
notify_contact = b_notify_contact;
}else{
BuyCoffee(ChatWnd);
}
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 = "The Kyozo Café - " + _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){
if(cups_owned>0){
cups_drank++;
cups_owned--;
if(notify_contact===true||notify_contact===-1){
if(typeof(y)!=="undefined"){
x.SendMessage("/me has drank "+y+" cups of hot chocolate!");
}else{
x.SendMessage("/me has drank a cup of hot chocolate!");
}
}
if(typeof(y)!=="undefined"){
x.DisplayInfoMessage(Messenger.MyName + " has drank "+y+" cups of hot chocolate!");
}else{
x.DisplayInfoMessage(Messenger.MyName + " has drank a cup of hot chocolate!");
}
if(toast===-1||toast===true){
if(typeof(y)!=="undefined"){
MsgPlus.DisplayToastContact("The Kyozo Café","ˇ$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just drank "+y+" cups of hot chocolate!");
}else{
MsgPlus.DisplayToastContact("The Kyozo Café","ˇ$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just drank a cup of hot chocolate!");
}
}
}else{
if(toast===-1||toast===true){
MsgPlus.DisplayToastContact("The Kyozo Café","ˇ$4Can't do that!","You need to buy more cups!");
}
}
if(show_in_psm===-1||show_in_psm===true){
Messenger.MyPersonalMessage = "The Kyozo Café - " + _parse(psm);
}
}
function BuyCoffee(x,y){
if((your_money-price)>=0){
cups_owned++;
your_money = your_money-price;
if(notify_contact===true||notify_contact===-1){
if(typeof(y)!=="undefined"){
x.SendMessage("/me has bought "+y+" cups of hot chocolate!");
}else{
x.SendMessage("/me has bought a cup of hot chocolate!");
}
}
if(typeof(y)!=="undefined"){
x.DisplayInfoMessage(Messenger.MyName + " has bought "+y+" cups of hot chocolate!");
}else{
x.DisplayInfoMessage(Messenger.MyName + " has bought a cup of hot chocolate!");
}
if(toast===-1||toast===true){
if(typeof(y)!=="undefined"){
MsgPlus.DisplayToastContact("The Kyozo Café","ˇ$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just bought "+y+" cups of hot chocolate!");
}else{
MsgPlus.DisplayToastContact("The Kyozo Café","ˇ$4"+MsgPlus.RemoveFormatCodes(Messenger.MyName),"just bought a cup of hot chocolate!");
}
}
}else{
if(toast===-1||toast===true){
MsgPlus.DisplayToastContact("The Kyozo Café","ˇ$4Can't do that!","You don't have the money!");
}
}
if(show_in_psm===-1||show_in_psm===true){
Messenger.MyPersonalMessage = "The Kyozo Café - " + _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("The Kyozo Café","[b]Thank you![/b]", "for downloading The Kyozo 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>bchocolate</Name>';
commands+='<Description>Buy a cup of hot chocolate</Description>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>dchocolate</Name>';
commands+='<Description>Drink a cup of hot chocolate</Description>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>cafestats</Name>';
commands+='<Description>Stats from The Kyozo Café</Description>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>cafeabout</Name>';
commands+='<Description>About The Kyozo Café</Description>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>cafestats_msg</Name>';
commands+='<Description>Send The Kyozo Café statistics to a contact as a MESSAGE</Description>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>cafestats_txt</Name>';
commands+='<Description>Send The Kyozo Café statistics to a contact as a TXT FILE</Description>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>cafestats_xml</Name>';
commands+='<Description>Send The Kyozo Café statistics to a contact as an XML FILE</Description>';
commands+='</Command>';
commands+='</ScriptCommands>';
return commands;
}
Well Theres The Code ... So Could Someone Please Help Me!!!!!
This post was edited on 07-08-2010 at 12:57 PM by Tochjo.
|
|
07-08-2010 12:01 PM |
|
|
matty
Scripting Guru
Posts: 8332 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [REQUEST]"Plus Cafe" Changing ...
By changing OnEvent_ChatWndReceiveMessage to OnEvent_ChatWndSendMessage will not work in this case. The reason is because there is already a function defined called OnEvent_ChatWndSendMessage. 2 functions with the same name cannot exist in the same scope. With that being said; learn some programming and combine the 2 functions into 1.
|
|
07-08-2010 12:48 PM |
|
|
|
|