Shoutbox

i have a problem with my script - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: i have a problem with my script (/showthread.php?tid=76471)

i have a problem with my script by crzymike13 on 08-01-2007 at 10:21 PM

someone plz help me i am almost done with my first script and when i save it i get this in the debug window:

Error:  Expected '}' (code: -2146827279
           File:  Pizza Shop.js. Line: 139

heres the line:

saveAll(); // I save the data

someone plz help me


RE: i have a problem with my script by MeEtc on 08-01-2007 at 10:24 PM

you'll have to post a bit more code than that, preferably the entire script. you probably missed the } in the previous function or statement


RE: i have a problem with my script by crzymike13 on 08-01-2007 at 10:31 PM

k then heres the script

var ScriptName = "Pizza Shop 1.0";
var nbrPizza;
var nbrEaten;
var nbrMoney;
var lang;
var givPizza = false;
var givMoney = false;
var givMoneyS = false;
var hmmcig = [25, 50, 75, 100, 500, 1000, 5000, 10000, 100000];
var ungivPizza = false;
var ungivMoney = false;
var ungivMoneyS = false;
var nbrDonEachMess = 50;
var toastEn;

function OnEvent_Initialize(MessengerStart)
{
    Debug.Trace("Welcome To The Pizza Shop!");
}

function OnEvent_Uninitialize(MessengerExit)
{
}

function OnEvent_Signin(Email)
{
    if(Email == "michael1194@roadrunner.com")
    {
        var Message = "Hello " + Messenger.MyName + "!";
        Message = MsgPlus.RemoveFormatCodes(Message);
        MsgPlus.DisplayToast("", Message);
    }
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
        nbrMoney = nbrDonEachMess+Number(nbrMoney); // I give you money when you speek
        switch (Message) {
                case "!givePizza": //you want give him/her a pizza
                        if (nbrPizza >= 1){
                                if (!givPizza) {
                                        givPizza = ChatWnd;
                                        if (toastEn == "Yes") MsgPlus.DisplayToast("Pizza Shop", lang[11]);
                                } else {
                                        return "!cancelgivepizza";
                                }
                        } else {
                                if (toastEn == "Yes") MsgPlus.DisplayToast("PizzaShop", lang[11]);
                                return "";
                        }
                        nbrMoney -= nbrDonEachMess; // No give Money
                break;
               
                case "!cancelgivepizza": // you dont want to give him/her a pizza
                        if (!givPizza) {
                                return "!givepizza";
                        } else {
                                givPizza =  false;
                                if (toastEn == "yes") MsgPlus.DisplayToast("PizzaShop", lang[19]);
                        }
                        nbrMoney -= 50 // No give money
                break;
               
                case "!cancelgivemoney": //you dont want to give him/her money
                        if (!givMoney) {
                                return "";
                        } else {
                                givMoney = false;
                                givMoneyS = false;
                                if (toastEn == "Yes") MsgPlus.DisplayToast("PizzaShop", lang[19]);
                        }
                        nbrMoney -= nbrDonEachMess; // No give money
                break;
               
                case "!nogivepizza": // you dont want a pizza
                        if (!ungivPizza) {
                                return "";
                        } else {
                                ungivPizza = false;
                        }
                        nbrMoney -= nbrDonEachMess; // No give money
                break;
               
                case "!yesgivepizza": //you want a pizza
                        if (!ungivPizza) {
                                return "";
                        } else {
                                ungivPizza = false
                                nbrPizza++;
                        }
                        nbrMoney -=nbrDonEachMess; // No give Money
                break;
               
                case "!nogivemoney": //you dont want money
                        if (ungivMoney) {
                               return "";
                        } else {
                               ungivMoney = false;
                        }
                        nbrMoney -= nbrDonEachMess; // No give money
                break;
               
                case "!yesgivemoney": // you want money
                        if (ungivMoney) {
                               return "";
                        } else {
                                ungivMoney = false;
                                nbrMoney += hmmcig[ungivMoneyS];
                                ungivMoneyS = false;
                        }
                        nbrMoney -= nbrDonEachMess; // No give money
                break;
        }
        if (Message.substring(0, 11) == "!givemoney ") { // you want to give him/her money
                if (!givMoney) {
                        if (nbrMoney >= hmmcig[Message.substring(11, Message.length)]) {
                                givMoney = ChatWnd;
                                givMoneyS = Message.substring(11, Message.length);
                                if (toastEn == "Yes") MsgPlus.DisplayToast("PizzaShop", lang[18]);
                        } else {
                                return "";
                        }
                } else {
                        return "";
                }
                nbrMoney -=nbrDonEachMess; // No give money
        }
        saveAll(); // I save the data


RE: i have a problem with my script by matty on 08-01-2007 at 10:35 PM

You are missing a } at the very end of the script.


RE: i have a problem with my script by crzymike13 on 08-01-2007 at 10:36 PM

k its fixet ty


RE: i have a problem with my script by matty on 08-01-2007 at 10:38 PM

Your welcome but I don't mean to be rude but people need to start reading the error message they are descriptive and explain that there is a problem and where it is.


RE: i have a problem with my script by LifelesS on 08-02-2007 at 12:02 AM

More important than that, at least in my opinion, I think code organization is a very good thing:P

For example, if you use

code:
if(code...)
{
    a little more code...
}

instead of

code:
if(code...){
    the code... }

and so on...

Another good thing, is to use something else that the default script editor. I use phpDesigner and it matches the () and {}, it would work like so in the above example:

code:
if(code...)
{
    a little more code...
}