quote:
Originally posted by Arsenal
Or to shorten the script. You can just use an array like so..
function OnEvent_Signin(Email)
{
var emails = new Array("account1@live.com","account2@live.com","etc..")
for(i=0; i<emails.length; i++){
if(Email == emails[i])
{
var Message = "Hello :\n " + Messenger.MyName + "!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Allowed", Message,'notify.mp3');
}
else
{
var Message = "Access Denied " + "!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Not Allowed", Message,'notify.mp3');
Messenger.signout();
}
}
}
It should work. I havent tested it though.
No that won't work. If your account is say "account1@live.com" then the first time through the loop it will approve you, but then it will go through the loop again, and your email address is not account2@live.com, and so it will not approve you and sign you out.
If your account is the last one in the array, I still don't think it would work, as you will have already been signed out in the previous iterations of the loop.
If you wanted to do it like this, I think the simplest way would be to have a separate function whichchecks if your email address is in the stored array. It should return true if your email address is found, or return false if it goes through the whole loop.
eg
code:
function checkAddress(Email)
{
var emails = new Array("account1@live.com","account2@live.com","etc..")
for(i=0; i<emails.length; i++){
if(Email == emails[i])
{
return true;
}
}
return false;
}
of course, I made the same mistake as you, and didn't test it....